flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 501 forks source link

Map is blank after going back from background #1023

Closed PawelZygmax closed 2 years ago

PawelZygmax commented 2 years ago

Map is blank, only mapbox logo is visible after being in background and going back. Is there any option to refresh map? Im trying setState in didChangeAppLifecycleState, invalidateAmbientCache on mapBoxController but nothing works. Any ideas how to make this works properly?

PawelZygmax commented 2 years ago

Worth to mention that when there are many apps in background, which in result cause huge memory usage so there is more probability map is going to be blank. It's may be only a few minutes in background and this bug occur. Actually tested on flutter 2.10.4 with compiledSdk 31 and targetSdk 31, Redmi note 9T. @tobrun @felix-ht any ideas how to get over with it?

Albertbol commented 2 years ago

Same issue here.

lorenzorheinicke commented 2 years ago

We had the same problem after upgrading to v0.15. We got it to work by re-enabling textureMode to true in the MapboxMapBuilder.java file (line 26). We can no longer reproduce this issue after making the change in our forked repo.

We are aware that textureMode has a huge performance impact, but this blank map issue was going to potentially impact a big percentage of our user base.

We are currently looking at making this flag dynamic when creating the Mapbox widget.

felix-mittermeier commented 2 years ago

I am also able to reproduce this on Android 12.

felix-mittermeier commented 2 years ago

@PawelZygmax @Albertbol @lorenzorheinicke Finally found the reason: This bug was introduced by this commit here: https://github.com/flutter-mapbox-gl/maps/pull/782/files#diff-267cc6a657d6daa95a0cc73ab1d47e53fc784c4c2d7c3ff7160637d41ce8ee9c

If you revert this, it works perfectly like it should.

I cannot explain why because the way it was before it looked quite strange (calling onResume inside onPause) but somehow it is required to do exactly this. @felix-ht Maybe you can also have a short look at this due to more background knowledge.

lorenzorheinicke commented 2 years ago

@felix-mittermeier I tried the proposed change from onPause to onResume and can still reproduce the blank map issue, textureMode is not set to true.

felix-mittermeier commented 2 years ago

@felix-mittermeier I tried the proposed change from onPause to onResume and can still reproduce the blank map issue, textureMode is not set to true.

Are you 100% sure you made this change?

Bildschirmfoto 2022-06-07 um 09 42 32

used the local repository with the change and made a full reload of the app after it?

I had a case where I could constantly reproduce this grey screen issue and after this change it did not happen again so I would be quite surprised if it is different for you 🤔

lorenzorheinicke commented 2 years ago

@felix-mittermeier I tried the proposed change from onPause to onResume and can still reproduce the blank map issue, textureMode is not set to true.

Are you 100% sure you made this change? Bildschirmfoto 2022-06-07 um 09 42 32 used the local repository with the change and made a full reload of the app after it?

I had a case where I could constantly reproduce this grey screen issue and after this change it did not happen again so I would be quite surprised if it is different for you 🤔

I have re-tested this and made sure to reference the local repository with the change. I can still constantly reproduce the grey screen issue on a Nokia 6.1 Android 10 device.

Note: The textureMode is not set.

image
felix-mittermeier commented 2 years ago

@lorenzorheinicke Could you please try if it works for you if you use mapView.onStart(); inside @Override public void onResume and mapView.onPause(); inside @Override public void onPause?

Calling onResume will basically have no effect at all because it just calls the onResume of the MapRenderer, which is not implemented: Bildschirmfoto 2022-06-07 um 16 49 44

onStart has more code in it which is probably implemented in contrast.

lorenzorheinicke commented 2 years ago

@lorenzorheinicke Could you please try if it works for you if you use mapView.onStart(); inside @Override public void onResume and mapView.onPause(); inside @Override public void onPause?

Calling onResume will basically have no effect at all because it just calls the onResume of the MapRenderer, which is not implemented: Bildschirmfoto 2022-06-07 um 16 49 44

onStart has more code in it which is probably implemented in contrast.

@felix-mittermeier I've tested the map with the changes described above and still no luck. (I can still reproduce the blank map issue)

image
felix-mittermeier commented 2 years ago

@lorenzorheinicke Hmm okay, thanks for testing it. Not sure either but maybe it has something to do with the Android versions. I was using Android 12 and you 10. Platform views can differ on different OS versions so just as an idea for a possible cause 🤔

kleeb commented 2 years ago

its fully reproducable on Android 11

irjayjay commented 2 years ago

Not sure if related. I get a blank map after the container the map is in resizes, causing the map to redraw. Happens only on Android 12 so far.

I have to make the map resize a few times, then it happens.

Here's a clue for debugging though: Right after I get it to go blank, I get spammed with these logs: E/BufferQueueProducer(12931): [SurfaceTexture-0-12931-66](id:328300000089,api:0,p:-1,c:12931) dequeueBuffer: BufferQueue has no connected producer

These never spam before reproducing the blank screen, only after. Hoping this helps someone debug.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ranjithbobby89 commented 1 year ago

Please reopen this. The issue was still reproducing any fix for this?

steveneal commented 1 year ago

Can this be reopened please? We have problems with a producation app and this seems a likely cause.