Skip to content

[Feature]: Read a COG window (layer.addUrl {"bbox"}) off the frame in the app, and from plugins #1330

Closed

Description

@elpidioassinaturas

Before you start

  • I searched the existing issues and the roadmap and did not find a duplicate request.

What problem does this solve?

#1210 (for #1204) reads a window of a cloud-optimised GeoTIFF as a raster layer: layer.addUrl with "bbox". The read blocks where the command runs. It waits up to two minutes for the header, then up to two minutes for each band, and no band is started after five minutes. On the command line and in scripts that is what a caller expects.

In the desktop app, the command palette's layer.addUrl runs as ui.addUrl. Its probe runs off the frame. poll_data_downloads then runs layer.addUrl with the caller's parameters on the frame, so the window read holds the UI while it waits. On a slow server or a large window, that can be minutes. A plugin's command (leave_downloads) can't take that wait at all, so #1210 refuses "bbox" there with a message. That leaves out BrasilData's MapBiomas windows, the case #1204 was opened for.

Proposed solution

Split the window read from adding the layer, so the slow part can run on a worker and the layer is added on the frame when it lands. That is how ui.addUrl already handles a whole download.

  1. Engine: add_cog_window becomes two steps:
    • read_cog_window(url, params) -> Result<Window, String>: the box, the level, the header and the bands' values, with the notices to say and no Session. It can run on any thread, since everything in it already calls blocking rustgis_tiles::cog functions.
    • add_window(s, Window): builds the raster, keeps it in the project and says the notices, as the command does now.
      layer.addUrl {"bbox"} on the command line runs both in turn, as today.
  2. App: ui.addUrl with "bbox" starts read_cog_window on a worker, beside the probe it starts now (cog_probes). It shows the read as running, the way a download shows, and poll_data_downloads calls add_window when the result lands. An error is said there too.
  3. Plugins: with leave_downloads, layer.addUrl {"bbox"} goes to the same queue (request_url) instead of being refused, and the plugin command runs again when it lands, once [Feature]: A plugin command that downloads a layer runs again when it lands, so it can go on with it (clip, rename, style) in the web app and, after #1170, on the desktop #1202 is in.

Choices in this proposal

  • Split the command, not a thread inside it. Session stays on the frame. Only the read, which needs no session, moves.
  • The same limits as now. The value and band caps and the five-minute overall wait still apply on the worker, so a hostile or huge file can't keep a worker forever.
  • Cancelling a running window read: a follow-up. The first step only stops it from holding the UI.

Estimated scope

  • crates/engine/src/cmd/layer.rs: the split, and the plugin path no longer refused.
  • crates/ui-egui/src/lib.rs: the queue entry and its landing.
  • Tests: the engine's window tests run on the split as they are. A UI test checks that the frame isn't held: a slow test server, the frame keeps drawing, and the layer is added once the read lands.

Alternatives considered

  • Refusing "bbox" in ui.addUrl. It would leave windows to scripts and the command line only, and the command palette maps layer.addUrl to ui.addUrl.
  • Running the whole command on a worker with a cloned Session. The clone would be heavy, and two sessions would have to be merged when it lands.

🤖 Generated with Claude Code

Activity

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

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