Skip to content

Style source reload error on browser tab change #2926

Description

@twelch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions