fix(AppLifecycle): coalesce multi-file activation redirections into single event#6276
Open
fix(AppLifecycle): coalesce multi-file activation redirections into single event#6276
Conversation
Port agents and skills from PowerToys for automated PR and issue workflows, generalized for any repository: Agents (8): ReviewPR, FixPR, TriagePR, ReviewIssue, PlanIssue, FixIssue, IssueToPR, ReviewTheReview Skills (10): pr-review (13-dimension analysis), pr-fix, pr-rework (iterative review-fix-build loops), pr-triage, issue-review, issue-fix, issue-review-review, issue-to-pr-cycle, continuous-issue-triage, parallel-job-orchestrator Key generalizations: - Auto-detect owner/repo via gh CLI (Get-RepoSlug helper) - Build commands use existing BuildAll.ps1 - Worktree scripts use existing worktree-manager skill - Review dimension 10 rewritten for C++/WinRT + WIL patterns - All 13 review dimensions updated with WinAppSDK-specific checks - No hardcoded repo references; fully portable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bump AppLifecycleContract from v2 to v3 and expose a public constructor on AppActivationArguments(ExtendedActivationKind, IInspectable) so callers can create instances directly for activation redirection scenarios without relying on internal factory methods. Fixes #6075
…ingle event When a user opens multiple files at once, each file triggers a separate process that redirects to the main single-instanced app. Previously, each redirection fired a separate Activated event, causing the app to receive N individual activations instead of one event with all N files. This change: - Adds a multi-file constructor to FileActivatedEventArgs that accepts a pre-built IVector<IStorageItem> for efficient in-process merging. - Rewrites AppInstance::ProcessRedirectionRequests() to collect all pending file activation redirections, wait a brief coalescing window (150ms) for late-arriving redirections, and fire a single merged Activated event containing all files. - Non-file activation types continue to fire immediately as before. - All coalesced redirection cleanup events are properly signaled so redirecting processes can exit normally. Fixes #5066
|
Please don't add a forced delay for file activation. The issue can be worked around (at least in packaged apps) by using the <Extensions>
<uap3:Extension Category="windows.fileTypeAssociation">
<uap3:FileTypeAssociation Name="my-extensions" MultiSelectModel="Player">
..This means the app is only launched once (with multiple files provided to the file activation args). If you are going to add a delay, please make this optional as start-up speed is very important to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5066 — App activation fires multiple times when launching multiple files
When a user selects N files and opens them with a WinAppSDK single-instanced app, N processes launch. N-1 processes redirect to the main instance via
RedirectActivationToAsync(). Previously, the main instance fired N separateActivatedevents — each containing 1 file — instead of 1 event containing all N files.Root Cause
ProcessRedirectionRequests()inAppInstance.cpphad a simple while-loop that dequeued each redirection request and firedm_activatedEventindependently for each one.Fix
dev/AppLifecycle/FileActivatedEventArgs.hFileActivatedEventArgs(verb, IVector<IStorageItem>)for coalesced multi-file activationsdev/AppLifecycle/AppInstance.cppRewrote
ProcessRedirectionRequests()to:coalescedFilesvectorFileActivatedEventArgsActivatedevent with all filesNon-file activations continue to fire immediately, preserving backward compatibility.
Testing
WindowsAppRuntime_DLL.vcxprojbuilds cleanly (x64 Release)Activatedevent with all files in theFilescollectionNotes
.github/infrastructure files unrelated to this fix