microsoft / microsoft/microsoft-ui-xaml
Microsoft.UI.Input.InputPointerSource does not implement IWeakReferenceSource
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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