Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectorBar crashes the app #9424

Closed
vfib opened this issue Mar 10, 2024 · 11 comments
Closed

SelectorBar crashes the app #9424

vfib opened this issue Mar 10, 2024 · 11 comments
Assignees
Labels
area-Navigation Frame, Page bug Something isn't working team-Controls Issue for the Controls team

Comments

@vfib
Copy link

vfib commented Mar 10, 2024

Describe the bug

For me, using Win Ui 1.5 with Net 8.0, project created by Template Studio for WinUi C#, simple placing a SelectorBar crashes the whole app.

The exception message is: ""
error code: -2147467259

stack trace:
bei WinRT.ExceptionHelpers.g__Throw|39_0(Int32 hr)
bei WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
bei ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(IObjectReference _obj, Size availableSize)
bei Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
bei Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size availableSize)
bei ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)
--- Ende der Stapelüberwachung vom vorhergehenden Ort ---
bei WinRT.ExceptionHelpers.g__Throw|39_0(Int32 hr)
bei WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
bei ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.MeasureOverride(IObjectReference _obj, Size availableSize)
bei Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
bei Microsoft.UI.Xaml.FrameworkElement.Microsoft.UI.Xaml.IFrameworkElementOverrides.MeasureOverride(Size availableSize)
bei ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)

Any advice?
Best regards

Steps to reproduce the bug

  1. Add following snippet to your main page
    <SelectorBar x:Name="SelectorBar"> <!--TODO Use x:UID--> <SelectorBarItem x:Name="T1" Text="Item1" /> <SelectorBarItem x:Name="T2" Text="Item2" /> <SelectorBarItem x:Name="T3" Text="Item3" /> </SelectorBar>

Expected behavior

No response

Screenshots

No response

NuGet package version

1.5

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@bpulliam bpulliam transferred this issue from microsoft/WindowsAppSDK Mar 11, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 11, 2024
@codendone codendone added bug Something isn't working area-Navigation Frame, Page team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Mar 12, 2024
@ranjeshj
Copy link
Contributor

@vfib Thanks for reporting. can you please share your project ?

@ranjeshj ranjeshj added the needs-author-feedback Asked author to supply more information. label Mar 12, 2024
@vfib
Copy link
Author

vfib commented Mar 12, 2024

@ranjeshj Hello, thanks for your answer. I will strip everything sensitive for this.
Meanwhile I debugged a little bit and found, I guess, the place where the exception is thrown. A jit intrinsic bool func that throws without any info but should return true, so it could throw the same error then with more info. But T is byte, so a value type, so the bool func should return false. So the cause of this is, that the jit compiler got irritated?
I would be delighted if you could give me feedback on the extent to which my assumption is correct. Purely for training reasons.
image
image

best regards

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Mar 12, 2024
@vfib
Copy link
Author

vfib commented Mar 12, 2024

@ranjeshj Here it is.
Solution1.zip

@HHaoWang
Copy link

I also meet this error. Just place it and when it is loading the app crash
image
image

@ranjeshj ranjeshj removed the needs-triage Issue needs to be triaged by the area owners label Mar 26, 2024
@mitzoe
Copy link

mitzoe commented Mar 28, 2024

Same issue. I have a UWP app I'm porting to WinUI 3. I'm trying to update my Pivots to SelectorBars per Microsoft's recommendation, but yeah, crash per @vfib's description.

In my XAML I'm changing Pivot to SelectorBar and PivotItem to SelectorBarItem, and updating the SelectionChanged to reflect the new EventArgs. I've also tried placing one in a new UserControl with the same result.

@karkarl karkarl self-assigned this Mar 29, 2024
@MPITech
Copy link

MPITech commented Apr 1, 2024

Same crash here using the same steps as above. Thanks for looking into this.

@karkarl
Copy link
Contributor

karkarl commented Apr 1, 2024

Solution1.zip

@vfib I'm unable to build and run this project even after commenting out SelectorBar and downleveling to WASDK 1.4. I'm also unable to repro the crash by creating a template studio project based on your configurations.

Can you provide another repro app?

@vfib
Copy link
Author

vfib commented Apr 3, 2024

Solution1.zip

@vfib I'm unable to build and run this project even after commenting out SelectorBar and downleveling to WASDK 1.4. I'm also unable to repro the crash by creating a template studio project based on your configurations.

Can you provide another repro app?

Since you dont tell me the errors I cant assist you with this, nor can I provide another project. For me its building fine.
Perhaps @HHaoWang, @MPITech or @mitzoe can provide theirs?

@HHaoWang
Copy link

HHaoWang commented Apr 3, 2024

I'm sorry I can not reproduce this error now cause I've used NavigationView to achieve my goal. I just tried it again and it would not carshed. It's amazing and confusing. By the way, I have to complain about the error report as it dosen't provide any useful thing about the error excepting some useless and meanningless string like " ... microsoft c++ ... winrt:hresult_error ..."

@kmahone
Copy link
Member

kmahone commented Apr 3, 2024

You can get better debug information if you debug with native code debugging enabled. This produces this error message which does not show when attached only with a managed debugger:

'Failed to assign to property 'Microsoft.UI.Xaml.Controls.ItemsRepeater.ItemTransitionProvider'.

This is the same underlying issue as #8810.

This occurs when the project references libraries containing xaml controls (e.g. CommunityToolkit.WinUI.UI.Controls) that were built against an older version of WinAppSDK than the app. This results in an IXamlMetadataProvider being used that includes out of date metadata. See the linked bug for more details.

To address this issue we need to fix the bug in the Xaml Compiler that generates the app's IXMP implementation.

Until that issue is addressed, there are two ways to work around this bug. The first is to use the DoNotGenerateOtherProviders flag and manually provide the set of IXMP providers. This approach is described in the linked bug.

An easier workaround is to add a Xaml page to your app. On that page add an instance of <ItemsRepeater />. You don't even need to ever navigate to that page. Just having it in your app will mean that your app is aware of the ItemsRepeater metadata and so it does not hit this problem during xaml parse time.

The other way to resolve this issue would be to update the dependencies to newer versions that are built against the target version of WinAppSDK. However updated WCT libraries are not yet available so that is not an option for this case.

@kmahone kmahone closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2024
@karkarl
Copy link
Contributor

karkarl commented Apr 3, 2024

You can get better debug information if you debug with native code debugging enabled. This produces this error message which does not show when attached only with a managed debugger:

'Failed to assign to property 'Microsoft.UI.Xaml.Controls.ItemsRepeater.ItemTransitionProvider'.

@HHaoWang Turning on all the checkboxes for first-chance exceptions in VS is what got me to produce the above error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Navigation Frame, Page bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

8 participants