Code Monkey home page Code Monkey logo

Comments (14)

sothawo avatar sothawo commented on August 12, 2024

strange stacktrace. I never did create and discard a MapView in a program so often; I'll to to reproduce this.

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

I created a small TestApp where I repeatedly open a Dialog with a MapView and discard it automatically after 5 seconds branched from 1.x.

I found, that when running from within IntelliJ on macOS 10.14 (using jdk1.8.0_192) I get crashes when I switch the focus to the second monitor or switch desktops. But the stacktrace is different, I only see some errors from native calls:

2018-11-10 19:07:36.425 java[33017:4934001] unrecognized type is 4294967295
2018-11-10 19:07:36.425 java[33017:4934001] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1671/AppKit.subproj/NSEvent.m:1969
2018-11-10 19:07:36.428 java[33017:4934001] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: _type > 0 && _type <= kCGSLastEventType'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff3275043d __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff5e65d720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff3276b08e +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff34b0755d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   AppKit                              0x00007fff2fbf6acd -[NSEvent _initWithCGEvent:eventRef:] + 3272
	5   AppKit                              0x00007fff2ff4a188 +[NSEvent eventWithCGEvent:] + 120
	6   libglass.dylib                      0x000000012d77717b listenTouchEvents + 59
	7   SkyLight                            0x00007fff5871b782 _ZL19processEventTapDataPvjjjPhj + 148
	8   SkyLight                            0x00007fff5861abb2 _XPostEventTapData + 278
	9   SkyLight                            0x00007fff5871b690 _ZL22eventTapMessageHandlerP12__CFMachPortPvlS1_ + 132
	10  CoreFoundation                      0x00007fff326aea5b __CFMachPortPerform + 246
	11  CoreFoundation                      0x00007fff326ae959 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
	12  CoreFoundation                      0x00007fff326ae8b7 __CFRunLoopDoSource1 + 527
	13  CoreFoundation                      0x00007fff32696945 __CFRunLoopRun + 2574
	14  CoreFoundation                      0x00007fff32695ce4 CFRunLoopRunSpecific + 463
	15  HIToolbox                           0x00007fff3192f895 RunCurrentEventLoopInMode + 293
	16  HIToolbox                           0x00007fff3192f4d4 ReceiveNextEventCommon + 371
	17  HIToolbox                           0x00007fff3192f348 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	18  AppKit                              0x00007fff2fbec95b _DPSNextEvent + 997
	19  AppKit                              0x00007fff2fbeb6fa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
	20  libglass.dylib                      0x000000012d764af3 +[GlassApplication enterNestedEventLoopWithEnv:] + 195
	21  libglass.dylib                      0x000000012d76551a Java_com_sun_glass_ui_mac_MacApplication__1enterNestedEventLoopImpl + 74
	22  ???                                 0x000000011a618667 0x0 + 4737566311
	23  ???                                 0x000000011a608040 0x0 + 4737499200
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I am not able to reproduce this when running the program from the commandline with the samt jdk version, there it works as it should no matter if I change the focus to a different monitor and or switch desktops. The new dialog appear and disappear as they should.

I monitored the application in jvisualvm. No problems when attaching to the app started from the commandline, but the crashes mentioned above when launched from IJ.

Can you provide a minimal sample that reproduces the error?

Concerning leaks: I can see that the MapView-WeakRef-Cleaner threads are being kept around, I'll fix this, but I do not think that this causes your problem.

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

I created a demo for this problem. Just press the "Add one map" button until the new map does not load its data anymore. This happens if I close each old map before and when just adding new ones. I have the feeling that it is something about the complexity of the map, but I have not verified until now.

https://github.com/joha78/mapjfx-problem-demo

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

I am running the app out of IntelliJ. I try it on command line later. That sounds strange.

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

I started your test app with

-Dprism.debug=true -Dprism.pooldebug=true -Dprism.poolstats=true -Dprism.verbose=true

and that showed that this probably is a prolem with es vram pool:

ES2 Vram Pool: 536.708.096 used (100,0%), 536.870.912 target (100,0%), 536.870.912 max

This is pretty lowlevel Javafx stuff, where I am not sure how this could be handled. I found this page: https://wiki.openjdk.java.net/pages/viewpage.action?pageId=20415996 but I do not know at the moment how this could be handled from MapView's side. I'll keep on searching later.

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

I just ran your app in jvisualvm, created and closed 15 Tabs. In jvisualvm I see that even after run a garbage collection for several times, there are still the 15 MapViews around - and the 15 DetachableTab objects that own them.
So I think the first thing to do would be to release the objects the DetachableTab references on closing.

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

I tried changing my example in a way that it creates Tabs with Labels inside. If I close all Tabs all the Labels are discarded by GC. If I replace the Labels with MapViews and close all Tabs, the Tabs and MapViews are not discarded anymore. Maybe it is the MapView-WeakRef-Cleaner?

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

I can easily create >=30 tabs with MapViews if I resize the window like 100x100 px. If I maximize the window it is possible to open about 5 tabs.

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

I found a "workaround". It's running the app with -Dprism.order=sw
Obviously, it does not solve the problem with not garbage collecting the MapView.
This unfortunately disables hardware accelerated java fx rendering.


Another workaround is increasing the vram dramatically with -Dprism.targetvram=6G. Obviously the texture memory is not freed correctly. Maybe the not garbage collected MapView is the reason.


https://wiki.openjdk.java.net/display/OpenJFX/Debug+Flags

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

yes, I think the MapView should be gc'ed, but the the DetachableTabs holding a reference to the MapViews aren't collected either. Does closing a tab by clicking the 'x' release the objjects created in this tab?

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

Just to be save I added some code that clears the Tab content if the 'x' is clicked.

I found out that all the DetachableTabs are garbage collected correctly if they contain labels, but they are not garbage collected if they contain MapViews.

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

I have added a method MapView.close() which will stop the background thread that cleans the weak references. This is in 1.20.0 for JDK 8 and 2.1.0 for JDK 11, should be available in maven central tomorrow. I changed the code in your sample to:

        addButton.setOnAction(event -> {
            if (bingMapsApiKeyField.getText() == null || bingMapsApiKeyField.getText().trim().isEmpty()) {
                DetachableTab newTab = new DetachableTab("Error", new Label("Please provide an API key for bing maps"));
                tabPane.getTabs().add(newTab);
                tabPane.getSelectionModel().select(newTab);
            } else {
                DetachableTab newTab =
                        new DetachableTab("Map") {
                            {
                                final MapView mapView = buildMap();
                                setContent(mapView);
                                setOnClosed(evt -> {
                                    System.out.println("tab closed");
                                    mapView.close();
                                    setContent(null);
                                });
                            }

                        };
                tabPane.getTabs().add(newTab);
                tabPane.getSelectionModel().select(newTab);
            }
        });

to call this method when the tab is closed (and releasing the MapView object by setting the tab's content to null). With this, when opening and closing multiple tabs, and after triggering a garbage collection, the MapView instances are gone.

I could open tabs and close them without getting the error (stopped after 40 tabs) without explicitly triggering a gc.

Please try if this works for you as well.

from mapjfx.

joha78 avatar joha78 commented on August 12, 2024

Yes. That works. Thank you. In my real app its a bit more complicated. I need to figure out a way how to call close() from the Tab, because my Tab does not (and should not) know about it's content. But that should be possible.

Nevertheless, its not possible to open more than 6 fullscreen maps at the same time :-(

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

So I will close this issue, as I don't think that we can do more from MapViews side.

from mapjfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.