On Tue, Jun 1, 2010 at 5:05 PM, Stephan Beal <[email protected]> wrote: > Sorry, i obviously didn't read closely enough - i've never _set_ the global > context, so anything i say on the topic is moot. (In fact, i've never used > more than one context per app.)
I think we might actually have thousands of contexts, and are switching contexts constantly. We use JavaScript for defining functions that can be called on our game objects, and each snippet of JavaScript in the definition or instance of a game object is its own context. > i've finally found the code i was looking for: > http://code.google.com/p/v8-juice/source/browse/trunk/src/lib/juice/time.cc > if you'll grep that for "evalFunc" you'll find a note i left to myself about > why that little bastard exists. The reason is because Context::GetCurrent() > was giving me nulls. So i lied earlier - i didn't store the Context handle, > but a handle to the one function from that context's global object which i > needed. Storing the Context should be feasible using that same approach, > though. I think we have a completely different use case. We're not running a single thread that uses V8 and then spawning another short-lived thread that interacts with V8 and then exits (please correct me if that's not what the code you've referenced does). We have two independent threads that start at the time the process begins. Each one of them creates a lot of contexts itself, calls into V8 which calls back into our game in C++, which often calls back into V8. It used to be that we had only a single thread doing what is now in two threads, and we never saw this crash. With the single thread, we still had the thousands of contexts, with the current context being changed often. Now with two threads, it started crashing sporadically, but always the same call stack when it does. Also, I'm never looking up the context directly. This is happening as part of V8 internals. The exposed API function we're actually calling when the crash occurs is v8::Object::GetPropertyNames. matt -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
