Fix bad isolate being retrieved when callback are called from unity-scopes-js

Bug #1476406 reported by Alexandre Abreu
6
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

Changed in unity-js-scopes:
importance: Undecided → Critical
status: New → In Progress
assignee: nobody → Alexandre Abreu (abreu-alexandre)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

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.createServer(function(req, res)
{
  res.writeHead(200, { 'content-type': 'text/plain' });
  res.end('Hello there\n');
});

s.listen(1000);

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

Agree (about isolate not being enough), that's what I was saying when talking about v8's heavy use of TLS,

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.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.