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

Stack Overflow Exception #3189

Closed
waliarubal opened this issue Oct 31, 2019 · 11 comments
Closed

Stack Overflow Exception #3189

waliarubal opened this issue Oct 31, 2019 · 11 comments

Comments

@waliarubal
Copy link

I just upgraded my project to latest preview of 0.9 and now its completely broken.
Expanding or clicking on bound tree nodes have started giving stack overflow exceptions. It was working very well with Avalonia 0.8.3 stable.

To reproduce follow below mentioned steps.

  1. Clone my project's 'master' branch from repositary URL https://github.com/waliarubal/Jaya.
  2. Run it and on left hand side of navigation tree under 'File System' node, expand it to show your PC's node.
  3. In PC node, further expand it to show drives attached to your PC.
  4. Then on any drive node, just click it and see stack overflow coming.

Earlier I thought that this might be because of another package I am using but it seems like it's not because of it. You can refer this for that issue. AvaloniaUI/Avalonia.Xaml.Behaviors#28

@Gillibald
Copy link
Contributor

I think it was suggested that ReactiveUI could cause this. Could you isolate the areas that are using ReactiveUI? Also a small repro would be ideal.

@waliarubal
Copy link
Author

waliarubal commented Oct 31, 2019

@Gillibald The file where this trouble is administered is https://github.com/waliarubal/Jaya/blob/master/Jaya.Ui/Views/NavigationView.xaml. It shall get you started real quick without having to dig deep.

@Gillibald
Copy link
Contributor

This line is causing the stack overflow: https://github.com/waliarubal/Jaya/blob/master/Jaya.Ui/Views/ExplorerView.xaml#L98

The binding returns null for the target command and it looks like this is retried over and over again.

@Gillibald
Copy link
Contributor

Even without a binding the CommandInvokeAction is causing a stack overflow.

@waliarubal
Copy link
Author

@Gillibald This is strange though, I reported the issue to @wieslawsoltes regarding his Behaviors assembly which I am using and he mentioned that it's happening even after removing it. Maybe he can shed some more light on this matter as per his investigations.

@waliarubal
Copy link
Author

@Gillibald Today I was revisiting the issue (waliarubal/Jaya#13), it seems like your observation is partially correct. https://github.com/waliarubal/Jaya/blob/ba7994037dfa8d064e87d88b1631f899d1b2c886/Jaya.Ui/ViewModels/NavigationViewModel.cs#L48 is getting stack overflow exception.

Even after commenting out ExplorerView from main window, still exception is being thrown. Designer is trying to set its value 'null' again and again which should not happen at the very first place. Please take latest from my repository and check this out. When I have a node selected in the tree view, as soon as I click on another node the exception starts appearing. Theoretically this should not happen as I am not setting 'null', instead another node is being set through SelectedItem property of TreeView.

@waliarubal
Copy link
Author

@Gillibald Another thing which I noticed today is stack overflow doesn't happen when we click expand node icon on the left of the node. It happens when node selection is done. Please be kind enough to have a look.

@Gillibald
Copy link
Contributor

@waliarubal This is an issue with TreeView and how it is handling selection changes. In short somehow SelectedItem is set to null and that causes a reset of the SelectedItems and that sets SelectedItem to null. => StackOverflow

@Gillibald
Copy link
Contributor

We need a small repro to tackle this. Hopefully I am able to write a failing unit test on Friday.

@waliarubal
Copy link
Author

@Gillibald this was not at all a problem with v0.8.3, but as soon as stuff upgraded to v0.9.x; things started falling apart and I started struggling with this stack overflow exception. A patch may be needed in a near-planned Avalonia release with the fix. I feel all the people using the TreeView will encounter this issue in some way or the other.

@waliarubal
Copy link
Author

Closing out after cause was diagnosed by @grokys.

i'm not 100% sure how the code is supposed to work, but these lines appear to be causing the problem:
https://github.com/waliarubal/Jaya/blob/6510826746a37f5f4ff2020931ecbb86abf7aee7/Jaya.Shared/Base/ModelBase.cs#L38-L41
the Set method is not accepting null as a property value
is that intentional?
if i comment out the null checks there then there's no more stack overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants