reactjs / React.NET

.NET library for JSX compilation and server-side rendering of React components
https://reactjs.net/
MIT License
2.3k stars 932 forks source link

VroomJsInitialisationException: Failed to initialise VroomJs #338

Closed nhannguyen29 closed 5 years ago

nhannguyen29 commented 8 years ago

Hi, I'm using macOS Sierra and ASP.NET Core 1.0 for my website. I encountered this error after adding and configuring React.AspNet 3.0.0 package to my website. Can you help me resolve it? Thank you so much.

Here is the 500 Internal Error I'm getting:

VroomJsInitialisationException: Failed to initialise VroomJs. This is most likely caused by the native library (libVroomJsNative.so) being out of date or your system lacking a compatible version of V8. Please run Mono with the MONO_LOG_LEVEL=debug environment variable for more debugging information, and refer to the ReactJS.NET Mono documentation at http://reactjs.net/guides/mono.html for further debugging hints.

More details: Exception has been thrown by the target of an invocation. ConstructType

TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory ConstructType

TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment ConstructType

Daniel15 commented 8 years ago

I haven't tested on Mac OS for a while, and don't have a Mac to test this out on at the moment. You probably need to compile VroomJs. See https://github.com/pauldotknopf/vroomjs-core for instructions.

nhannguyen29 commented 8 years ago

I tried to follow the instruction on how to set up the VroomJs. However, I encountered this error:

svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ --revision 1501 svn: E170013: Unable to connect to a repository at URL 'http://gyp.googlecode.com/svn/trunk' svn: E160013: '/svn/trunk' path not found Makefile:301: recipe for target 'dependencies' failed make: *\ [dependencies] Error 1

Seems like the issue #289 is the same as mine. In that issue, the poster was able to work around this to run the make native ... command when building v8 but I couldn't. Can you look into this, please? Thank you so much.

fujihara commented 8 years ago

It will not compile to Mac since the repository http://gyp.googlecode.com/svn/trunk is not available anymore and I could not make VroomJs compile with gyp version greater than 3.17.

Is it possible to run on Mac using javascript engine other than v8?

Taritsyn commented 8 years ago

Is it possible to run on Mac using javascript engine other than v8?

@fujihara If you are using a .NET Core, then try to install the following packages: JavaScriptEngineSwitcher.ChakraCore and JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64.

saberone commented 7 years ago

Any news on this? It's not really critical for me, but it makes a demo just that bit cooler if it works on macOS too. ;)

holmesconan commented 7 years ago

After followed the step-by-step instruction on https://github.com/pauldotknopf/vroomjs-core/issues/10, I have successfully built a libVroomJsNative.so, and copy it into /usr/local/lib. That doesn't work. Then I link it to libVroomJsNative.dylib, the application crashed without any information. I have tried to build the React.Core in order to find what happened, the dotnet restore shows many System packages do not have compatible version on osx-10.12-x64. Finally I dropped my attempt. The .net core just release less a year, and the SDK is still in preview stage. We could not expect it to run anywhere.

I don't know if my PR could be merged. It it could, the VroomJS will be skipped on macOS, then using Chakra instead.

luty81 commented 7 years ago

I am facing this issue in Ubuntu 16.04. Is it possible to force React.NET to use another js engine ?

luty81 commented 7 years ago

I managed to change the js engine. Now it works with Chakra and Jint, but now I got another problem. It takes so long to process jsx files. Sometimes it takes about 1 minute in one single jsx. The same code in Windows is processed instantly.

image

As you can see in the print above, it took 47625 ms to process a tiny jsx (0.6 KB)

Any thoughts ?

holmesconan commented 7 years ago

@luty81 how do you managed the JS engine? could you share the code?

I am switching to JavaScriptService which is written by asp.net core team. It is working well on Windows, Linux and macOS.

luty81 commented 7 years ago

@holmescn in Startup.Configure something like this:

            var engineSwitcher = JsEngineSwitcher.Instance;
            engineSwitcher.DefaultEngineName = "Jint";
            engineSwitcher.EngineFactories
                .AddChakraCore()
                .AddJint()
                .AddVroom();

            app.UseReact(config =>
            {
                //
            }

The code above along this fix https://github.com/reactjs/React.NET/pull/359 solves the problem for me in Ubuntu 16.04 LTS

Daniel15 commented 7 years ago

Yeah, manually adding EngineFactories (like @luty81 mentioned above) is the correct method to specify which JS engines to use. ReactJS.NET adds some engine factories by default, but only if you haven't already registered some yourself (see the code at https://github.com/reactjs/React.NET/blob/3ea6f8be627cdc6cf627e588e3dd96a2cb6f1d78/src/React.Core/JavaScriptEngineFactory.cs#L360).

stimms commented 7 years ago

I ran into this tonight on OSX. Thanks to the helpful instructions in this thread and a couple of other places I was able to piece together a working version.

The process is

  1. Install the JavaScriptEngineSwitcher.Jint package
  2. Add the namespaces to Startup.cs

    using JavaScriptEngineSwitcher.Core;
    using JavaScriptEngineSwitcher.ChakraCore;
    using JavaScriptEngineSwitcher.Jint;
  3. In the Configure before the app.UseReact() call include

    var engineSwitcher = JsEngineSwitcher.Instance;
            engineSwitcher.DefaultEngineName = "Jint";
            engineSwitcher.EngineFactories
                .AddJint();

This appears to be sufficient to get everything working, however as @luty81 observed the initial call is very slow. Subsequent calls seem to be fine so it is likely the cost of starting up the JavaScript engine.

Taritsyn commented 7 years ago

This appears to be sufficient to get everything working, however as @luty81 observed the initial call is very slow. Subsequent calls seem to be fine so it is likely the cost of starting up the JavaScript engine.

@stimms, @luty81 Jint is very slow JavaScript engine, because it's written entirely in .NET and works exclusively as interpreter. In your case it is better to use the JavaScriptEngineSwitcher.ChakraCore.

dustinsoftware commented 5 years ago

Closing issues older than a year, please re-open if you think this is still relevant.