Comments (13)
Just to add, there's nothing special about navigating to the Monaco editor. If I navigate to www.google.com the same thing happens. I'm going to take the example UWP project posted here, and try the above just to exclude anything particular to my project setup.
from chakra-samples.
Yep I can replicate this with the UWP example.
Steps:
- Add a WebView control to MainPage.xaml
- Change MainPage.cs to this:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
WebView.DOMContentLoaded += WebView_DOMContentLoaded;
WebView.Navigate(new Uri("http://www.google.com"));
}
private void WebView_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args)
{
new ChakraHost.ChakraHost().init();
}
}
- Change debugger type in project settings to Application Process: 'Managed Only'
- Run and step through execution. Call to Native.JsCreateContext(runtime, out context) will fail
This looks like a significant problem unless I'm missing something? Thanks.
from chakra-samples.
Error is normal since WebView also creates the Runtime.
from chakra-samples.
OK so two runtimes. But they don't operate in isolation?
from chakra-samples.
One runtime, multiple context ?
from chakra-samples.
OK, to rephrase, how do I use the WebView and Chakra Engine together without raising ''Runtime is active on another thread' errors. :) If I'm working with the Chakra engine yes I can create multiple contexts. The problem is creating contexts in the first place if I have a WebView active which seems to be hogging the runtime.
from chakra-samples.
Didn't use WebView. If you are on the same thread with WebView (which is IIRC to be main thread??) You may get the active context by calling JsGetCurrentContext
and using that Context, you may grab the Runtime objectJsGetRuntime
.
Just a suggestion. Didn't try it.
from chakra-samples.
This assumes a shared runtime though. I thought the whole point was to be able to create separate isolated runtimes. Surely if I explicitly create a new runtime this should not interact with the runtime created by the WebView. Anyway I'll investigate a bit more, thanks.
from chakra-samples.
Great. Please share your experiences back. It may help others :) Keeping this open for a while then.
from chakra-samples.
Please keep this open. I haven't yet found a way to use the WebView control and Chakra engine together in a UWP app. This seems like a significant issue. Hopefully someone will be able to shed some light.
Thanks
from chakra-samples.
/cc @munyirik ?
from chakra-samples.
OK I think I've found the problem. In the example above I'm creating a runtime on the UI thread (the same thread as the WebView).
If I do one of the following I can successfully create a new context on a new runtime.
Either
-
Run the WebView on a separate thread ( some limitations)
-
Create the Chakra runtime on a separate thread. e.g. Task.Run(()=>new ChakraHost.ChakraHost().init()) in the above example;
Phew. Happy to close :)
from chakra-samples.
Perfect!
from chakra-samples.
Related Issues (20)
- Adding items to a JS array using CallFunction doesn't add HOT 1
- Add ref to task in PromiseContinuationCallback HOT 1
- Details on .NET memory management requirements/gotchas HOT 3
- how to use third party js library? HOT 3
- Debugger (Local window) crashes when JavaScriptPropertyId is a local variable
- Enable beta features HOT 2
- Multi-thread code samples request HOT 6
- Any plan to support OSX in "JSRT Hosting Samples" HOT 1
- Linux_OSX_Shared/Sample.cpp Build Error HOT 4
- Unable to run the sample app in Linux HOT 4
- Updated helloWorld.py HOT 3
- C# Sample Updates HOT 3
- Generate a Class and Instance in C# HOT 1
- Q: TypeScript ? is it possible HOT 3
- Reuse parsing result HOT 1
- JsProjectWinrtNamespace sample not working in UWP Library
- Need help with C# Native.JsRunScript and async
- Linux/MacOS create function with return sample
- Move CharkaCore samples to chakra-core org
- This repo is missing important files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chakra-samples.