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

[BUG] Tiles sometimes do not load until extra event #1813

Open
coogle opened this issue Jan 28, 2024 · 11 comments
Open

[BUG] Tiles sometimes do not load until extra event #1813

coogle opened this issue Jan 28, 2024 · 11 comments
Labels
bug This issue reports broken functionality or another error P: 1 (important) S: core Scoped to the core flutter_map functionality

Comments

@coogle
Copy link

coogle commented Jan 28, 2024

What is the bug?

I'm not sure what exactly to report as the bug, but I have a situation where I am using an animation to move my map programmatically using the following code. The animation works pretty well, but at the end of the animation I end up with a totally gray map until I interact with it again (e.g. slightly zoom out or move the map by dragging).

All of the other layers render except the tile layer. I'm not seeing any network traffic downloading the tiles, but that said when the map does render after manual intervention it loads instantly (so it already had the tiles).

    void _smoothMoveMapTo(Location destination, double destZoom)
    {
        final latTween = Tween<double>(
            begin: context.read<MapBloc>().mapController.center.latitude,
            end: destination.latitude
        );

        final lonTween = Tween<double>(
            begin: context.read<MapBloc>().mapController.center.longitude,
            end: destination.longitude
        );

        final zoomTween = Tween<double>(
            begin: context.read<MapBloc>().mapController.camera.zoom,
            end: destZoom
        );

        final animation = CurvedAnimation(
            parent: _animationCtl,
            curve: Curves.fastOutSlowIn
        );

        _animationCtl.addListener(() => context.read<MapBloc>()
            .mapController.move(
                Location(latTween.evaluate(animation), lonTween.evaluate(animation)),
                zoomTween.evaluate(animation)
            )
        );

        _animationCtl.forward(from: 0);
    }

How can we reproduce it?

See provided animation controller which moves a map.

Do you have a potential solution?

As a workaround, or perhaps to fix a bug in my code because I missed something, I'm trying to figure out how to trigger whatever is happening when I manually interact with the map after moving to my destination to actually redraw it. Notably, I've tried ending the animation with one last move ... including on a slight delay .. to no effect.

Platforms

Flutter Web

Severity

Minimum: Allows normal functioning

@coogle coogle added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Jan 28, 2024
@josxha
Copy link
Contributor

josxha commented Jan 28, 2024

As far as I know, the tile layer checks if tiles need to be purged or loaded when a MapEventWithMove is emitted. move, rotate and so on all trigger a child object of this event and therefore update the tiles.


I'm sorry but I'm not sure if I can reproduce your described problem with your code snipped.

However in the example app if you trigger a second animation before the first has ended, the tiles won't be loaded.
Could this be related to your described issue?

Aufzeichnung.2024-01-28.122004.mp4

You can try it out yourself on https://demo.fleaflet.dev/map_controller_animated

@josxha josxha changed the title [BUG] Animation breaks map until manual move [BUG] Animation leads to missing tiles until manual move Jan 28, 2024
@coogle
Copy link
Author

coogle commented Jan 28, 2024

That's actually exactly what I am experiencing.. but I'm not sure how I'd be calling the animation twice! Seeing as this is in the demo, does that mean there isn't really a fix available?

@josxha
Copy link
Contributor

josxha commented Jan 28, 2024

If both has the same cause it's probably the best to check in your app if any animations is going on before starting a second animation. I'm still not sure why exactly this bug occurs, my guess would be somewhere in the tile manager.

I'm sorry to say but I don't think that there will be an fix any time soon because all resources are currently on performance tweaks and gestures. However we are happy to accept pull requests if you find the time to investigate. (:

@josxha
Copy link
Contributor

josxha commented Jan 28, 2024

@coogle Btw you could try the flutter_map_animations plugin. It's written by a flutter_map maintainer. Maybe the problem doesn't occur when using it.

@coogle
Copy link
Author

coogle commented Jan 28, 2024

I'll check out the plugin, thanks for the suggestion! I agree it's def. related to the Tiles specifically because in my situation I have multiple custom layers which render just fine post-animation.. it's only the tile layers that break. If I happen to figure out what's wrong I'll throw up a PR but I'm under a gun right now so it's more likely I'll just skip the animation for now until I get some more breathing room.

@JaffaKetchup JaffaKetchup added P: 3 (low) (Default priority for feature requests) S: core Scoped to the core flutter_map functionality and removed needs triage This new bug report needs reproducing and prioritizing labels Jan 31, 2024
@JaffaKetchup
Copy link
Member

There's some similarities to #1808's broken fix. I bet if that issue is fixed (tiles not loading after prune), this issue will be fixed as well.

@shrijanRegmi
Copy link

I am using flutter_map_animations and I am having the exact same issue.

@Albert221
Copy link

Albert221 commented May 29, 2024

I have the same as in the #1813 (comment) and #1813 (comment), after I call MapController.move then I see no tiles, only after making a gesture on the map the tiles do load. Flutter 3.19.5, both iOS and Android.

My workaround as I'm also using the flutter_map_animations is using the AnimatedMapController.animateTo with zero duration.

@JaffaKetchup JaffaKetchup added P: 2 (soon™?) and removed P: 3 (low) (Default priority for feature requests) labels Aug 7, 2024
@JaffaKetchup JaffaKetchup changed the title [BUG] Animation leads to missing tiles until manual move [BUG] Tiles sometimes do not load until extra event Aug 8, 2024
@JaffaKetchup
Copy link
Member

Although this bug occurs rarely, I have assigned P1, as fixing this may help to fix a number of other bugs.

@JaffaKetchup
Copy link
Member

When #1943 is merged, this issue will still prevent proper functioning of reset.

@JaffaKetchup
Copy link
Member

#1602 should also be checked after a fix to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 1 (important) S: core Scoped to the core flutter_map functionality
Projects
Status: To do
Development

No branches or pull requests

5 participants