Skip to content

Debounce the settings-file write when zooming the edit page (BL-16763) - #8239

Open
hatton wants to merge 4 commits into
Version6.5from
BL-16763-debounce-save-settings-on-zoom
Open

Debounce the settings-file write when zooming the edit page (BL-16763)#8239
hatton wants to merge 4 commits into
Version6.5from
BL-16763-debounce-save-settings-on-zoom

Conversation

@hatton

@hatton hatton commented Aug 26, 2026

Copy link
Copy Markdown
Member

Problem

While the user zooms the edit page with Ctrl+mousewheel, Bloom writes the whole user.config
settings 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.SetZoom no longer writes the settings file. It still applies the zoom to the browser
at once, and it still updates Settings.Default.PageZoom in memory at once, so nothing the user
sees 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 Reviewable

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>
@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR debounces persistence of Edit-page zoom changes while applying each zoom immediately in memory and in the browser.

  • Adds a two-second WinForms timer that coalesces successive zoom changes into one settings-file write.
  • Flushes a pending zoom setting when leaving Edit, deactivating the main window, or disposing the view.
  • Documents a recurring isolated-build tooling issue in PAPERCUTS.md.

Important Files Changed

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

hatton and others added 2 commits August 26, 2026 15:01
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>
@hatton

hatton commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

[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>
@hatton

hatton commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

[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.

@hatton
hatton marked this pull request as ready for review August 26, 2026 21:38
@andrew-polk
andrew-polk changed the base branch from master to Version6.5 August 26, 2026 22:00
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