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

Fluent Ribbon crashes program on shutdown #489

Closed
sborkman opened this issue Nov 7, 2017 · 9 comments
Closed

Fluent Ribbon crashes program on shutdown #489

sborkman opened this issue Nov 7, 2017 · 9 comments
Assignees
Labels
Milestone

Comments

@sborkman
Copy link

sborkman commented Nov 7, 2017

Hi,
I recently upgraded from a much older version of the Fluent Ribbon bar, and some of my users have started getting program crashes in my crash log. So far, I have been unable to reproduce this problem on my own computer. I've seen it happen (to my boss!!!) when he was using the program on a terminal server. It's also happening to a few other users, but I don't know their exact circumstances. Hopefully the stack trace (which I collect whenever there is an unhandled exception) will help. The problem seems to happen as the program is starting up and the main Fluent Ribbon window is just appearing.

Do you think I should try using the latest beta version (available as a Nuget package)?

Thanks!
Steven

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.DeferredAppResourceReference.GetValue(BaseValueSourceInternal valueSource)
at System.Windows.DependencyPropertyChangedEventArgs.get_OldValue()
at System.Windows.Controls.Control.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.StyleHelper.InvalidateResourceDependents(DependencyObject container, ResourcesChangeInfo info, FrugalStructList1& resourceDependents, Boolean invalidateVisualTreeToo) at System.Windows.TreeWalkHelper.InvalidateStyleAndReferences(DependencyObject d, ResourcesChangeInfo info, Boolean containsTypeOfKey) at System.Windows.TreeWalkHelper.OnResourcesChanged(DependencyObject d, ResourcesChangeInfo info, Boolean raiseResourceChangedEvent) at System.Windows.FrameworkElement.OnAncestorChangedInternal(TreeChangeInfo parentTreeState) at System.Windows.TreeWalkHelper.OnAncestorChanged(DependencyObject d, TreeChangeInfo info, Boolean visitedViaVisualTree) at System.Windows.DescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
at MS.Internal.PrePostDescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree) at System.Windows.DescendentsWalker1.VisitNode(FrameworkElement fe, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1.VisitNode(DependencyObject d, Boolean visitedViaVisualTree) at System.Windows.DescendentsWalker1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren)
at System.Windows.DescendentsWalker1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker1.IterateChildren(DependencyObject d)
at System.Windows.DescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree) at MS.Internal.PrePostDescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1.VisitNode(FrameworkElement fe, Boolean visitedViaVisualTree) at System.Windows.DescendentsWalker1.VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1.WalkLogicalChildren(FrameworkElement feParent, FrameworkContentElement fceParent, IEnumerator logicalChildren) at System.Windows.DescendentsWalker1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren)
at System.Windows.DescendentsWalker1.IterateChildren(DependencyObject d) at System.Windows.DescendentsWalker1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
at MS.Internal.PrePostDescendentsWalker1.StartWalk(DependencyObject startNode, Boolean skipStartNode) at System.Windows.TreeWalkHelper.InvalidateOnTreeChange(FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, Boolean isAddOperation) at System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent) at System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent) at System.Windows.Media.Visual.RemoveVisualChild(Visual child) at System.Windows.FrameworkElement.set_TemplateChild(UIElement value) at System.Windows.StyleHelper.ClearGeneratedSubTree(HybridDictionary[] instanceData, FrameworkElement feContainer, FrameworkContentElement fceContainer, FrameworkTemplate oldFrameworkTemplate) at System.Windows.StyleHelper.DoTemplateInvalidations(FrameworkElement feContainer, FrameworkTemplate oldFrameworkTemplate) at System.Windows.Controls.Control.OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) at System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList1& exclusionContainerDependents, FrugalStructList1& oldContainerDependents, FrugalStructList1& newContainerDependents)
at System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.FrameworkElement.UpdateStyleProperty()
at System.Windows.TreeWalkHelper.InvalidateStyleAndReferences(DependencyObject d, ResourcesChangeInfo info, Boolean containsTypeOfKey)
at System.Windows.TreeWalkHelper.OnResourcesChanged(DependencyObject d, ResourcesChangeInfo info, Boolean raiseResourceChangedEvent)
at System.Windows.FrameworkElement.OnAncestorChangedInternal(TreeChangeInfo parentTreeState)
at System.Windows.TreeWalkHelper.OnAncestorChanged(DependencyObject d, TreeChangeInfo info, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree) at MS.Internal.PrePostDescendentsWalker1._VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1.VisitNode(FrameworkElement fe, Boolean visitedViaVisualTree) at System.Windows.DescendentsWalker1.VisitNode(DependencyObject d, Boolean visitedViaVisualTree)
at System.Windows.DescendentsWalker1.WalkFrameworkElementLogicalThenVisualChildren(FrameworkElement feParent, Boolean hasLogicalChildren) at System.Windows.DescendentsWalker1.IterateChildren(DependencyObject d)
at System.Windows.DescendentsWalker1.StartWalk(DependencyObject startNode, Boolean skipStartNode) at MS.Internal.PrePostDescendentsWalker1.StartWalk(DependencyObject startNode, Boolean skipStartNode)
at System.Windows.TreeWalkHelper.InvalidateOnTreeChange(FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, Boolean isAddOperation)
at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.RemoveLogicalChild(Object child)
at System.Windows.Documents.AdornerLayer.Remove(Adorner adorner)
at Fluent.Backstage.DestroyAdorner()
at Fluent.Backstage.OnBackstageUnloaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastUnloadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)


