microsoft / microsoft/WindowsAppSDK

IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData.Data is not marshaled in RedirectActivationToAsyncBug title

Open
#3,588 0 comments 0 reactions 0 assignees View on GitHub
area-Activation
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

Because of the async nature of WinAppSDK redirection, via RedirectActivationToAsync, the OS launch logic assumes that it is safe to destroy the InputToken required by SharedStorageAccessManager.RedeemTokenForFileAsync, as soon as the secondary instance terminates. So it’s necessary to synchronize termination of the secondary instance with positive handoff of the redirect to the primary instance. That is, Instance 2 should wait until Instance 1 calls SharedStorageAccessManager.RedeemTokenForFileAsync. Today, that’s not happening – thus the bug.

Now ProtocolForResultsActivatedEventArgs implements IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, which provides a mutable general purpose ValueSet (name-value pair collection) via the Data property:
[IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData.Data Property (Windows.ApplicationModel.Activation) - Windows UWP applications | Microsoft Learn](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.applicationmodel.activation.iprotocolactivatedeventargswithcallerpackagefamilynameanddata.data%3Fview%3Dwinrt-22621&data=05%7C01%7Cdaferg%40microsoft.com%7C5731faca1f9947bce0a808db41051761%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638175262359063639%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OlAAelqyUyyPpIsY7EHpi94fp947VvzMcI%2BwVFQjSzE%3D&reserved=0)

So my original proposal to Yawen was to place all necessary redirection data in this store:
• The InputToken string required by SharedStorageAccessManager.RedeemTokenForFileAsync
• Any synchronization primitives (e.g., the name of an [EventWaitHandle](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.albahari.com%2Fthreading%2Fpart2.aspx%23_CrossProcess_EventWaitHandle&data=05%7C01%7Cdaferg%40microsoft.com%7C5731faca1f9947bce0a808db41051761%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638175262359063639%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nrYoyCO3jEfUtn%2BXR3agWeOHXbfjRpj%2FTsqKvwaXbFA%3D&reserved=0))
• etc

But we struggled to get these mutations marshaled to Instance 1 – they were simply dropped, and we didn’t have time to debug into why. That strikes me as a bug, and fixing that should unblock your scenario.

### Steps to reproduce the bug

see bug description

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

None

### Packaging type

_No response_

### Windows version

_No response_

### IDE

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the handoff through RedirectActivationToAsync and inspect how IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData.Data is transferred between instances. Verify whether the InputToken and synchronization data reach Instance 1; done means the mutations are preserved and the secondary instance waits for the primary instance to redeem the token.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.