microsoft / microsoft/WindowsAppSDK

Lifetime of activation arguments is too short and unclear

Open
#6,074 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Activation area-Lifecycle needs-triage
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

Describe the bug

The activation arguments have a short lifetime, which makes it easy to hit errors when trying to use them. The main issue is that this includes the data in the arguments, so one has to know to copy it out instead of just keeping a reference to it.

The documentation for AppInstance.GetActivatedEventArgs mentions that

for packaged apps, this method will only return the arguments the first time it is called in an app. So, you should call it as early as possible during activation, as the arguments may become unavailable later.

but it does not mention that even if one calls it early and stores the value for later, it may also become unavailable.

For file activation, the arguments' lifetime is tied to the caller process, so GetActivatedEventArgs may not even work the first time. See #5481

For activation redirection, the activation arguments are only valid during the Activated event. So, again, it is not possible to store the arguments and use them later.

Steps to reproduce the bug

.

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AppInstance.GetActivatedEventArgs API and the activation-redirection and file-activation behavior described in the issue; review related issue #5481. Determine the documented lifetime for each activation path and whether the reported unavailability is expected or requires a fix, then verify the resulting behavior or documentation.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.