From 8ebf3d637a1502dc4023f84894aaaedf1963fb36 Mon Sep 17 00:00:00 2001 From: ejt1 Date: Sun, 11 Feb 2024 06:47:33 +0100 Subject: [PATCH] fix: interrupting script breaks kolbot --- src/Spidermonkey Engine/Engine/Script.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Spidermonkey Engine/Engine/Script.cpp b/src/Spidermonkey Engine/Engine/Script.cpp index f750b218..86edd190 100644 --- a/src/Spidermonkey Engine/Engine/Script.cpp +++ b/src/Spidermonkey Engine/Engine/Script.cpp @@ -833,11 +833,15 @@ bool Script::ProcessAllEvents() { // return != 0 if the JS code needs to be interrupted int Script::InterruptHandler(JSRuntime* rt, void* /*opaque*/) { ThreadState* ts = (ThreadState*)JS_GetRuntimeOpaque(rt); + Script* script = ts->script; - auto t = std::chrono::steady_clock::now() - ts->lastSpinTime; - auto tms = std::chrono::duration_cast(t); - if (tms.count() > 5000) { - // interrupt the script if it stalls for more than 5 seconds without yielding to event loop + //auto t = std::chrono::steady_clock::now() - ts->lastSpinTime; + //auto tms = std::chrono::duration_cast(t); + //if (tms.count() > 5000) { + // // interrupt the script if it stalls for more than 5 seconds without yielding to event loop + // return 1; + //} + if (!script->RunEventLoop()) { return 1; } return 0;