Registry Mirror
Skip to content

Conversation

@nschimme

@nschimme nschimme commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Asyncify instruments every function that might sit on the stack during a
nested event loop, which roughly doubles mmapper.wasm (37 MB -> 22 MB
without it) and, with it, the browser's compiled-code footprint -- the
part that pushes an iPad tab over its memory limit. Without Asyncify a
nested QEventLoop::exec() on wasm aborts, so every blocking call that is
reachable there is converted:

  • QMessageBox::information/warning/critical statics -> mmqt::showInformation/
    showWarning/showCritical (window_utils): a heap box with
    WA_DeleteOnClose shown with open().
  • QMenu::exec() in the adventure, tasks and timer panels ->
    mmqt::popupMenu(): takes ownership of the menu and popup()s it.
  • MainWindow::maybeSave() takes a continuation (File > New/Open/Reload);
    closeEvent() keeps a blocking maybeSaveBlocking() on desktop, since it
    cannot be deferred, and on wasm the browser owns the tab's lifetime.
  • RemoteEditWidget's discard prompt is shown with open(); the close is
    retried from slot_cancelEdit() when the user discards.
  • ShaderUtils' "Message from OpenGL" box is non-blocking on wasm only.

Left as they are because they are not reachable on wasm: the desktop-only
QFileDialog::get* calls, main()'s fatal-GL box (the wasm prober never
fails), the QOpenGLDebugLogger abort path (no KHR_debug on WebGL), and
the busy-waits in AsyncTasks' destructor, TcpSocket and OpenGLProber.

Verified in headless Chromium: the web build loads, loads the map, survives click/drag/zoom, opens Find Rooms/Preferences, and the console has no "exec() is not supported" or abort lines. Desktop: build, 14 tests, clang-format.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QFncyBYH55KbWPdvzvxXQw

Summary by Sourcery

Build WebAssembly without Asyncify while converting reachable blocking UI flows to non-blocking behavior.

Bug Fixes:

  • Replace wasm-incompatible blocking dialogs and menus with non-blocking interactions to prevent nested event-loop aborts.

Enhancements:

  • Remove Asyncify from the Emscripten build and adapt save, discard, menu, and message-box workflows to use continuations or asynchronous presentation while preserving blocking desktop behavior where required.
  • Add shared window utilities for self-managed non-blocking message boxes and popup menus.

Build:

  • Disable Asyncify instrumentation for WebAssembly builds.

Tests:

  • Verify the WebAssembly build in headless Chromium and retain desktop build, test, and formatting validation.

Asyncify instruments every function that might sit on the stack during a
nested event loop, which roughly doubles mmapper.wasm (37 MB -> 22 MB
without it) and, with it, the browser's compiled-code footprint -- the
part that pushes an iPad tab over its memory limit. Without Asyncify a
nested QEventLoop::exec() on wasm aborts, so every blocking call that is
reachable there is converted:

- QMessageBox::information/warning/critical statics -> mmqt::showInformation/
  showWarning/showCritical (window_utils): a heap box with
  WA_DeleteOnClose shown with open().
- QMenu::exec() in the adventure, tasks and timer panels ->
  mmqt::popupMenu(): takes ownership of the menu and popup()s it.
- MainWindow::maybeSave() takes a continuation (File > New/Open/Reload);
  closeEvent() keeps a blocking maybeSaveBlocking() on desktop, since it
  cannot be deferred, and on wasm the browser owns the tab's lifetime.
- RemoteEditWidget's discard prompt is shown with open(); the close is
  retried from slot_cancelEdit() when the user discards.
- ShaderUtils' "Message from OpenGL" box is non-blocking on wasm only.

Left as they are because they are not reachable on wasm: the desktop-only
QFileDialog::get* calls, main()'s fatal-GL box (the wasm prober never
fails), the QOpenGLDebugLogger abort path (no KHR_debug on WebGL), and
the busy-waits in AsyncTasks' destructor, TcpSocket and OpenGLProber.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QFncyBYH55KbWPdvzvxXQw

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @nschimme, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 21 hours and 56 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR removes Asyncify from the wasm build to reduce binary and compiled-code memory usage, then eliminates wasm-reachable nested event loops by introducing asynchronous message-box/menu helpers and continuation-based save and discard workflows, while retaining blocking behavior for desktop-only paths.

Sequence diagram for asynchronous map save continuation

