MarshallOfSound

#53574: fix: resolve the file dialog's parent HWND on the UI thread on Windows

Merged
Created: Sep 4, 2026, 10:32:49 PM
Merged: Sep 5, 2026, 9:52:26 AM
5 comments
Target: main

Description of Change

dialog.showOpenDialog() / showSaveDialog() (and the download manager's default Save prompt) run the native dialog on dialog_thread, and ShowFileDialog resolved the parent HWND there via NativeWindowViews::GetAcceleratedWidget()views::Widget::GetNativeWindow(), which reads a UI-thread WeakPtr. In DCHECK builds that's sequence_checker.cc: CalledOnValidSequence and a browser-process crash (CI hit); in release builds it's an unsynchronised read of a window the UI thread may be tearing down.

  • Resolve the HWND on the UI thread in ShowOpenDialog/ShowSaveDialog/Show*DialogSync and pass it into the dialog-thread function, the same way message_box_win.cc has done since the M110 roll. No header or cross-platform change.
  • The CI hit came from asar-spec.ts "saves a packed PDF from the PDF viewer": its click loop can start a second download, which had no will-download handler and fell through to the real Save dialog. Give every download from that test a save path (or refuse it) synchronously in will-download.

Checklist

  • PR description included
  • npm test passes

Release Notes

Notes: Fixed a possible crash on Windows when a file dialog was shown for a window that was being closed at the same time.

Backports

42-x-y
Merged
PR Number
#53585
Merged At
Sep 5, 2026, 11:21:39 AM
Released In
Not yet
Release Date
Not yet
43-x-y
Merged
PR Number
#53584
Merged At
Sep 5, 2026, 11:03:28 AM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#53583
Merged At
Sep 5, 2026, 11:56:36 AM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#53586
Merged At
Sep 5, 2026, 11:59:52 AM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron