Skip to content

onStyleLoadedCallback not called on iOS #347

Closed

Description

@woelmer

Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale en-US)
On Master branch of plugin.

The onStyleLoadedCallback is not called in the example app. Notice if you go to 'Place Symbol' and click on add (asset image) or add (network image) it does not work. That is because these images are setup in the onStyleLoadedCallback which is not called on iOS. This works fine on Android.

Activity

  1. TimothySealy commented on Jul 1, 2020

    @TimothySealy
    Collaborator

    Hi @woelmer,

    I'm trying to reproduce this error but everything seems to work on my device. If I click on add(asset image) or add(network image) the symbols are shown with a mapbox icon or placholder image respectively. Looking at the code the onStyleLoadedCallback should be trigger:
    https://github.com/tobrun/flutter-mapbox-gl/blob/4ce26231f3250b598060063d1b8b65950694754e/ios/Classes/MapboxMapController.swift#L525-L527

    Can you verify that the onStyleLoadedCallback is not triggered by adding a breakpoint of print statement in this method:
    https://github.com/tobrun/flutter-mapbox-gl/blob/4ce26231f3250b598060063d1b8b65950694754e/example/lib/place_symbol.dart#L48-L51

  2. lj64 commented on Jul 1, 2020

    @lj64

    I experienced the same issue just yesterday in my project on ios.

    onStyleLoadedCallback fired on first entry into the page containing map.
    When I closed it and opened again, it did not fire, even though map tiles were displayed.

    On Android everything was fine.

  3. TimothySealy commented on Jul 1, 2020

    @TimothySealy
    Collaborator

    Just tested it a couple of times and it seems that the onStyleLoadedCallback is not always fired. On my device in most cases the style is loaded properly but some times it is not and then the icon images are not loaded. Will have to look deeper into this issue.

  4. woelmer commented on Jul 2, 2020

    @woelmer
    Author

    @TimothySealy The new recommendation is to add symbols in the onStyleLoadedCallback which is why I noticed it in my own project. I thought I would try out the example and noticed the same thing. I had breakpoints there that were not getting hit. I did have it successfully call the callback once if I recall, so I guess it is intermittent like you noticed.

  5. philiplindberg commented on Aug 8, 2020

    @philiplindberg
    Contributor

    Seeing the exact same thing as @woelmer - tapping on add (asset image) or add (network image) in the example app does nothing on ios because onStyleLoadedCallback is never called.

    The only time I can get onStyleLoadedCallback to be called on ios is after reinstalling the app. When the map is generated for the very first time, onStyleLoadedCallback does get called on both ios and android, but every time after that, onStyleLoadedCallback is only called on android.

  6. m0nac0 commented on Aug 9, 2020

    @m0nac0
    Collaborator

    @woelmer @philiplindberg If you previously added your annotations before onStyleLoadedCallback was fired and that worked for you, you can continue to do this as a workaround. The new documentation wasn't added because we changed any behavior. Adding annotations in onStyleLoadedCallback was always recommended (just less visibly).

  7. tonnyavery commented on Sep 5, 2020

    @tonnyavery
    Contributor

    I can confirm the issue. Have not been testing on iOS for some time, so not sure when it started happening exactly.
    I have updated to 0.8.0 release and also upgraded Flutter to latest available.
    Android seems to work fine, on iOS onStyleLoaded is not invoked when map shows.
    If I manually (via setState) change map style, callback is invoked, but I do get a crash almost instantly after that. Not sure it's related.

  8. edufpin commented on Sep 8, 2020

    @edufpin

    Happening with me too, my workaround is check OS and if iOS do it manually after onMapCreated.

  9. tonnyavery commented on Oct 25, 2020

    @tonnyavery
    Contributor

    Issue is still present on latest master, after the supposed fix was merged. @andrea689 Was the issue fixed in your tests?

  10. tonnyavery commented on Oct 25, 2020

    @tonnyavery
    Contributor

    Ok, this was an issue on my side, didn't update properly. Seems to be more stable now, I'll keep testing

  11. tonnyavery commented on Oct 25, 2020

    @tonnyavery
    Contributor

    This is still completely unstable for me.
    Sometimes callback is called, but most of the times it isn't

  12. tonnyavery commented on Oct 25, 2020

    @tonnyavery
    Contributor

    @tobrun We should reopen it. Style callback is not invoked, but looks like it's not in Flutter, it's not properly called from the native part.
    I would assume that this should be long fixed in iOS Mapbox, so we should update to the latest and overall somehow keep dependencies up to date for this project.
    #413

  13. tonnyavery commented on Oct 25, 2020

    @tonnyavery
    Contributor

    This callback in controller.dart never gets invoked for me

     MapboxGlPlatform.getInstance(_id).onMapStyleLoadedPlatform.add((_) {
          if (onStyleLoadedCallback != null) {
            onStyleLoadedCallback();
          }
        });
    
  14. reopened this on Oct 26, 2020
  15. 12 remaining items

  16. keehoo commented on Feb 19, 2021

    @keehoo

    So far for me the issue only seems to reproduce on debug builds. Release builds seem to be fine, at least no users have complained yet.

    @aaverin I was able to reproduce this on both release & debug (iOS)... I'm also not sure whether I saw this happening on Android, will check more and get back here if find anything.

  17. tonnyavery commented on Feb 19, 2021

    @tonnyavery
    Contributor

    Debugging this issue, it seemed as native methods inside Mapbox SDK were not called.
    Because flutter-mapbox uses some old versions of Mapbox SDK I have created #413

  18. jgrandchavin commented on May 24, 2021

    @jgrandchavin

    I have exactly the same problem on iOS, still any solution found ?

  19. Sar777 commented on Jun 30, 2021

    @Sar777

    any news?

  20. pdcolandrea commented on Aug 26, 2021

    @pdcolandrea

    still an issue on 0.12.0, only happening on ios I believe

  21. tonnyavery commented on Sep 5, 2021

    @tonnyavery
    Contributor

    I can also confirm this happening in production builds on real devices.
    OnStyleLoaded callback is completely inconsistent on iOS

  22. tonnyavery commented on Sep 11, 2021

    @tonnyavery
    Contributor

    Some debugging results.
    map#onStyleLoaded gets called before map#waitForMap, which means that _handleMethodCall in dart is not yet attached correctly and onStyleLoaded invocation will not reach dart codebase.
    This results in the bug we have here.

  23. tonnyavery commented on Sep 11, 2021

    @tonnyavery
    Contributor

    Opened a PR with a fix

  24. samderlust commented on Jan 5, 2022

    @samderlust
    Contributor

    I still have this issue with Mapbox 0.14.0?

  25. tonnyavery commented on Jan 6, 2022

    @tonnyavery
    Contributor

    @samderlust In that case we would need your help debugging the issue.
    Last fixes for for onStyleLoaded callback reliability were applied in this PR: #808
    If you can reliably reproduce the problem can you try debugging your app to see what is the cause exactly?

  26. samderlust commented on Jan 13, 2022

    @samderlust
    Contributor

    @aaverin thanks, it fixed with mater branch

  27. stale commented on Mar 14, 2022

    @stale

    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.

  28. kaspesi commented on Nov 21, 2024

    @kaspesi

    Im seeing this in mapbox maps 11.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions