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

Style source reload error on browser tab change #2926

Closed
twelch opened this Issue Aug 2, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@twelch
Contributor

twelch commented Aug 2, 2016

Observed with version 0.21.0 or latest master

I have a web socket streaming in events multiple per second. Each event is added to the map as a point icon for 2 seconds using its own source and layer. All is good until I change browser tabs, then I observe that the map stops re-rendering (to be efficient I assume) and the style update queue starts filling. When I switch back to the map tab, the style update resumes and batch processes the queue (with all of the source adds/removes), and I get a source reload error.

I didn't have this error with version 0.15.0, prior to the refactoring of batch processing.

Example

Try out https://jsbin.com/zehuloqofu/edit?html,console,output

You should see contour sources and layers getting added and removed in quick succession. Now change tabs for at least a few seconds and then change back. Observe the console error Cannot read property 'reload' of undefined. After that the map is in a broken state and you'll need to refresh.

From what I've observed the error is due to the Style trying to reload one of the short-lived sources from Style.update, after its been removed.

I think what's happening is that the Style object isn't deleting source id's from it's internal _updates.sources list when Style.removeSource is called as is done for _updates.layers

The fix

Pull request forthcoming that I think resolves the issue. Comments welcome, thanks.

@mourner

This comment has been minimized.

Show comment
Hide comment
@mourner

mourner Aug 2, 2016

Member

Thanks! The fix looks right, merged.

Member

mourner commented Aug 2, 2016

Thanks! The fix looks right, merged.

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