Environment

  • Fluent.Ribbon __v5.0.2.46
  • Windows 7 Pro SP1
  • .NET Framework (Target = 4.5.2, Runtime = 4.5.2 or higher)
@batzen
Copy link
Member

batzen commented Nov 11, 2017

Will have a look this weekend.

@batzen
Copy link
Member

batzen commented Nov 11, 2017

According to the stacktrace i doubt this happens on startup as the stack show that this happens when the backstage is unloaded and it's adorner is destroyed.

Do you show the backstage or startscreen on application startup?

@sborkman
Copy link
Author

You're right, it's not always start-up. I see that sometimes it happens 2 seconds after a user starts up the program. Other times, it happens after the user has had the program open for a long time. Unfortunately, there doesn't seem to be an obvious pattern.

@sborkman
Copy link
Author

sborkman commented Dec 7, 2017

I just spoke with one of my users that is experiencing this problem. It happens while she's in the middle using the program (not when it's starting up or shutting down). It's been a bit disruptive for her. There's another user that uses the same program just as much, but he hasn't experienced the problem at all. Of course, he could be using the program differently.

@sborkman
Copy link
Author

sborkman commented Dec 8, 2017

I have an idea that might fix this problem. In Backstage.cs, in the DestroyAdorner function, I'm going to try surrounding the call to layer?.Remove(this.adorner); with a call to Dispatcher.DisableProcessing()
like this...
using (this.Dispatcher.DisableProcessing()) { layer?.Remove(this.adorner); }
I will let you know in a week or two if this fixed the problem.

@sborkman
Copy link
Author

Well, that didn't work. After some more investigation, I figured out that the crash actually happens when the program starts up (contrary to what my users were reporting). I tried shutting down the dispatcher on program shutdown, but that didn't prevent the problem. Ultimately, this is what I think I'll do:

In the DestroyAdorner function in Backstage.cs, ignore errors when the program is shutting down:

            try
            {
                layer?.Remove(this.adorner);
            } catch
            {
                if (!Application.Current.Dispatcher.HasShutdownStarted)
                {
                    throw;
                }
            }

And I will call this when the program begins to shut down (which will run before the code shown above):

Application.Current.Dispatcher.InvokeShutdown();

It's not pretty, but it should work. I don't care if there is an error dismantling the UI when I'm shutting down the program. It would be nice to have the underlying problem fixed, of course.

@sborkman sborkman changed the title Fluent Ribbon crashes program on start-up Fluent Ribbon crashes program on shutdown Dec 13, 2017
@batzen
Copy link
Member

batzen commented Jan 3, 2018

May i guess that the application is shut down by clicking a backstage button?

@sborkman
Copy link
Author

sborkman commented Jan 8, 2018

Yes, that is one way the user can close the program. Sounds like you have an idea about what's wrong.

@batzen
Copy link
Member

batzen commented Jan 9, 2018

I think it's the WPF animation system that causes this issue.
Will introduce code to prevent the backstage animation when the application is shutting down.
To prevent this issue right now you could try to set IsDefinitive to False on the backstage-button causing the application to shutdown. That way the backstage does not get dismissed when someone clicks the button.

@batzen batzen self-assigned this Jan 9, 2018
@batzen batzen added the Bug 🐞 label Jan 9, 2018
@batzen batzen added this to the 6.0.0 milestone Jan 9, 2018
@batzen batzen closed this as completed in 3fd9991 Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants