Skip to content

fix(windows): prevent working set trimming and reduce default log level#192

Open
richardpowellus wants to merge 3 commits intoOpenBubbles:rustpushfrom
richardpowellus:fix/windows-perf-working-set-trimming
Open

fix(windows): prevent working set trimming and reduce default log level#192
richardpowellus wants to merge 3 commits intoOpenBubbles:rustpushfrom
richardpowellus:fix/windows-perf-working-set-trimming

Conversation

@richardpowellus
Copy link
Copy Markdown

Summary

Fixes severe input lag (~15 seconds) on Windows when the app regains focus after being in the background. Also reduces excessive disk I/O from keystroke logging on desktop.

Closes #191

Problem

On Windows, the ~400-500MB working set gets paged out when the app loses focus. When focus returns, the OS spends 10-15 seconds faulting all those pages back into RAM before the app becomes responsive. This happens even on high-end hardware (tested on RTX 3080 Ti, 64GB RAM, NVMe SSD).

Additionally, the default logLevel is INFO, which logs every single keystroke and text prediction annotation to disk. Typing a single word produces 8+ log entries. This generates tens of MB of log I/O per session, adding constant disk pressure.

Changes

windows/runner/main.cpp

  • Call SetProcessWorkingSetSizeEx() at startup with a 256 MB hard minimum floor (QUOTA_LIMITS_HARDWS_MIN_ENABLE). This prevents Windows from trimming the working set when the app loses focus, eliminating the 10-15 second input lag on focus regain.
  • Set process priority to ABOVE_NORMAL_PRIORITY_CLASS to reduce scheduling latency for the UI thread.

lib/database/global/settings.dart

  • Default logLevel to Level.warning on desktop platforms (Windows, Linux, macOS). Mobile continues to default to Level.info. Users can still change this in Settings > Troubleshooting.
  • Updated both settings restoration paths to use the platform-appropriate default.

Testing

Tested on Windows 11 with:

  • 4K display (3840x2160)
  • NVIDIA RTX 3080 Ti
  • 64GB RAM
  • NVMe SSD

Before fix: 10-15 seconds of input lag every time the window regains focus.
After fix: Immediate responsiveness on focus regain, no perceptible lag.

On Windows, the ~400-500MB working set gets paged out when the app loses
focus. When focus returns, the OS spends 10-15 seconds faulting pages back
into RAM, causing severe input lag. This happens even on high-end hardware.

Fixes:
- Call SetProcessWorkingSetSizeEx() at startup with a 256MB hard minimum
  floor to prevent Windows from trimming the working set on focus loss
- Set process priority to ABOVE_NORMAL to reduce scheduling latency
- Default logLevel to WARNING on desktop platforms (was INFO, which logs
  every keystroke and text prediction annotation, generating tens of MB
  of log I/O per session)

Closes OpenBubbles#191
- Upgrade freezed_annotation to ^3.0.0 (from ^2.4.1)
- Upgrade freezed to ^3.1.0 (from ^2.4.1)
- Remove build_verify (incompatible with Flutter 3.41 test_api)
- Update material_color_utilities override to ^0.12.0
- Add dependency overrides for pointycastle, source_gen, dart_style
  to resolve freezed 3.x vs objectbox_generator conflicts
@richardpowellus richardpowellus force-pushed the fix/windows-perf-working-set-trimming branch from aa1a72d to 2383248 Compare March 30, 2026 21:08
- Updated skeletonizer ^1.4.3 -> ^2.1.3 (Flutter 3.41 Canvas compat)
- Updated google_fonts ^6.2.2 -> ^8.0.2 (Dart 3.11 compat)
- Updated pubspec.lock and generated plugin registrants
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.

Windows: Severe input lag (~15s) after window regains focus due to working set trimming

1 participant