sequenceDiagram
    participant User
    participant MainWindow
    participant QMessageBox
    participant MapOperation

    User->>MainWindow: slot_newFile()
    MainWindow->>MainWindow: maybeSave(onProceed)
    MainWindow->>QMessageBox: open()
    QMessageBox-->>MainWindow: finished(result)
    MainWindow->>MainWindow: handleMaybeSaveResult(result)
    MainWindow->>MapOperation: forceNewFile()
Loading

Sequence diagram for asynchronous discard confirmation

sequenceDiagram
    participant User
    participant RemoteEditWidget
    participant QMessageBox

    User->>RemoteEditWidget: closeEvent(event)
    RemoteEditWidget->>RemoteEditWidget: slot_contentsChanged()
    RemoteEditWidget->>RemoteEditWidget: promptDiscardChanges()
    RemoteEditWidget->>QMessageBox: open()
    QMessageBox-->>RemoteEditWidget: finished(result)
    alt result is Discard
        RemoteEditWidget->>RemoteEditWidget: slot_cancelEdit()
    else result is Cancel
        RemoteEditWidget-->>User: Keep editor open
    end
Loading

File-Level Changes

Change Details Files
Removes Emscripten Asyncify and replaces wasm-reachable nested event loops with asynchronous Qt UI flows.
  • Disables the Asyncify linker setting for Emscripten builds.
  • Adds heap-owned, self-deleting non-blocking message boxes and popup menus.
  • Migrates reachable QMessageBox statics and QMenu::exec() call sites to the new helpers.
  • Preserves desktop-only blocking behavior for paths that cannot be deferred.
src/CMakeLists.txt
src/global/window_utils.h
src/global/window_utils.cpp
src/adventure/adventurewidget.cpp
src/display/mapcanvas_gl.cpp
src/logger/autologger.cpp
src/mainwindow/TasksPanel.cpp
src/mainwindow/findroomsdlg.cpp
src/mainwindow/infomarkseditdlg.cpp
src/mainwindow/mainwindow-async.cpp
src/mainwindow/mainwindow.cpp
src/mainwindow/roomeditattrdlg.cpp
src/mpi/remoteedit.cpp
src/timers/TimerWidget.cpp
Refactors map save confirmation into continuation-based and desktop blocking variants.
  • Changes maybeSave() to open a non-blocking QMessageBox and invoke a continuation after Save or Discard.
  • Adds result handling and a desktop-only maybeSaveBlocking() for closeEvent().
  • Updates New, Open, and Reload flows to continue after asynchronous confirmation.
  • Adds a separate Open-file continuation entry point.
src/mainwindow/mainwindow-saveslots.cpp
src/mainwindow/mainwindow.cpp
src/mainwindow/mainwindow.h
Makes remote-edit discard confirmation asynchronous and retry-based.
  • Replaces the blocking discard prompt with QMessageBox::open() and a finished callback.
  • Ignores the initial close while prompting and retries cancellation when Discard is selected.
src/mpi/remoteeditwidget.cpp
src/mpi/remoteeditwidget.h
Handles the remaining shader warning dialog conditionally by platform.
  • Uses a non-blocking warning on wasm while retaining the blocking desktop dialog.
src/opengl/legacy/ShaderUtils.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 112 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.06%. Comparing base (8b03755) to head (ea922e8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/mainwindow/mainwindow-saveslots.cpp 0.00% 36 Missing ⚠️
src/mpi/remoteeditwidget.cpp 0.00% 20 Missing ⚠️
src/global/window_utils.cpp 0.00% 15 Missing ⚠️
src/mainwindow/mainwindow.cpp 0.00% 11 Missing ⚠️
src/timers/TimerWidget.cpp 0.00% 8 Missing ⚠️
src/mainwindow/TasksPanel.cpp 0.00% 7 Missing ⚠️
src/opengl/legacy/ShaderUtils.cpp 0.00% 4 Missing ⚠️
src/mainwindow/findroomsdlg.cpp 0.00% 2 Missing ⚠️
src/mainwindow/infomarkseditdlg.cpp 0.00% 2 Missing ⚠️
src/mainwindow/mainwindow-async.cpp 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #552      +/-   ##
==========================================
- Coverage   25.08%   25.06%   -0.03%     
==========================================
  Files         528      528              
  Lines       44211    44249      +38     
  Branches     4794     4790       -4     
==========================================
  Hits        11092    11092              
- Misses      33119    33157      +38     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nschimme
nschimme merged commit 7391a20 into master Sep 13, 2026
20 of 22 checks passed
@nschimme
nschimme deleted the wasm-no-asyncify branch September 13, 2026 18:52
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