Closed Bug 1858225 Opened 1 year ago Closed 10 months ago

Async Win32 file-picker

Categories

(Core :: Widget: Win32, enhancement)

Desktop
Windows
enhancement

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: rkraesig, Assigned: rkraesig)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(10 files, 3 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Our internal file-picker interface is already mostly async. However, the Win32 file dialog itself is synchronous and modal; it will need to be placed on a separate thread to avoid blocking the main event loop.

(This is formally orthogonal to moving it out-of-process, per bug 1837079, but the two tasks touch enough of the same code that in practice they have to be sequenced somehow.)

Blocks: 1677170
Depends on: 1863795
Blocks: 1837008
Assignee: nobody → rkraesig
Status: NEW → ASSIGNED

We're about to add some code that will actually create a file dialog,
rather than just the actor, asynchronously. Rename this function to make
it clear which of those it does.

(That it does so asynchronously is probably sufficiently communicated by
the return type.)

Depends on D193732

These functions are essentially sprues, left over from earlier
development. Trim them away.

No functional changes.

Depends on D193733

Introduce functions which create and invoke the Windows file-picker in a
separate thread.

Technically, no functional changes: these functions aren't actually
invoked yet. (That will occur in an upcoming commit.)

Depends on D193734

When opening a file picker in a utility process, do so off the utility
process's main thread, allowing multiple dialogs to resolve in parallel.

The relevant IPC calls are already formally async, so this suffices to
convert them to being functionally async as well. (While this is
technically a functional change, it's not yet a user-visible one: the
parent-process code is still synchronous.)

Depends on D193735

When opening a file dialog locally (that is, in the parent process), do
so asynchronously on a separate thread.

Since the calling code is still synchronous, this necessitates adding
new calls to ImmorallyDrivePromiseToCompletion at the sync-to-async
boundary. These are very temporary -- they'll be removed before this
patchset is done.

Depends on D193736

Pull the sync-to-async boundary up one function-call layer, from
ShowXxxPicker{Local,Remote} to ShowXxxPicker. This coalesces the
remote and local sync-to-async boundaries.

Additionally, standardize on exclusive MozPromises, since none of them
happen to need multiple listeners.

This is arguably, but not practically, a functional change, as a tiny
bit of glue code is now executed on a different thread.

(N.B.: While this reduces the total number of sync-to-async boundaries
back down to two, this is not the removal promised in the previous
commit summary.)

Depends on D193737

Pull the sync-to-async boundary up another function-call layer. This
unifies the file- and folder-picker sync-to-async boundaries.

Again, no functional changes except for the migration of a tiny bit of
glue code.

Depends on D193738

Pull the async-to-sync transition down one (or two) class-layers, while
pulling the sync-to-async transition up one more function layer. This
allows them to meet in a single function -- where they cleanly annihilate.

This is a significant functional change, as it leaves the file-dialog
implementation fully asynchronous on Windows! \o/

Depends on D193739

This is no longer needed on Windows, so #ifdef it out.

Depends on D193740

For clarity, separate out decoding what the preference says to do (which
is not as trivial as might be desired) from actually doing it (ditto).

Depends on D193741

Add a lint (paralleling the existing lint for CoInitializeEx) for new
uses of the utility classes defined in ApartmentRegion.h.

Depends on D194302

Comment on attachment 9364851 [details]
Bug 1858225 - [2/2] Add lint for ApartmentRegion and derivatives r?handyman!

Revision D194303 was moved to bug 1865867. Setting attachment 9364851 [details] to obsolete.

Attachment #9364851 - Attachment is obsolete: true
Attachment #9363821 - Attachment description: Bug 1858225 - [0/10] drive-by: add FileDialog to Windows profiler preset r?#profiler-reviewers! → Bug 1858225 - [0/9] drive-by: add FileDialog to Windows profiler preset r?#profiler-reviewers!
Attachment #9363822 - Attachment description: Bug 1858225 - [1/10] rename CreateWinFileDialogAsync to CreateWinFileDialogActor r?#ipc-reviewers! → Bug 1858225 - [1/9] rename CreateWinFileDialogAsync to CreateWinFileDialogActor r?#ipc-reviewers!
Attachment #9363823 - Attachment description: Bug 1858225 - [2/10] inline `nsFilePicker::...Impl()` functions r?#win-reviewers! → Bug 1858225 - [2/9] inline `nsFilePicker::...Impl()` functions r?#win-reviewers!
Attachment #9363824 - Attachment description: Bug 1858225 - [3/10] introduce "local" async-filepicker implementation functions r?handyman!,#win-reviewers! → Bug 1858225 - [3/9] introduce "local" async-filepicker implementation functions r?handyman!,#win-reviewers!
Attachment #9363825 - Attachment description: Bug 1858225 - [4/10] use alternate-thread file picker in remote process r?#win-reviewers! → Bug 1858225 - [4/9] use alternate-thread file picker in remote process r?#win-reviewers!
Attachment #9363826 - Attachment description: Bug 1858225 - [5/10] use local-async functions for local calls r?#win-reviewers! → Bug 1858225 - [5/9] use local-async functions for local calls r?#win-reviewers!
Attachment #9363827 - Attachment description: Bug 1858225 - [6/10] hoist syncification one layer up r?#win-reviewers! → Bug 1858225 - [6/9] hoist syncification one layer up r?#win-reviewers!
Attachment #9363828 - Attachment description: Bug 1858225 - [7/10] hoist syncification one more layer r?#win-reviewers! → Bug 1858225 - [7/9] hoist syncification one more layer r?#win-reviewers!
Attachment #9363829 - Attachment description: Bug 1858225 - [8/10] cancel out sync/async transitions r?#win-reviewers! → Bug 1858225 - [8/9] cancel out sync/async transitions r?#win-reviewers!
Attachment #9363830 - Attachment description: Bug 1858225 - [9/10] remove async-to-sync code from Windows build r?#win-reviewers! → Bug 1858225 - [9/9] remove async-to-sync code from Windows build r?#win-reviewers!
Attachment #9363831 - Attachment is obsolete: true
Blocks: 1867630
Pushed by rkraesig@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/82b7b851c429 [0/9] drive-by: add FileDialog to Windows profiler preset r=profiler-reviewers,julienw https://hg.mozilla.org/integration/autoland/rev/c31dfa5f9be5 [1/9] rename CreateWinFileDialogAsync to CreateWinFileDialogActor r=win-reviewers,mhowell,gerard-majax https://hg.mozilla.org/integration/autoland/rev/2eb38cba55d6 [2/9] inline `nsFilePicker::...Impl()` functions r=win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/6aacb8fde7e1 [3/9] introduce "local" async-filepicker implementation functions r=handyman,win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/9b2c6eaf137e [4/9] use alternate-thread file picker in remote process r=win-reviewers,handyman,mhowell https://hg.mozilla.org/integration/autoland/rev/f57ac4a387f2 [5/9] use local-async functions for local calls r=win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/9b1f0d37b74b [6/9] hoist syncification one layer up r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/61c8a62b47c5 [7/9] hoist syncification one more layer r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/d1efbf517c7e [8/9] cancel out sync/async transitions r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/e6f456e40dda [9/9] remove async-to-sync code from Windows build r=win-reviewers,mhowell
Pushed by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/808f68da4438 [10/9] add thread name to permitted-threads list. r=bustage-fix CLOSED TREE
Blocks: 705190
Attachment #9366389 - Attachment is obsolete: true

Reresolved the misresolved merge conflict, then ran git rebase -i central --exec './mach build' with the clang-plugin active; all green.

A current try-job is also green so far, except for known intermittents. Attempting a reland shortly...

Flags: needinfo?(rkraesig)
Pushed by rkraesig@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6b56a5c339c3 [0/9] drive-by: add FileDialog to Windows profiler preset r=profiler-reviewers,julienw https://hg.mozilla.org/integration/autoland/rev/54e12c84d094 [1/9] rename CreateWinFileDialogAsync to CreateWinFileDialogActor r=win-reviewers,mhowell,gerard-majax https://hg.mozilla.org/integration/autoland/rev/32f455e67029 [2/9] inline `nsFilePicker::...Impl()` functions r=win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/1c7b0f8d1e8d [3/9] introduce "local" async-filepicker implementation functions r=handyman,win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/1a25d0d1161b [4/9] use alternate-thread file picker in remote process r=win-reviewers,handyman,mhowell https://hg.mozilla.org/integration/autoland/rev/d08b97ae0098 [5/9] use local-async functions for local calls r=win-reviewers,mhowell https://hg.mozilla.org/integration/autoland/rev/e66d99182863 [6/9] hoist syncification one layer up r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/735ce96c3325 [7/9] hoist syncification one more layer r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/1c6cd3fa8c52 [8/9] cancel out sync/async transitions r=win-reviewers,handyman https://hg.mozilla.org/integration/autoland/rev/3e082a66c721 [9/9] remove async-to-sync code from Windows build r=win-reviewers,mhowell
Blocks: 465511
No longer blocks: 1837008
Regressions: 1878568
Regressions: 1879608
Regressions: 1893868
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: