Skip to content

Commit 714be8c

Browse files
authored
fix: enable interruption of V8 execution on Debugger.pause command (#378)
1 parent 5e34fec commit 714be8c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

NativeScript/inspector/JsV8InspectorClient.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ StringView Make8BitStringView(const std::string& value) {
142142
dispatch_semaphore_signal(messageArrived_);
143143
});
144144

145+
// Debugger.pause needs to interrupt V8 even if the main thread is busy
146+
// executing JS. RequestInterrupt fires at the next safe bytecode boundary.
147+
auto parsed = json::parse(message, nullptr, false);
148+
if (!parsed.is_discarded() && parsed.contains("method") && parsed["method"] == "Debugger.pause") {
149+
isolate_->RequestInterrupt(
150+
[](Isolate* isolate, void* data) {
151+
auto client = static_cast<JsV8InspectorClient*>(data);
152+
client->session_->schedulePauseOnNextStatement({}, {});
153+
},
154+
this);
155+
}
156+
145157
tns::ExecuteOnMainThread([this, message]() {
146158
dispatch_sync(this->messageLoopQueue_, ^{
147159
// prevent execution if we're already pumping messages

0 commit comments

Comments
 (0)