diff --git a/src/blocks/scratch3_event.js b/src/blocks/scratch3_event.js index ba496a172..6d4eaca8a 100644 --- a/src/blocks/scratch3_event.js +++ b/src/blocks/scratch3_event.js @@ -100,7 +100,17 @@ class Scratch3EventBlocks { const instance = this; const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread)); if (waiting) { - util.yield(); + // If all threads are waiting for the next tick or later yield + // for a tick as well. Otherwise yield until the next loop of + // the threads. + if ( + util.stackFrame.startedThreads + .every(thread => instance.runtime.isWaitingThread(thread)) + ) { + util.yieldTick(); + } else { + util.yield(); + } } } } diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index 4a7994a4a..21599f251 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -409,7 +409,17 @@ class Scratch3LooksBlocks { const instance = this; const waiting = util.stackFrame.startedThreads.some(thread => instance.runtime.isActiveThread(thread)); if (waiting) { - util.yield(); + // If all threads are waiting for the next tick or later yield + // for a tick as well. Otherwise yield until the next loop of + // the threads. + if ( + util.stackFrame.startedThreads + .every(thread => instance.runtime.isWaitingThread(thread)) + ) { + util.yieldTick(); + } else { + util.yield(); + } } }