Announcement

Collapse
No announcement yet.

Unreal.js

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Chrome inspector enabled!

    Click image for larger version

Name:	CzaVVpFUQAAQliy.jpg
Views:	1
Size:	352.2 KB
ID:	1119968

    Comment


      And React-UMG is open sourced! https://github.com/ncsoft/React-UMG

      Comment


        Unreal.JS is always crashing in cooked build.

        [MENTION=33973]nako_sung[/MENTION], sorry to bother you again, but I tried working around this for a couple of days now, but no matter what I do, it always happens.
        Here is what I do with custom BP GameInstance (although I tried doing purely on C++ side, then with custom actor and JavaScript component, it's always the same result):

        Click image for larger version

Name:	JsGameInstance.png
Views:	1
Size:	82.2 KB
ID:	1120057

        Here is what I get when exiting the game:

        Click image for larger version

Name:	Crash.png
Views:	1
Size:	2.9 KB
ID:	1120058

        Here is what log says:

        Code:
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffff
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: LogWindows:Error: ColonyShipGame.exe!UObjectBaseUtility::IsTemplate()
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: ColonyShipGame.exe!UObjectBaseUtility::IsTemplate()
        LogWindows:Error: ColonyShipGame.exe!UJavascriptIsolate::~UJavascriptIsolate() [c:\work\epic games\projects\colonyshipgame\plugins\unrealjs\source\v8\private\v8implementation.cpp:44]
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: ColonyShipGame.exe!UJavascriptIsolate::~UJavascriptIsolate() [c:\work\epic games\projects\colonyshipgame\plugins\unrealjs\source\v8\private\v8implementation.cpp:44]
        LogWindows:Error: ColonyShipGame.exe!UJavascriptIsolate::`scalar deleting destructor'()
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: ColonyShipGame.exe!UJavascriptIsolate::`scalar deleting destructor'()
        LogWindows:Error: ColonyShipGame.exe!IncrementalPurgeGarbage()
        LogPlayLevel: ColonyShipGame: [2016.12.13-17.54.25:690][316]LogWindows:Error: ColonyShipGame.exe!IncrementalPurgeGarbage()
        LogWindows:Error: ColonyShipGame.exe!StaticExit()
        ...
        Having moved the plugin to project's folder and after adding a breakpoint to ~UJavascriptIsolate(), I can see that the destructor is called twice, which is a reason for the crash. But why does that happen, and why it doesn't happen in PIE is a mystery to me. Perhaps you have an idea.
        Last edited by Flashback; 12-14-2016, 06:08 AM.

        Comment


          Destructor being called during GC doesn't seem normal to me. What about removing all js code and leave empty? If that solves your problem, there must be some GC leakage within your js logic.

          Comment


            Originally posted by nako_sung View Post
            Destructor being called during GC doesn't seem normal to me. What about removing all js code and leave empty? If that solves your problem, there must be some GC leakage within your js logic.
            [MENTION=33973]nako_sung[/MENTION], nope, as I have no JS logic except "5 > 3" passed into RunScript node (belonging to JavascriptContext). This is definitely an issue with plugin's RunScript node and cooked builds - it makes the game crash even with empty project.

            Repro steps:

            1) Create empty project (doesn't matter if C++ and BP), no starter content;
            2) Open Level Blueprint and recreate this simple structure:

            Click image for larger version

Name:	Untitled.png
Views:	1
Size:	87.7 KB
ID:	1120111

            3) Press "Launch" to make cooked build. When it runs, you'll see "true" on screen as a confirmation that "5 > 3" script was evaluated;
            4) Close the window and you'll get a crash.

            ...

            I thought it could be related to wrong parenting, i.e. "Outer" node being linked to level blueprint or game instance parent, but it's not the case. If you do the same with an actor with JavascriptComponent, it still crashes. The only modification you'd have to do is make JavascriptContext field of UJavascriptComponent blueprint-accessible to gain access to RunScript node from component:

            Code:
            UPROPERTY(transient, BlueprintReadOnly)
            UJavascriptContext* JavascriptContext;
            But again, you don't have to do this and the crash is reproducible with unmodified plugin, following repro steps above.

            Comment


              [MENTION=157359]Flashback[/MENTION] Thanks! I just updated to replace destructor with BeginDestroy. https://github.com/ncsoft/Unreal.js-core/commits/master

              Comment


                Nice! I can confirm the crash is gone

                Comment


                  Click image for larger version

Name:	74b4132c-c54e-11e6-97b5-62c7ef7b17a2.png
Views:	1
Size:	134.1 KB
ID:	1120263

                  UMG in action! https://github.com/ncsoft/Unreal.js-demo

                  Comment


                    Is there a way to call Javascript functions directly from Blueprints?

                    Comment


                      Originally posted by Banbury View Post
                      Is there a way to call Javascript functions directly from Blueprints?
                      Function call needs proper function signature which describes types of arguments and return value, so I decided not to support direct call to JS land from BP. Actually you can execute arbitrary 'string -> string' function by calling Context.RunScript("some thing").
                      Last edited by nako_sung; 01-31-2017, 05:33 PM.

                      Comment


                        Sad. A combination of Blueprint and JavaScript I would have found useful. If I have to write the whole thing in JavaScript, I can write it in C++ just as well.

                        What would I have to do, to implement calls to JavaScript from Blueprint? Maybe the signature could be defined with JavaScript decorators or Blueprint parameters.

                        Comment


                          [MENTION=34537]Banbury[/MENTION] As I mentioned earlier, you *can* call JS function from BP like below:

                          in JS
                          global.your_js_fn = (args) => {
                          let [...args] = JSON.parse(args)
                          function your_org_js_fn(x,y,z) {
                          return x + y * z
                          }
                          return JSON.stringify(your_org_js_fn(...args))
                          }

                          In your BP
                          str = FormatString("[{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}]", your-X, your-Y, your-Z, None, None, None, None, None, ...)
                          str_result = Context.RunScript("your_js_fn",str)
                          int_result = ToInteger(str_result)

                          This is quite a slow code-path but it still does its job.

                          Comment


                            I'll try that on the weekend.
                            But your examples always take so much for granted. I don't like to write documentation, either. But I'm trying to piece together how unreal.js works for over a week now, without getting anywhere.

                            But my original question still stands. Is there a way to implement proper Blueprint support and how difficult would it be?

                            Comment


                              Oh I forgot there was FJavascriptFunction which takes UStruct as its function signature for C++ -> JS calls. Though it doesn't support return type.
                              https://github.com/ncsoft/Unreal.js-...tIsolate.h#L47

                              There is an example of custom thunk for taking arbitrary struct type as its argument(https://github.com/EpicGames/UnrealE...xLibrary.h#L55), so I think it is possible to extend FJavascriptFunction to support fast BP -> JS calls.

                              Update -

                              I have updated UJavascriptLibrary::CallJS in https://github.com/ncsoft/Unreal.js-...ca3100c7550338. Currently there can be a crash during destroying FJavascriptFunction property after V8 shutdown.

                              Click image for larger version

Name:	calljs1.png
Views:	1
Size:	110.2 KB
ID:	1122338Click image for larger version

Name:	calljs2.png
Views:	1
Size:	12.0 KB
ID:	1122339
                              Last edited by nako_sung; 01-31-2017, 06:49 PM.

                              Comment


                                I've got the "Run Script" command to work, after I called "Run File" first. Otherwise the function isn't defined. Speed isn't an issue for me right now, so this should work for me.

                                Is there a reason, why the Javascript Component has no "Run Script" function? Or a "Get Context"?

                                Comment

                                Working...
                                X