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

AttachedDropShadow Sample App Crash #4750

Closed
1 of 14 tasks
michael-hawker opened this issue Sep 1, 2022 · 7 comments · Fixed by #4757
Closed
1 of 14 tasks

AttachedDropShadow Sample App Crash #4750

michael-hawker opened this issue Sep 1, 2022 · 7 comments · Fixed by #4757
Assignees
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 sample app 🖼
Milestone

Comments

@michael-hawker
Copy link
Member

Describe the bug

While looking at #4548 and seeing if we could reproduce it in the sample app, hit a crash when pasting in the XAML into the sample app...

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

1. Open Sample App
2. Open Attached Drop Shadow sample
3. Replace ScrollViewer with following from #4548


<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>

    <Border x:Name="ShadowTarget" Grid.Column="0"/>

    <Border Grid.Column="1" Background="AliceBlue">
        <ui:Effects.Shadow>
            <ui:AttachedDropShadow BlurRadius="60"
                               Color="Black"
                               CastTo="{Binding ElementName=ShadowTarget}"/>
        </ui:Effects.Shadow>
    </Border>
</Grid>


See crash...

Expected behavior

No crash

Screenshots

No response

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Nuget packages

No response

Additional context

No response

Help us help you

Yes, but only if others can assist.

@michael-hawker michael-hawker added bug 🐛 An unexpected issue that highlights incorrect behavior sample app 🖼 labels Sep 1, 2022
@michael-hawker michael-hawker added this to the 7.1.3 milestone Sep 1, 2022
@LalithaNadimpalli
Copy link
Contributor

LalithaNadimpalli commented Sep 1, 2022

It's crashing if we just replace the ScrollViewer code but it works fine if we replace the whole code by just including the Page tag

@michael-hawker
Copy link
Member Author

Hmm, interesting. We do have logic on that page in the code-behind:

https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/main/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Shadows/AttachedDropShadowPage.xaml.cs

So, I wonder if something with this particular example is just causing that to fail. Should be easy to see what's failing if you run the Sample App from VS and reproduce the crash?

At least it means this is independent of #4548 and may be isolated to the Sample App itself.

@LalithaNadimpalli
Copy link
Contributor

If we just remove the Page. Resources code and Scrollviewer code and place the code user suggested then there is no crash(Can include all the namespaces as is) but if we include the Page. Resources code and then place Grid code then there is a crash in the sample app

@LalithaNadimpalli
Copy link
Contributor

I see the crash when I try to reproduce the issue in VS and it throws NRE(NullReferenceException) in

Image

@michael-hawker
Copy link
Member Author

Thanks @LalithaNadimpalli can you provide the call stack as well? What called into this method?

This is where the code is (you can select multiple lines in GitHub and get a permalink from the triple dot menu to embed these in comments as well like this):

public IEnumerable<AttachedShadowElementContext> EnumerateElementContexts()
{
foreach (var kvp in ShadowElementContextTable)
{
yield return kvp.Value;
}
}

It would seem somehow ShadowElementContextTable is being set to null (but I don't see code that does that), so it could mean something's calling this method before anything is connected maybe?

FYI @Ryken100

@LalithaNadimpalli
Copy link
Contributor

I created a PR by adding a null check to ShadowElementContextTable which fixed the issue

@LalithaNadimpalli
Copy link
Contributor

This is how the call stack looks like with NRE

Image

Repository owner moved this from In Progress to Done in Windows Community Toolkit Sep 22, 2022
@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Sep 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥 sample app 🖼
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants