Skip to content

Feature Request: Cancel in-flight tile requests when view changes #296

@TomBeckett

Description

@TomBeckett

Problem

When the map view changes rapidly (via zoom or pan), Galileo continues processing tile requests for tiles that are no longer visible. This causes:

  1. Request queue flooding - Rapid zoom operations queue many tile requests that become stale immediately
  2. Wasted resources - CPU/network cycles spent loading tiles that won't be displayed
  3. Delayed visible tiles - Currently-visible tiles wait behind stale requests in the queue

Current Behavior

Once a tile is requested through VectorTileProvider / ThreadVtProcessor, the request runs to completion even if the tile is no longer in the viewport. There's no mechanism to cancel or deprioritize stale requests.

Workaround

We've had to reduce zoom speed significantly to prevent queue backup:

// Reduced zoom speed (0.02) to prevent tile request queue flooding
// when zooming rapidly - Galileo doesn't cancel stale tile requests
let controller_config = MapControllerConfiguration::default().with_zoom_speed(0.02);

This trades off user experience (sluggish zoom) for stability.

Proposed Solution

Add support for request cancellation, potentially via:

  1. Cancellation tokens - Pass a token to VectorTileLoader::load() that can signal cancellation
  2. Request priority/invalidation - Allow marking requests as stale so the processor can skip them
  3. View-change callback - Notify the tile provider when the view changes so it can clear pending requests

Example API sketch:

// Option 1: Cancellation token
async fn load(&self, index: TileIndex, cancel: CancellationToken) -> Result<...>

// Option 2: Request handle that can be cancelled
let handle = provider.request_tile(index);
handle.cancel(); // Called when view changes

Use Case

We're building an embedded map application on Raspberry Pi where resources are constrained. The inability to cancel stale requests causes noticeable lag during navigation and zoom operations, especially when loading from network sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions