Skip to content

Commit

Permalink
fix: interrupting script breaks kolbot
Browse files Browse the repository at this point in the history
  • Loading branch information
ejt1 committed Feb 11, 2024
1 parent fd3136d commit 8ebf3d6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Spidermonkey Engine/Engine/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::chrono::milliseconds>(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<std::chrono::milliseconds>(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;
Expand Down

0 comments on commit 8ebf3d6

Please sign in to comment.