Commit 34c00ad
authored
fix(processing): let Whitebox Dissolve take a grouping field (#1997)
* fix(processing): let Whitebox Dissolve take a grouping field
The Dissolve dialog rendered its `dissolve_field` parameter as a second
layer picker with a file-path box, so the attribute to dissolve by could
not be entered at all. The parameter kind came from geolibre-wasm's
manifest, which inferred a parameter's type from its description -- and a
column parameter's description describes the data it *indexes*, not the
value the user types. "Optional attribute field used to dissolve polygons
within groups" read as a polygon layer to open.
Bump geolibre-wasm to 1.5.2, which carries three upstream fixes:
- opengeos/whitebox-wasm#19 types a `*_field`/`*_attribute` parameter as
the column name it is. 54 params across 28 tools stop asking for a file
or a checkbox, so the dialog's attribute picker (GeoLibre#1459) now
reaches them: Dissolve, join_tables, merge_table_with_csv, the route
event family, and every network tool's `one_way_field`.
- opengeos/whitebox-wasm#20 makes `dissolve` emit one feature per group.
Parts of a group that shared a value but no boundary were separate
features, so 290 polygons over 12 values dissolved to 48, not 12.
- opengeos/whitebox-wasm#21 decodes GeoJSON/TopoJSON strings as UTF-8.
Both parsers read each byte as a Latin-1 code point and re-encoded it,
so a non-ASCII attribute gained a layer of mojibake on every pass
through a tool.
Also correct two comments that cited `join_tables.primary_key_field` as a
field-named parameter that is legitimately a dataset input. It was one of
the 40 the manifest mistyped, and it is a string now; the sidecar
catalog's `classify_objects_svm.class_field` is a live example, so the
scalar-string guard those comments explain still earns its place.
Fixes #1977
* fix(processing): run Whitebox WASM tools off the main thread
The WASI runner is a single synchronous `wasi.start()` with no yield
points, so running it on the main thread freezes the whole UI -- no
repaint, no input -- for as long as the tool takes. Dissolving the
290-polygon layer from #1977 takes ~60s, and a stall probe measured
58,573 ms without a single animation frame: the app looks hung.
wasm-convert.ts already routed its tiling calls to a one-shot Worker for
exactly this reason, and its worker script is generic. Lift that
machinery into `wasm-tool-runner.ts`, rename the script to
`wasm-tool.worker.ts` now that it serves both callers, and route
`runWhiteboxToolWasm` through it. One implementation, so the two paths
cannot drift.
This freeze predates the dissolve fix -- every WASM tool blocked the main
thread -- but a long-running Dissolve was unreachable until the grouping
field became typeable, so it surfaces there first.
Measured on the same run: max main-thread stall drops from 58,573 ms to
756 ms, and the output is unchanged at 12 features.
* Address Claude review feedback
- reuse WASM tool workers instead of discarding each after one run. A worker
compiles the ~23 MB geolibre-cli.wasm in its own module scope, and the main
thread's copy is not shared with it, so one worker per run made every run pay
that again. Invisible next to a minutes-long tiling job, the only caller
before this PR, but not next to the many Whitebox tools that finish in well
under a second. An idle worker is taken when there is one and a new one
spawned otherwise, so concurrent runs still overlap rather than serializing
behind a single shared worker; a worker that fails at the worker level is
terminated rather than parked, and listeners are removed so a reused worker
does not accumulate them. Adds `releaseIdleWasmToolWorkers()` to free the
warm workers, which test teardown needs so a parked worker is not handed to
the next case.
- fix the stale `wasm-convert.worker.ts` reference in the afterEach comment
left by this PR's rename.
* Address Claude review feedback
- guard reuse of a parked worker with an acknowledgement. A worker killed
out of band fires no `error` event and silently swallows `postMessage`, and
this module deliberately puts no timeout on the run itself, so reusing one
that died while idle would have left the run pending forever with nothing
shown to the user. The worker now acks on receipt, before starting the run
that blocks its thread; a reused worker that does not ack within 10s is
terminated, replaced, and the request re-sent. Only reused workers are
watched — a freshly spawned one has not had time to die, reports itself
through `error`, and its module-graph startup can outlast any sensible ack
window in a dev server. A false positive costs a respawn, never a failed run.1 parent b4b1c17 commit 34c00ad
10 files changed
Lines changed: 350 additions & 116 deletions
File tree
- apps/geolibre-desktop/src
- components/processing
- lib
- packages/processing
- src
- tests
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
654 | | - | |
655 | 655 | | |
656 | 656 | | |
657 | 657 | | |
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
773 | | - | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
774 | 781 | | |
775 | 782 | | |
776 | 783 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 62 | | |
118 | 63 | | |
119 | 64 | | |
| |||
295 | 240 | | |
296 | 241 | | |
297 | 242 | | |
298 | | - | |
| 243 | + | |
299 | 244 | | |
300 | 245 | | |
301 | 246 | | |
| |||
322 | 267 | | |
323 | 268 | | |
324 | 269 | | |
325 | | - | |
| 270 | + | |
326 | 271 | | |
327 | 272 | | |
328 | 273 | | |
| |||
This file was deleted.
0 commit comments