Debounce the settings-file write when zooming the edit page (BL-16763) - #8239
Debounce the settings-file write when zooming the edit page (BL-16763)#8239hatton wants to merge 4 commits into
Conversation
EditingView.SetZoom wrote the whole user.config to disk on every zoom change. A Ctrl+mousewheel spin changes the zoom many times a second, so that was many synchronous disk writes on the UI thread, each one holding that thread while the browser process was trying to call into it. That widens the window for the WebView2 accelerator-key collision that can freeze Bloom for minutes (BL-16762). The zoom still reaches the browser immediately, and Settings.Default.PageZoom still changes immediately. Only the write to disk is deferred: a timer writes the file one second after the zoom stops changing. We also write it at once if the user leaves the Edit tab, if the main window goes inactive, or when the view is disposed, so a zoom made in the last second is not lost. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| src/BloomExe/Edit/EditingView.cs | Replaces per-step zoom persistence with a debounced timer and lifecycle flush points; no follow-up-eligible issue was established. |
| PAPERCUTS.md | Adds a historical note about a recurring build-copy collision during preflight. |
Reviews (2): Last reviewed commit: "Wait two seconds, not one, before writin..." | Re-trigger Greptile
The comment that follows warns against a save during Deactivate. That warning is about the model save, which runs Javascript. This one only serializes the in-memory settings, so record the difference for the next reader. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…763) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
[Claude Opus 5 from Hatton's machine during preflight] Consulted Devin on 2026-08-26 21:20 UTC up to commit cb70423. It reported no bugs and no Investigate flags. It raised two Informational items, both of which it judged low risk itself: that a zoom made in the last second before an abrupt kill is lost (a deliberate trade-off, and the write is flushed on tab change, deactivate, and dispose), and that the flush on window-deactivate sits next to the BL-6299 warning (that warning is about the model save, which runs Javascript; this one only serializes the settings). The second item is now answered by a code comment. Nothing was mirrored to the PR, because Informational items are not posted. |
Every ordinary way of leaving the Edit tab flushes the pending write, so a longer wait costs nothing in practice and batches more of a slow, deliberate zoom with the buttons into one write. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
[Claude Opus 5 from Hatton's machine during preflight] Consulted Devin on 2026-08-26 21:45 UTC up to commit 26a41fc (the delay raised to two seconds). No bugs and no Investigate flags. Three Informational items, all judged low risk: the debounce timer stays on the UI thread, a pending zoom is lost on a hard crash (the deliberate trade-off), and the flush on window-deactivate sits next to the BL-6299 warning, which is about the model save and its Javascript. Nothing mirrored to the PR, because Informational items are not posted. |
Problem
While the user zooms the edit page with Ctrl+mousewheel, Bloom writes the whole
user.configsettings file to disk on every zoom step. A fast wheel spin produces many of those synchronous
writes per second, all on the UI thread. This is not the root cause of the multi-minute freeze in
BL-16762, but each write holds the UI thread longer, which widens the window in which the
host-to-browser and browser-to-host calls collide.
Fix
EditingView.SetZoomno longer writes the settings file. It still applies the zoom to the browserat once, and it still updates
Settings.Default.PageZoomin memory at once, so nothing the usersees changes. A two-second timer now does the disk write, and each zoom step restarts that timer,
so a whole wheel spin costs one write instead of one write per notch.
The pending write is also flushed at once when the user leaves the Edit tab, when the main window
becomes inactive, and when the view is disposed. So a zoom made in the last two seconds before any of
those events is still saved.
Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16763
Devin review
This change is