Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed race condition with map#waitForMap #808

Merged
merged 1 commit into from Dec 10, 2021

Conversation

felix-ht
Copy link
Collaborator

@felix-ht felix-ht commented Dec 8, 2021

Multiple attempts have been made to fix the the issue that sometimes on iOS onStyleLoaded has does not fire. #775
However the error still seems to show up for some users - albeit very rarely.

With this PR im pretty confident to truly fix the issue.
The root cause seems to be that on the native side onStyleLoaded fires before the flutter code has even setup the platform callbacks. This causes mainly two kinds of issues:

  • onMapCreated and onStyleLoaded being called out of order
  • onStyleLoaded not being called at all

To fix it i changed the implementation so that map#waitForMap calls onStyleLoaded if on the map has already finished loading the style. If map#waitForMap happens first onStyleLoaded is called in the mapView callback.

On subsequent style changes mapView always directly calls onStyleLoaded.

@AAverin it would be great if you could check this code with your test code as well - to make sure that is gone for you as well.

@felix-ht felix-ht requested a review from AAverin December 8, 2021 17:41
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN December 8, 2021 17:41 Inactive
@felix-ht felix-ht temporarily deployed to ANDROID_CI_DOWNLOADS_TOKEN December 8, 2021 17:41 Inactive
@felix-ht felix-ht added bug Something isn't working ios labels Dec 8, 2021
@AAverin
Copy link
Contributor

AAverin commented Dec 8, 2021

@felix-ht would it also help with #807?
I had to introduce 100ms delay on iOS for camera to work somewhat reliably.

@felix-ht
Copy link
Collaborator Author

felix-ht commented Dec 8, 2021

@AAverin There is a good chance thats this solves that issue that as well. Would be great if you could test!

@AAverin
Copy link
Contributor

AAverin commented Dec 8, 2021

@felix-ht Yes, I will try to test tomorrow against my codebase. Android was quite stable, but there were many issues on iOS

@AAverin
Copy link
Contributor

AAverin commented Dec 9, 2021

@felix-ht Doesn't help with the animation issue I had, will do some more tests

@AAverin
Copy link
Contributor

AAverin commented Dec 9, 2021

@felix-ht After all the fixes I did before onStyleLoaded is invoked quite stable for me, maybe I am just not catching some edge case. The only big issue I have is that calling camera with animation inside onStyleLoaded doesn't work.
This issue is not resolved with this PR and the only workaround that worked for me is to add 100ms delay before calling any methods on the controller.
This is probably related to some native implementation because on Android everything works fine without delays.

If you say that this PR resolves some minor edge case, let's merge it.

@felix-ht felix-ht merged commit c970a0d into master Dec 10, 2021
m0nac0 added a commit to maplibre/flutter-maplibre-gl that referenced this pull request May 19, 2022
https: //github.com/flutter-mapbox-gl/maps/pull/808
Co-Authored-By: Felix Horvat <24698503+felix-ht@users.noreply.github.com>
m0nac0 added a commit to maplibre/flutter-maplibre-gl that referenced this pull request May 20, 2022
* Cherry-pick upstream#808

https: //github.com/flutter-mapbox-gl/maps/pull/808
Co-Authored-By: Felix Horvat <24698503+felix-ht@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants