Skip to content

Ariadne file-pick: a hidden tab's upload keeps its pace; the system dialog's title and folder - #1274

Merged
transfix merged 1 commit into
masterfrom
fix/file-pick-gaps
Nov 16, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/file-pick-gaps

Conversation

@transfix

Copy link
Copy Markdown
Owner

Three gaps in #1190's file picker, found by trying it by hand on Windows and in Chrome.

A hidden tab's upload crawled

A browser page's picks and reads polled a timer (4 ms for a read, 50 ms for a pick) until the page had answered. A hidden tab runs timers about once a second (once a minute after five minutes hidden), so an upload in a background tab went a chunk or two a second.

Now the page calls back (cvc_files_settled, an EMSCRIPTEN_KEEPALIVE export, as browser_runtime.cpp does) from the browser's own events: the input's change/cancel and the slice's promise. An answer the page already has comes from a microtask, after the C++ call returns. A read settles exactly once, even if the copy into the heap throws (before, that would have hung). A pool thread's read in wasm-mt still waits as before (no page timer is involved).

Chrome 157, 1 KiB chunks, page hidden (minimized) right after the pick:

file before after
70,000 B 35 s 0.8 s
1 MiB (~8 min at the old rate) 12.2 s

The bytes matched each file's sha256, and the program reported the result once the page was shown again.

The system dialog ignored title, and dir opened the wrong folder

arigl now calls SDL_ShowFileDialogWithProperties (SDL ≥ 3.2; deps have 3.4.12), so title reaches the dialog. Without a title it keeps the system's own, in the user's language.

dir now gets a trailing separator: SDL took C:\...\pick-test as a file, and Windows opened C:\... with "pick-test" typed into the file-name box.

Docs

ARIADNE.md §10.8 says what title and dir do in each picker: the composed window's defaults, the system dialog's, and a browser's (no title, its own folder). With no dir, the system dialog starts where the system chooses (usually the folder last used), not in the working folder as the docs said.

Verified on Windows

  • arigl dialog:
    • The title bar reads "Attach a file".
    • With no title it reads "Open".
    • dir opens inside the folder, with the filter showing only .bin/.txt.
    • A pick uploads 70,000 B byte-exact.
    • Cancel gives an empty list.
  • Chrome 157:
    • A trusted click on Attach opens Chrome's own Open dialog (user activation was active).
    • Pick and cancel both work.
    • The hidden-tab timings are in the table above.
  • Tests:
    • arigl_web_smoke.mjs against the new single-threaded build: 6/6.
    • ariadne_files_test: 15/15.
    • clang-format (18.1.8) is clean.

Not verified here

  • The wasm-mt build: CI's ariglx-web (wasm-mt) runs the same smoke file.
  • The macOS and Linux dialogs (SDL's portal/zenity) with a title.
  • Firefox and Safari.

…ialog's title and folder

Found by trying the file picker by hand after #1190.

A browser page's picks and reads now call back from the browser's own events (the input's change
or cancel, the slice's promise) through cvc_files_settled, not from a 4 ms / 50 ms timer that
polled. A hidden tab runs timers about once a second, and once a minute after five minutes, so
an upload in a background tab went a chunk or two a second. With 1 KiB chunks in Chrome 157:
70 KB took 35 s hidden before, and now 0.8 s; 1 MiB takes 12 s hidden. A read settles once,
even when the copy into the heap throws. A pool thread's read (wasm-mt) waits as before.

arigl's system dialog goes through SDL_ShowFileDialogWithProperties, so file-pick's `title`
reaches it. Without one it keeps the system's own, in the user's language. `dir` now ends in a
separator: SDL took a folder without one for a file, and Windows opened the folder's parent
with the folder's name typed in.

ARIADNE.md 10.8 says what `title` and `dir` do in each picker. With no `dir`, the system dialog
starts where the system chooses, not in the working folder.
@transfix
transfix merged commit 591b8f4 into master Nov 16, 2026
28 checks passed
@transfix
transfix deleted the fix/file-pick-gaps branch November 16, 2026 06:36
transfix added a commit that referenced this pull request Nov 16, 2026
No conflicts; this branch touches none of its files (files.cpp, files.h, ImGuiBackend.cpp,
ARIADNE.md 10.8). ariadne_files_test passes locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant