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

Fixing CommandBarFlyout lifetime crashing bug #6929

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

RBrid
Copy link
Contributor

@RBrid RBrid commented Apr 4, 2022

Description

The onCompleteFunc function provided to CommandBarFlyoutCommandBar::PlayCloseAnimation method would sometimes be executed on an already destroyed CommandBarFlyout, causing an app crash.

Motivation and Context

This problem recently surfaced when a consumer called CommandBarFlyout.Hide in a FlyoutClosed handler. By the time the closing animation completed, the CommandBarFlyout may already have been destroyed. The app would crash in the onCompleteFunc function execution, while operating on a destroyed instance.
The fix is to pass a weak reference to the CommandBarFlyout instance alongside the onCompleteFunc function and check if that object is still alive before invoking onCompleteFunc. The call is skipped otherwise.

How Has This Been Tested?

Manually tested the application that surfaced this bug and could no longer repro. It was originally repro'able within a couple minutes while OS & Style animations are turned on.

Expanded the MuxControlsTestApp to optionally cover CommandBarFlyout.Hide being called in FlyoutClosed handler.
Created a new regression test with that scenario, which required the use of DefaultCommandBarFlyoutCommandBarStyle with its animations turned on.

@RBrid RBrid self-assigned this Apr 4, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 4, 2022
@RBrid
Copy link
Contributor Author

RBrid commented Apr 4, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@RBrid RBrid requested a review from llongley April 4, 2022 20:15
@RBrid RBrid merged commit 8d35575 into main Apr 5, 2022
@RBrid RBrid deleted the user/regisb/CommandBarFlyoutFix2 branch April 5, 2022 00:04
@ojhad ojhad added team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CommandBarFlyout team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants