Code Monkey home page Code Monkey logo

Comments (13)

globeport avatar globeport commented on May 16, 2024

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.

globeport avatar globeport commented on May 16, 2024

Yep I can replicate this with the UWP example.

Steps:

  1. Add a WebView control to MainPage.xaml
  2. 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();
        }
    }
  1. Change debugger type in project settings to Application Process: 'Managed Only'
  2. 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.

obastemur avatar obastemur commented on May 16, 2024

Error is normal since WebView also creates the Runtime.

from chakra-samples.

globeport avatar globeport commented on May 16, 2024

OK so two runtimes. But they don't operate in isolation?

from chakra-samples.

obastemur avatar obastemur commented on May 16, 2024

One runtime, multiple context ?

from chakra-samples.

globeport avatar globeport commented on May 16, 2024

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.

obastemur avatar obastemur commented on May 16, 2024

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.

globeport avatar globeport commented on May 16, 2024

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.

obastemur avatar obastemur commented on May 16, 2024

Great. Please share your experiences back. It may help others :) Keeping this open for a while then.

from chakra-samples.

globeport avatar globeport commented on May 16, 2024

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.

obastemur avatar obastemur commented on May 16, 2024

/cc @munyirik ?

from chakra-samples.

globeport avatar globeport commented on May 16, 2024

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

  1. Run the WebView on a separate thread ( some limitations)

  2. 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.

obastemur avatar obastemur commented on May 16, 2024

Perfect!

from chakra-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.