microsoft / microsoft/microsoft-ui-xaml

Microsoft.UI.Input.InputPointerSource does not implement IWeakReferenceSource

Open
#11,198 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug team-CompInput
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When subscribing to its events using C++/WinRT auto_revoke, the application crashes during event registration.
```cpp
if (auto xamlRoot = sender.as().XamlRoot())
{
if (auto island = xamlRoot.ContentIsland())
{
auto inputPointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(island);

auto revoker = inputPointerSource.PointerPressed(winrt::auto_revoke, [](auto&, auto&) {});
}
}
```

### Why is this important?

This scenario currently leads to a runtime crash with no obvious indication that the API does not support weak references.

Since most WinRT types support weak references by default, developers can easily run into this issue unintentionally. If this behavior is by design, the documentation should clearly state that `InputPointerSource` does not support weak references.

### Steps to reproduce the bug

The minimal reproduction is shown in the code sample above.

### Actual behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

2.2.0

### Windows version

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

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 minimal reproduction at InputPointerSource::GetForIsland and the PointerPressed auto_revoke registration shown in the issue. Investigate the InputPointerSource implementation and its weak-reference behavior, then verify that event registration no longer crashes or that the unsupported behavior is clearly documented, with a regression test if the project provides one.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.