diff --git a/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp index f245dea1970..40f7c74572e 100644 --- a/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp @@ -444,6 +444,12 @@ static bool js_CanvasRenderingContext2D_setCanvasBufferUpdatedCallback(se::State se::ScriptEngine::getInstance()->clearException(); } }; + // Add an unroot to avoid the root of the copy constructor caused by the internal reference of Lambda. + if (jsThis.isObject()) + { + jsThis.toObject()->unroot(); + } + jsFunc.toObject()->unroot(); arg0 = lambda; } else