dlsc-software-consulting-gmbh / GMapsFX

Java API for using Google Maps within a JavaFX application.
http://rterp.github.io/GMapsFX/
Apache License 2.0
320 stars 119 forks source link

Map (v11.0.6) freezes on Java/FX 17.0.2 shortly after beeing initialized #202

Open bgmf opened 2 years ago

bgmf commented 2 years ago

The code is rather easy: in the UI code I create an empty container for the map (mapCard) and I use the controller to create the map and add Data (markers):

mapCard.content.clear()
mapCard.content.children.add(
    GoogleMapView().apply {
        mapView = this
        minHeight = 320.0
        maxHeight = minHeight
        setKey("...")

        addEventFilter(ScrollEvent.ANY) {
            if (!it.isControlDown) {
                parent.fireEvent(it.copyFor(parent, parent))
                it.consume()
            }
        }
    }
)
mapView?.addMapInitializedListener(object : MapComponentInitializedListener {
    override fun mapInitialized() {
        mapView?.createMap(
            MapOptions().apply {
                center(LatLong(46.80121, 8.22669))
                mapType(MapTypeIdEnum.ROADMAP)
                mapTypeControl(false)
                overviewMapControl(false)
                panControl(false)
                rotateControl(false)
                scaleControl(false)
                streetViewControl(false)
                zoomControl(true)
                zoom(8.0)
            }
        ).also { map = it }
        mapView?.removeMapInitializedListener(this)
        initResults()
        toggleGroup.toggles.forEach { (it as ToggleButton).isDisable = false }
    }
})

The initResults() method loads some data from a local database and creates markers. I'm using Kotlin for the application and everything runs in a co routine, but that should not be an issue.

What happens is, the map freezes shortly after being initialized, or beeing just for some seconds. No zoomin, no map moving, no marker interaction.
What is notable, though, is that the web container itself still seems to be reacting - I've seen a grey rectanguar border around a marker appearing at least once. So I think, that the input events somehow are not forwarded to the map.

To make sure, it's not something else, I've removed the initResult() method as well as the scroll event filter. No change.

Since I have no more ideas, I thought raising an issue might be a good idea.

#edit: maybe that's noteworthy: I'm using the classpath variant, the application is not modularized...

RyuDarc commented 2 years ago

I got mine randomly freeze too, right now using javafx 17 + java 17 and lastest build of gmapsfx.

Try few more times(eg.10 times). I will got 2 \~3 times properly functional, 7\~8 times freezes, and if you access GoogleMap again, it will throw MapNotInitializedException.

I've tried to renew map by

   map = googleMapView.getMap();

~but no luck, it will not be able to initialize agian.~

edit: if you press any of the links below and rightclick back to map, then the frozen will get resolved.

bgmf commented 2 years ago

@RyuDarc

if you press any of the links below and rightclick back to map, then the frozen will get resolved.

What do you mean by that? I have no liks in the map.

danielwilbanks commented 2 years ago

Were you able to fix this? I'm having the same issue but oddly it only impacts my windows machines...not the mac.

EDIT: If anyone else encounters this I solved it by going back to 11.0.2. Not an ideal solution but for my purposes it works fine and maybe it will work for yours too.

bgmf commented 1 year ago

No sorry. Unfortunately I wasn't able to work around this. But I will try the suggested older version.

@dlemmermann Have you ever experienced this behaviour in any of your apps?

dlemmermann commented 1 year ago

No, I have not. Then again ... not using it extensively at the moment.

danielwilbanks commented 1 year ago

So after running a while on 11.0.2 with no issues now every version except 11.0.7 doesn't load a map at all, and 11.0.7 still has the issue with the map freezing. So we're back where we started on this issue. @dlemmermann any ideas on what I could try?