hawkerm / monaco-editor-uwp

A Windows Runtime Component wrapper around the web-based Monaco Editor.
MIT License
152 stars 36 forks source link

Crash with TabView #53

Open 632575987 opened 4 years ago

632575987 commented 4 years ago

I have a custom control which contains two monaco-editor , when I add the tabviewitem(content is that custom control) to tabview and click the tabviewitem ,app crashed.

hez2010 commented 4 years ago

It caused by a stackoverflow between DependencyProperty and Property while there're multiple CodeEditor instances: https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L62 https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L77 https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L112

A workaround is removing properties ReadOnly, CodeLanguage and HasGlyphMargin and use Options directly instead.

632575987 commented 4 years ago

It casused by a stackoverflow between DependencyProperty and Property while there're multiple CodeEditor instances:

https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L62

https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L77

https://github.com/hawkerm/monaco-editor-uwp/blob/b390c5381b043f91fab9b0921729f37808b5b89c/MonacoEditorComponent/CodeEditor/CodeEditor.Properties.cs#L112

A workaround is removing properties ReadOnly, CodeLanguage and HasGlyphMargin and use Options directly instead.

Could you compile it and publish to Nuget? I tried to compile it myself and publish to Nuget, but the control renders a white non-clickable area. So I had to directly reference the latest source code project in my project, and it works well, this way I had to install some extra software like Node, which was too complicated. Thanks~

hez2010 commented 4 years ago

I'm uploading my build here directly: Monaco.Editor.0.899.0-beta.zip

I compiled it with version 0.899.0-beta, you can put it under a local directory and add the path to your nuget config, then you can reference it directly.

hez2010 commented 3 years ago

@hawkerm This should be fixed before 0.9 release.

hawkerm commented 3 years ago

Linking to #21 as the crux of the issue too.

hawkerm commented 3 years ago

Wonder if this is fixed by the improvements in #58... Not sure about setting up a TabView in the sample test app to reproduce, though but will need to test this out a bit in my other project. May kick-off a build soon to NuGet and just see how it goes.

manfromarce commented 2 years ago

It seems that this is not fixed yet (at least in version 0.9.0-beta from Nuget).

hawkerm commented 2 years ago

Thanks @manfromarce for letting us know. I twiddled with how this works a bit, so that's disappointing to hear. I don't have a repo on my machine yet since it's a more complex setup than the demo app does at the moment. Did you have a similar setup to @632575987?

Can you provide some details on what your TabView XAML and DataTemplate look like where you're using Monaco? More details would help here like a stack trace or a minimal repro app.

manfromarce commented 2 years ago

Hi @hawkerm, I managed to avoid crashes but I noticed 2 curious issues: 1) frame.Navigate(typeof(Page1)); triggers the TabItemsChanged event (if Page1 contains Monaco), even if the tab has not yet been added to the TabView 2) this is probably related to multiple windows rather than TabView: I'm using code similar to the windowing sample in the XAML Controls Gallery app to create a new window when tabs are dragged out (https://github.com/microsoft/Xaml-Controls-Gallery/blob/3b12e184a5c98bcaba1085fcd9fc0f9c09fbd220/XamlControlsGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs). However, when I click on Monaco editor in the second window the focus is shifted to the first window or even if the second window gets focus the first window is always on top. Plus, when first window is closed Monaco disappers from the second window. (I'm using ApplicationView.GetForCurrentView().TryConsolidateAsync(); to close the first window and it seems to work without Monaco)