Repository navigation
Description
Before you start
- I searched the existing issues and the roadmap and did not find a duplicate request. Related: [Bug]: A plugin's layer.addUrl freezes the desktop window and reads only the first page of an ArcGIS query #1144 and fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170 (a plugin's
layer.addUrlleft to the app), and thehost.fetchretries inplugin_fetch.rs.
What problem does this solve?
A plugin command can't download a service's features and then work on them in one call in the web app. After #1170 the same holds on the desktop for layer.addUrl.
The case: a data-catalogue plugin (Brazilian public data by theme, for the user's area). One click should bring the features that cross the area, clip them to the area's polygon (gp.run clip) and rename the result. On the desktop service.add {bbox} does the download and the plugin goes on. In the web app, from a command:
service.addrefuses: "in the web app, use Home › Add › Add Data › From Service" without the capabilities (fetch_capabilities,crates/engine/src/cmd/service.rs:190), and "…From Service downloads the features" with them (service.rs:544).host.fetchcan't carry a layer:- answers are at most 2 MiB (
plugin_fetch::MAX_BYTES), and the geology of one municipality (Teresina, IBGE BDiA WFS, 110 polygons) is 3.9 MB; - paging it is possible (8 pending fetches a call, 64 in all), but the command then holds the GeoJSON itself, and its budget (
COMMAND_FUEL, 500 million) runs out building a 4 MB collection: "it ran too long and was stopped".
- answers are at most 2 MiB (
layer.addUrlanswers{"pending": true}and the layer lands later, but nothing tells the plugin. The command has already returned, so the clip needs a second click, and the plugin has to tell the user to click again.
#1170 takes layer.addUrl off the frame on the desktop the same way, so after it a desktop plugin using layer.addUrl has the same gap. That is the right change for the window; this issue is about letting the command finish its work afterwards.
Proposed solution
Run the command again when what it left to the app has landed, as RustGIS already does for host.fetch:
- A command whose
layer.addUrl(orservice.add, see 3) left a download answers{"pending": true}. The bridge undoes what the call did to the project, as it does for a pending fetch. - When the download lands, RustGIS runs the command again with the same parameters (
Session::poll_plugin_retries). In that run the samelayer.addUrlcall adds the landed layer at once and answers what it added ({"layer", "features"}). The command then clips, renames or styles it, and all of it is one undo step. - In the web app,
service.addfrom a command leaves its requests to the front end the same way (the capabilities, then the features, as the From Service dialog fetches them), instead of refusing. It then answers as on the desktop in the run after they land.
Choices in this proposal
- The same rerun as
host.fetch, not a callback command. Plugins already handlependingand reruns, and the docs already describe them. A callback ("on layer landed") would need a new manifest field and state the plugin can't keep. - The landed download is kept for the rerun only. It is kept by its address and parameters, as
host.fetchkeeps answers, and dropped once the rerun has taken it (or after thehost.fetchtime to live). So a layer isn't added twice, and memory isn't held. - Scripts,
gp.runandrustgis-clidon't change. They keep waiting for the layer, as fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170 keeps them. - The limits stay those of fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170 and
host.fetch: 16 downloads, 8 pending, a bounded number of reruns. A plugin that needs more says so.
Estimated scope
Medium. Most of it exists already: request_url / take_url_requests (#1170), the pending-and-rerun loop of host.fetch, and the From Service dialog's off-frame download of capabilities and features. The new part is keeping the landed layer by request until the command runs again, and service.add's web path.
Alternatives considered
- Two clicks (what the plugin does now in the web app): the first downloads, the second finds the layer "(sem recorte)" and clips it. It works, but the user has to be told to click again, and a failed download (a 502 without CORS headers, which the browser reports as a CORS error) only shows as the app's error.
- Raising the
host.fetchcap and the command budget: this moves the limit rather than removing it, and it keeps layers' GeoJSON inside the plugin. - A tool instead of a command (
TOOL_FUELis 30 billion): tools make no host requests, so a tool can't fetch.
Activity
fix(plugins): a command giving up names the downloads it leaves (open…
fix(plugins): a refused landing's error hides its address's keys (ope…
fix(plugins): a waiting command's answer hides its addresses' keys (o…
fix(plugins): a refused download with a key in its address is said on…
fix(plugins): a download given up after the wait is said, with its ad…
fix(plugins): clicks made while a command runs again are dropped too (o…
fix(plugins): downloads given up together are said in one notice (ope…
fix(plugins): a failed download answers the command waiting for it at…
fix(plugins): a command run again doesn't repeat the errors it said (o…
fix(plugins): a refused download's parsed read goes with it (opengeos…
fix(plugins): a download added to a deleted map doesn't ask to show it (
fix(plugins): a download whose layer was taken away is made again (op…
fix(plugins): a failed ui.addUrl the app runs is said once (opengeos#…
fix(plugins): a download whose table was taken away is made again too (…
feat(plugins): a plugin command whose `layer.addUrl` left a download …
Merge remote-tracking branch 'origin/main' into fix/mbtiles-windows-lock
feat(plugins): a plugin command's `layer.addUrl` with "bbox" goes to …