diff --git a/src/class/entity.js b/src/class/entity.js index 86b049ef67..842400e99a 100644 --- a/src/class/entity.js +++ b/src/class/entity.js @@ -1067,6 +1067,9 @@ Entry.EntityObject = class EntityObject { * @param {?picture model} pictureModel */ setImage(pictureModel) { + if (!pictureModel) { + return; + } const that = this; delete pictureModel._id; diff --git a/src/playground/code.js b/src/playground/code.js index 3873a83e95..442d2e83eb 100644 --- a/src/playground/code.js +++ b/src/playground/code.js @@ -490,10 +490,16 @@ Entry.Code = class Code { this.destroyView(); } + static waitPauseState = async () => { + while (Entry.engine.isState('pause')) { + await Entry.Utils.sleep(100); + } + }; + static funcAsyncExecute = async (funcCode, funcExecutor, _promises = []) => { await Promise.all(_promises); if (Entry.engine.isState('pause')) { - return this.funcAsyncExecute(funcCode, funcExecutor, _promises); + await this.waitPauseState(); } else if (!Entry.engine.isState('run')) { funcCode.removeExecutor(funcExecutor); return Entry.STATIC.BREAK; @@ -538,7 +544,7 @@ Entry.Code = class Code { static funcValueAsyncExecute = async (funcCode, funcExecutor, _promises = []) => { await Promise.all(_promises); if (Entry.engine.isState('pause')) { - return this.funcValueAsyncExecute(funcCode, funcExecutor, _promises); + await this.waitPauseState(); } else if (!Entry.engine.isState('run')) { funcCode.removeExecutor(funcExecutor); return await this.getAsyncParamsData(funcExecutor.result); diff --git a/src/util/utils.js b/src/util/utils.js index a15c5ca402..b885b039b0 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -2756,7 +2756,9 @@ Entry.Utils.pauseSoundInstances = function () { Entry.Utils.recoverSoundInstances = function () { Entry.soundInstances.getAllValues().forEach((instance) => { instance.paused = false; - instance.sourceNode.playbackRate.value = Entry.playbackRateValue; + if (instance.sourceNode?.playbackRate) { + instance.sourceNode.playbackRate.value = Entry.playbackRateValue; + } }); Entry.bgmInstances.getAllValues().forEach((instance) => { instance.paused = false; @@ -2964,11 +2966,10 @@ Entry.Utils.removeBlockByType2 = function (blockType, callback) { } }; -Entry.Utils.sleep = (time = 0) => { - return new Promise((resolve) => { +Entry.Utils.sleep = (time = 0) => + new Promise((resolve) => { setTimeout(resolve, time); }); -}; Entry.Utils.runAsync = async (func) => { await Entry.Utils.sleep();