Skip to content

source.setUrl does not abort in-flight raster tile requests (tilejson completed) #7149

@terraputix

Description

@terraputix

maplibre-gl-js version: 5.18.0

browser: Firefox, Chromium

Summary

Calling source.setUrl(...) on a raster source does not abort in-flight raster tile requests if the tilejson request has already completed. The abort only occurs if setUrl is called before the tilejson response arrives. As a result, the map continues loading tiles from the old URL(s) after setUrl is invoked.

Steps to Trigger Behavior

  1. Add a raster source and raster layer.
  2. Wait until the tilejson request completes (so tile URLs are known) but before all raster tiles have finished loading.
  3. Call source.setUrl(newUrl).
  4. Observe that in-flight raster tiles continue to load for the previous URL(s).

Link to Demonstration

Example demonstrating this behavior using a custom protocol: https://gist.github.com/terraputix/cbc40bbf92612e9c13fd795ab1eef247

If the source is removed and re-added the inflight tile-requests are correctly aborted: https://gist.github.com/terraputix/9fa7f1b6168b61ae9187c20d49f98c39. This mitigates my problem, but avoiding visual flickering using this pattern is tedious.

Expected Behavior

Abort inflight tile requests for previous URL when setUrl is called.

Actual Behavior

Inflight requests are only aborted if setUrl is called before the tilejson is returned.

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