diff --git a/src/low_loop.cpp b/src/low_loop.cpp index b1b0743..1baa83b 100644 --- a/src/low_loop.cpp +++ b/src/low_loop.cpp @@ -482,9 +482,16 @@ void low_loop_clear_callback(low_t *low, LowLoopCallback *callback) void low_call_next_tick(duk_context *ctx, int num_args) { low_t *low = duk_get_low_context(ctx); + // Push at the top of the stack - this probably is really slow, but it works duk_require_stack(low->next_tick_ctx, num_args + 2); - duk_xmove_top(low->next_tick_ctx, ctx, num_args + 1); duk_push_int(low->next_tick_ctx, num_args); + duk_insert(low->next_tick_ctx, 0); + + duk_xmove_top(low->next_tick_ctx, ctx, num_args + 1); + for (int i = 0; i < num_args + 1; i++) { + duk_insert(low->next_tick_ctx, 0); + } + }