Closed Sergio0694 closed 3 years ago
@Sergio0694 tried running the sample app but got:
System.Exception
HResult=0x8001010E
Message=The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
> Monaco.winmd!Monaco.CodeEditor.Options.get() Line 99 C#
[Native to Managed Transition]
[Managed to Native Transition]
Monaco.winmd!Monaco.Helpers.ParentAccessor.GetJsonValue(string name) Line 144 C#
Rebased this on top of the 0.9 work thread I had with all the updates I've made recently. Also worked on making sure we could dispatch everything properly to marshal between the threads. Has been a bit of a pain, but almost have it working...
[ ] Running into an issue where the initial Editor Language property isn't being set properly. (Wonder if related to #58?) So I need to debug that next. Otherwise most other things appear to be working, I think?
[x] Some of the margin decorators may not be working, I need to investigate what's supposed to be there.
When we highlight/mark all the things, we should get this:
We're currently with the out-of-proc WebView getting this:
Which... is the same... it works! Yay!
I think the problem was that I was trying to test them when the language wasn't set to the right provider and for some reason there it wasn't working as expected. This may be related to the HasGlyphMargin
property not being initialized at the beginning as well...
Surprisingly in Release Mode I still hit an exception with Decorations like I did in the 0.9 changes (see comment here)...
I would have hoped that was resolved by this move to async everything... That's going to require a deeper investigation then, which is concerning as it's a Release Mode only thing... ðŸ˜
Oh, this may be a different exception, the stack appears to be a ton of Newtonsoft Json bits:
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::ExpressionValueProvider.GetValue(System::Object & target) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.CalculatePropertyValues($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonContainerContract & contract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonProperty & property, $7_Newtonsoft::Json::Serialization::JsonContract & & memberContract, System::Object & & memberValue) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeObject($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonObjectContract & contract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & collectionContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeValue($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonContract & valueContract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & containerContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeObject($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonObjectContract & contract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & collectionContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeValue($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonContract & valueContract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & containerContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeObject($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonObjectContract & contract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & collectionContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
MonacoEditorTestApp.dll!$7_Newtonsoft::Json::Serialization::JsonSerializerInternalWriter.SerializeValue($7_Newtonsoft::Json::JsonWriter & writer, System::Object & value, $7_Newtonsoft::Json::Serialization::JsonContract & valueContract, $7_Newtonsoft::Json::Serialization::JsonProperty & member, $7_Newtonsoft::Json::Serialization::JsonContainerContract & containerContract, $7_Newtonsoft::Json::Serialization::JsonProperty & containerProperty) Unknown
... repeating until maxed out
Wish I knew where this was being called from exactly. Maybe this is an rd.xml thing I need to tweak? I should check if I updated the Newtonsoft version or not... (eventually should switch to System.Text.Json, but that's another can of worms).
Or maybe the same, was able to switch to x64 bits and get some breakpoints...
System.Exception
HResult=0x8001010E
Message=The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E)
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Stepped a bit and got this:
Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Error getting value from 'Color' on 'Windows.UI.Xaml.Media.SolidColorBrush'.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Inner Exception 1:
Exception: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E)
Yeah, happening in the Decoration method:
Really odd, as I don't think this would have changed from the last release?
This is all initiating from the UI Thread:
So I'm surprised there'd be an issue marshalling a UI object here...
I can try dispatching again, but that seems a bit silly. Otherwise, maybe it's best to have a converter for the object? Don't know if that'd run into the same problem...
Weird... it does look like the inner ContinueWith
in the DeltaDecorationsHelperAsync
method may be on a different thread:
Removed the ContinueWith to just use the AsyncInfo
pattern to bridge as been doing everywhere else... still hitting an issue though... That seems to indicate that we're all on the same thread now, but still failing in the serialization call... though not being as explicit about what's going on.
Fixed #60 over here finally, just needed to clean-up a few things. Was unfortunately unresolved by threading everything for out-of-proc webview as I was hoping.
But in good news, it means out-of-proc WebView is basically working already. Just need to resolve the issue with the initial settings not getting set properly.
This should also help us with the move to WebView2 and it's addhostobjecttoscript
interface later.
@Sergio0694 think I'm good to merge this in my beta branch. I then may try and build a test package to try out in a couple of other projects, merge that branch into main. Then just a couple of bugs to track down...?
Feel free to take a look at this PR and if you have any thoughts, know you can't test right now, but everything seems to be working well so far and think this should help with stuff later anyway for WebView2 too.
Fixed #60 over here finally
I proposed a better fix for this in #63. You don't have to add plenty of JsonIgnore and JsonConverter on properties, instead you can simply add them to the implementation class.
Moved the
WebView
to out of process for better performance.Didn't actually test this yet as I don't have node.js installed 🙈