Close open dialogs when a secondary view is consolidated - #3415
Open
FrayxRulez wants to merge 1 commit into
Open
Close open dialogs when a secondary view is consolidated#3415FrayxRulez wants to merge 1 commit into
FrayxRulez wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NativeException/ACCESS_VIOLATION, reported by crash telemetry on 12.10.2.0 (X64).Cause
The finalizer thread releases the last reference to a
ContentDialogthat belonged to asecondary view whose XAML core is already gone.
OnFinalReleaseOffThreadcannot post thedelete back to that view, so it runs
~ContentDialoginline on the finalizer thread; thedialog is still marked open, the destructor takes
DetachEventHandlersForOpenDialog, andthat faults.
This is the same class of failure
OnShutdownStarting's drain already exists to prevent —collect the view's RCWs while its thread still pumps and XAML is still up, so nothing is
released past the dead core. An open
ContentDialogslips through it: it is parented tothe popup root, not to
Window.Content, soOnConsolidated's_window.Content = nulldoes not unroot it. The native tree still holds its peer, the drain has nothing to collect,
and the dialog is finalized whenever a later GC happens to run.
The log tail from a report matches that exactly. A share target window opens a
ChooseChatsPopup, is closed with the dialog still up, and drains clean and fast — 234msthen 187ms, nowhere near the 2s timeout, which is the "still reference-tracked by the
native tree, nothing here to collect" outcome the diagnostic comment in
Draindescribes.Thirty seconds later a new share target window opens its own popup, and the allocation
collects the previous dialog: the crash lands ~1.2s after that second popup is shown.
ShareWindownever hides itsChooseChatsPopup, so it is the easiest way in, but nothingabout this is specific to the share target — any secondary view closed with a dialog open
gets there.
Change
OnConsolidatednow hides any openContentDialogfor the view before it drops thecontent. Placed before
OnClosed, which detaches the content and with itXamlRoot.Kept inside the
NET9_0_OR_GREATERblock with the rest of the teardown machinery it feeds,since that is where the drain lives and where the reports come from; it is a one-word change
to apply it on both flavors.
Notes
Not built or run — a UWP build was not available here. The file parses clean under Roslyn
with the symbol both defined and undefined; that catches syntax, not types.
One residual:
ContentDialog.Hide()starts a close transition that needs a rendered frameto finish, and the app's own
ContentPopupcompletion signal (QueueCallbackForCompositionRendered)needs one too. The shutdown deferral keeps the thread pumping and the drain is queued behind
it at
Low, so it should get there — but if reports continue on this stack, forcingpopup.IsOpen = falseafter theHide()unroots it without waiting for a frame, and thatis the next thing to try.