chakra-core / chakra-core/ChakraCore

JsStartDebugging on mutliple contexts (vs runtime) clarification

Open
#6,740 2 comments 0 reactions 0 assignees View on GitHub
Question
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hello!
I'm using chakraRT (in windows), but I also sometimes use chakracore in osx and linux (as well as jscore, both ios/osx natively and the open source one)

I've recently re-enabled `JsStartDebugging()` and hurrah! visual studio 2017 now shows code! (It used to just show when there was an exception, but no source, debugging, no idea what made it start working)

I've also implemented modules, via multiple contexts (in jscore and chakra). It all seems to be working fine, except I can only enable debugging for my first script....
Subsequent calls to `JsStartDebugging()` when creating my new context (which is during script execution of the parent-context) returns `JsErrorRuntimeInUse`.
I've read on another issue, that's because a script is currently being executed... but I'm on a different current context (same vm), so should I really see the error?
Does it need to be called outside of any script execution in the VM?
the headers say `Starts debugging in the current context.` so I assume that's correct that debugging needs enabling per-context, not per-vm?

My flow;
`Create VM`
`Create ContextA`
- `Set ContextA active`
- `Enable debugging (success)`
- `Set no active context`
`Bootup`
- `Set ContextA active`
- `Execute bootup.s script (imports ImportB.js)`
- - `Create ContextB`
- - `Set ContextB active`
- - `Enable debugging (fails JsErrorRuntimeInUse)`
- - `Execute ImportB.js`
- - `Set ContextA active (popped from stack)`
- - `Continue ContextA/script execution`
- `Bootup.js/ContextA finishes - set no active context`

`Run pending async jobs` (run on their respective contexts)

Visual studio only shows the bootup script in the debugger, so, I guess it is context specific...

I only ask as moving the debugger enabling is slightly awkward (but I can do it), but it does mean it's after the module initialisation, so I'd never be able to debug the actual import (but I can live with that)

But I'm also not sure if I'm setting up debugging correctly for multiple contexts (Info about debugging is extremely rare!)

Side note; if I'm doing multiple contexts incorrectly, do let me know! (should I switch active contexts this way?)
JavascriptCore is threadsafe for JS calls, but not script execution, chakra seems to be similar, and working so far :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.