Page MenuHomeWildfire Games

Fix missing JSAutoRequest before JS_ReportError
Needs ReviewPublic

Authored by elexis on Tue, Sep 3, 3:54 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

It is easy to forget request mode when coding JS from C++, because many calls dont need it and many do need it.
JS_ReportError is one of the calls that do need it but had it missed in various places, this patch fixes that.

Test Plan

Consider whether using ScriptInterface::ReportError would be better. The difference is that its one line shorter when the ScriptInterface is already known, but longer if it has to be derived from the pCxPrivate thing, even slower if that is the case.
There is a TODO in ReportError about pending exceptions not working. Perhaps these JS_ReportError calls should call something about pending exceptions.

Event Timeline

elexis created this revision.Tue, Sep 3, 3:54 PM
Vulcan added a comment.Tue, Sep 3, 3:56 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/63/display/redirect

Vulcan added a comment.Tue, Sep 3, 4:01 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/scripting/EngineScriptConversions.cpp
| 189| »   »   FAIL_VOID("Failed·to·get·Vector3D·constructor");
|    | [MAJOR] CPPCheckBear (unknownMacro):
|    | There is an unknown macro here somewhere. Configuration is required. If STMT is a macro then please configure it.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/572/display/redirect

Stan added a subscriber: Stan.Tue, Sep 3, 4:08 PM

What does JSAutoRequest do exactly ? I didn't find much documentation (I didn't exactly dig deep either)

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals#Garbage_collector
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_BeginRequest

Requests constrain garbage collection. If any thread is in a requests, garbage collection can happen only when that thread calls into the JSAPI. If one thread needs garbage collection, it blocks until each other thread makes a JSAPI call. It is therefore imperative that native code executing within an active request on cx not block, or simply take too long, outside the JSAPI.

Also notice how gcc segfaulted due to one missing AutoRequest previously: #4053, rP18451.

source/ps/scripting/JSInterface_Game.cpp
115

from rP14496