Fix bad isolate being retrieved when callback are called from unity-scopes-js
Bug #1476406 reported by
Alexandre Abreu
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
unity-js-scopes |
Fix Released
|
Critical
|
Alexandre Abreu |
Bug Description
When callbacks are called from unity-scopes api to js, the isolate that are tied to the various js callbacks are not accessible (GetCurrent() is TLS based),
Related branches
lp:~webapps/unity-js-scopes/lp-1476406
- WebApps: Pending requested
-
Diff: 481 lines (+117/-73)15 files modifiedCMakeLists.txt (+10/-8)
deps/build.sh (+1/-1)
examples/simple/simple.ini (+2/-0)
examples/simple/simple.js (+1/-1)
src/bindings/index.js (+4/-0)
src/bindings/src/addon.cc (+17/-0)
src/bindings/src/canned-query.h (+1/-1)
src/bindings/src/scope-base.cc (+33/-29)
src/bindings/src/scope-base.h (+1/-0)
src/bindings/src/scope.cc (+28/-21)
src/bindings/src/scope.h (+1/-0)
src/bindings/src/search-query.cc (+11/-12)
src/bindings/src/search-query.h (+1/-0)
src/launcher/CMakeLists.txt (+5/-0)
src/launcher/main.cc (+1/-0)
lp:~marcustomlinson/v8-cpp/async-callbacks
- Marcus Tomlinson: Pending requested
-
Diff: 90 lines (+64/-1)3 files modifiedsrc/internal/require.h (+1/-1)
src/locker.h (+62/-0)
src/v8-cpp.h (+1/-0)
Changed in unity-js-scopes: | |
importance: | Undecided → Critical |
status: | New → In Progress |
assignee: | nobody → Alexandre Abreu (abreu-alexandre) |
Changed in v8-cpp: | |
assignee: | nobody → Marcus Tomlinson (marcustomlinson) |
status: | New → Fix Committed |
importance: | Undecided → Critical |
Changed in unity-js-scopes: | |
status: | In Progress → Fix Committed |
Changed in unity-js-scopes: | |
status: | Fix Committed → Fix Released |
Changed in v8-cpp: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Unfortunately thats not the extent of the issue. If you want the correct isolate available you can simply create the binding class (E.g. ScopeBase) with the isolate as a constructor parameter from addon.cc. However, having a valid isolate is still not good enough. You can't call a V8 function from a non-V8 thread.
What we need to do is enter a "scopes.listen()" function of sorts as the last executed call of the scope's script. This function needs to take the V8 mainloop into a state where we listen for events. Events such as search, preview, etc. then we can react to these events by executing the callbacks from within V8.
This seems to be the norm in the V8 world. I think a good example of this is the node http lib.
E.g.
var http = require('http');
var s = http.createServ er(function( req, res) (200, { 'content-type': 'text/plain' });
{
res.writeHead
res.end('Hello there\n');
});
s.listen(1000);