microsoft / microsoft/microsoft-ui-xaml

Using composition on elements inside a `ScrollView` crash the app

Open
#10,974 5 comments 1 reaction 0 assignees View on GitHub
area-Scrolling bug team-CompInput
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

This happens whenever you call `ElementCompositionPreview::GetElementVisual()` on any elements inside a `ScrollView`, even when you did absolutely nothing.

### Why is this important?

This stops developers from utilizing the composition apis for advanced visual and effect.

### Steps to reproduce the bug

1. Create a new winui 3 project
2. Use this xaml
```xml



```
3. In the window constructor
```cpp
MainWindow::MainWindow()
{
InitializeComponent();
auto visual = winrt::Microsoft::UI::Xaml::Hosting::ElementCompositionPreview::GetElementVisual(CompositionHost());
}
```

### Actual behavior

Crash

### Expected behavior

Works.

### Screenshots

_No response_

### NuGet package version

None

### Windows version

Windows 10 (1809): Build 17763

### Additional context

Curiously, changing to `ScrollViewer` and doing the same thing does not cause a crash. Sugguesting there is some unexpected internal logic going wrong here.

Contributor guide

Open the contributing guide

Research direction

Start with the provided WinUI 3 reproduction using a Grid inside ScrollView and ElementCompositionPreview::GetElementVisual(). Compare that behavior with the ScrollViewer variant mentioned in the issue and trace where the call crashes. Done means retrieving the visual for an element inside ScrollView without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
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.