From 7db7b125f87716a1a35660f9dd6797efd306481a Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 28 Mar 2024 11:42:17 +0800 Subject: [PATCH] fixed #16831: Error information is printed forever if there is an error is triggered in timer callback (#16833) --- cocos/core/global-exports.ts | 2 +- native/cocos/cocos-version.h | 6 +++--- package-lock.json | 4 ++-- package.json | 2 +- platforms/native/builtin/index.js | 14 +++++++++----- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cocos/core/global-exports.ts b/cocos/core/global-exports.ts index 93ce23ac85..0e59bf5bd6 100644 --- a/cocos/core/global-exports.ts +++ b/cocos/core/global-exports.ts @@ -46,7 +46,7 @@ if (DEV) { legacyCC._Test = {}; } -const engineVersion = '3.8.3'; +const engineVersion = '3.8.4'; /** * @en diff --git a/native/cocos/cocos-version.h b/native/cocos/cocos-version.h index 8a1ceeda5f..ca71277b85 100644 --- a/native/cocos/cocos-version.h +++ b/native/cocos/cocos-version.h @@ -25,9 +25,9 @@ THE SOFTWARE. #define COCOS_MAJOR_VERSION 3 #define COCOS_MINJOR_VERSION 8 -#define COCOS_PATCH_VERSION 3 -#define COCOS_VERSION_STRING "3.8.3" +#define COCOS_PATCH_VERSION 4 +#define COCOS_VERSION_STRING "3.8.4" #define COCOS_VERSION_DEFINED 1 -#define COCOS_VERSION 30803 +#define COCOS_VERSION 30804 // #define COCOS_PRE_RELEASE "release" diff --git a/package-lock.json b/package-lock.json index d098f109b4..10d25013d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cocos-creator", - "version": "3.8.3", + "version": "3.8.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cocos-creator", - "version": "3.8.3", + "version": "3.8.4", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 7093f8efed..efa82eab7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cocos-creator", - "version": "3.8.3", + "version": "3.8.4", "description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.", "homepage": "http://www.cocos.com", "license": "MIT", diff --git a/platforms/native/builtin/index.js b/platforms/native/builtin/index.js index 386245ac49..81f991398a 100644 --- a/platforms/native/builtin/index.js +++ b/platforms/native/builtin/index.js @@ -82,16 +82,20 @@ function fireTimeout (nowMilliSeconds) { if (info && info.cb) { if ((nowMilliSeconds - info.start) >= info.delay) { // console.log(`fireTimeout: id ${id}, start: ${info.start}, delay: ${info.delay}, now: ${nowMilliSeconds}`); + if (info.isRepeat) { + info.start = nowMilliSeconds; + } else { + // The delete operation should be performed before the timeout callback. + // This is because if an error occurs during the timeout callback, + // it could be triggered indefinitely, leading to a game freeze. + delete _timeoutInfos[id]; + } + if (typeof info.cb === 'string') { Function(info.cb)(); } else if (typeof info.cb === 'function') { info.cb.apply(info.target, info.args); } - if (info.isRepeat) { - info.start = nowMilliSeconds; - } else { - delete _timeoutInfos[id]; - } } } }