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

Clarify, rename or remove map.loaded() method #5052

Closed
gpbmike opened this issue Jul 26, 2017 · 6 comments
Closed

Clarify, rename or remove map.loaded() method #5052

gpbmike opened this issue Jul 26, 2017 · 6 comments

Comments

@gpbmike
Copy link
Contributor

gpbmike commented Jul 26, 2017

mapbox-gl-js version: 39.1

Steps to Trigger Behavior

Add a canvas source / layer to the map.

Expected Behavior

map.loaded() eventually returns true.

Actual Behavior

map.loaded() never returns true.

Additional Details

I have created a codepen to demonstrate.

https://codepen.io/gpbmike/pen/NvqaZm

We're using map.loaded() to determine when certain actions can be performed that require the map to be loaded, see mapbox-gl-draw. We noticed that if you add a canvas source to the map, the map.loaded() will never change to true.

@mollymerp mollymerp changed the title Adding canvas source causes map.loaded() to return false indefinitely Adding canvas source causes infinite render loop Jul 26, 2017
@mollymerp
Copy link
Contributor

mollymerp commented Jul 26, 2017

Thanks for the report @gpbmike
I have confirmed that this is a bug, and map.loaded() isn't returning true because the source kicks off an infinite render loop.

Whoops! I spoke too soon. I didn't realize that CanvasSource defaults to animate=true. You can fix your example by adding animate = false (https://codepen.io/anon/pen/Evjbmv) but I do think we should figure out a way to check if animated sources are loaded 💭

@mollymerp mollymerp changed the title Adding canvas source causes infinite render loop Adding canvas source causes map.loaded() to return false indefinitely Jul 26, 2017
@lbud
Copy link
Contributor

lbud commented Jul 26, 2017

Oo 🕵️‍♀️ @mollymerp I would guess this applies to video sources too, then.

@gpbmike
Copy link
Contributor Author

gpbmike commented Jul 26, 2017

Also what's the difference between map.loaded() and map.isStyleLoaded()?

@mollymerp
Copy link
Contributor

@gpbmike map.loaded() checks that there are no pending source, tile, or style loads or updates and that the animation loop (triggered by any user interaction or programmatic map change) has finished. Because the animation loop never stops with animated canvas sources and video sources, that is blocking map.loaded() from returning true.

@mourner mourner changed the title Adding canvas source causes map.loaded() to return false indefinitely Clarify, rename or remove map.loaded() method Jul 25, 2018
@mourner
Copy link
Member

mourner commented Jul 25, 2018

This seems to be more of an API naming/documentation issue that an actual bug, so I renamed/labeled it accordingly.

@mourner
Copy link
Member

mourner commented Jul 25, 2018

Closing in favor of #6708 to centralize the discussion there.

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

No branches or pull requests

4 participants