-
Creator 版本: 3.8.4
-
目标平台: iOS
-
重现方式:场景中点击button向oc发送事件,然后OC向JS发送事件时,报错。按钮一直处于被点击的状态,恢复不了被点击状态。
21:50:09 [DEBUG]: JS: sendRequest…
21:50:09 [DEBUG]: JS: js get call back Charlotte
21:50:09 [DEBUG]: JS: Hello Charlotte I’m K
21:50:09 [ERROR]: [SE_ERROR] (/Applications/Cocos/Creator/3.8.4/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/bindings/jswrapper/v8/Object.cpp, 774): Invoking function (0x3033b85b0) failed!
21:50:09 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.4/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/application/CocosApplication.cpp: line 173
21:50:09 [ERROR]:
TS代码:
// 在start方法中注册的监听
if (NATIVE) {
console.error('is native..');
native.jsbBridgeWrapper.addNativeEventListener("changeLabelContent", (usr: string) => {
console.error('js get call back', usr);
this.changeLabelContent(usr);
});
}
public sendRequest()
{
console.log('sendRequest...');
if (NATIVE) {
native.jsbBridgeWrapper.dispatchEventToNative("requestLabelContent");
} else {
console.error('is not native');
}
}
public changeLabelContent(user: string): void {
console.log("Hello " + user + " I'm K");
this.label!.string = "Hello " + user + " ! I'm K";
}
OC代码
// Objective-C
JsbBridgeWrapper* m = [JsbBridgeWrapper sharedInstance];
OnScriptEventListener requestLabelContent = ^void(NSString* arg){
JsbBridgeWrapper* m = [JsbBridgeWrapper sharedInstance];
[m dispatchEventToScript:@"changeLabelContent" arg:@"Charlotte"];
};
[m addScriptEventListener:@"requestLabelContent" listener:requestLabelContent];
日志
21:50:09 [DEBUG]: JS: sendRequest...
21:50:09 [DEBUG]: JS: js get call back Charlotte
21:50:09 [DEBUG]: JS: Hello Charlotte I'm K
21:50:09 [ERROR]: [SE_ERROR] (/Applications/Cocos/Creator/3.8.4/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/bindings/jswrapper/v8/Object.cpp, 774): Invoking function (0x3033b85b0) failed!
21:50:09 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.4/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/application/CocosApplication.cpp: line 173
21:50:09 [ERROR]:
Uncaught Exception:
- location : src/cocos-js/cc.js:1:377498:
System.register([],(function(t,e){"use strict";return{execute:function(){function i(t,e,i,s,n){var r={};return Object.keys(s).forEach((function(t){r[t]=s[t]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=i.slice().reverse().reduce((function(i,s){return s(t,e,i)||i}),r),n&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(n):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(t,e,r),r=null),r}function s(t,e){const i="undefined"==typeof window?global:window;return void 0===i[t]?i[t]=e:i[t]}t({BitMask:ne,CCClass:ri,Enum:oe,Eventify:sr,WorldNode3DToLocalNodeUI:wr,WorldNode3DToWorldNodeUI:Pr,__checkObsoleteInNamespace__:function(t){return nt||(nt="undefined"==typeof Proxy?{}:new Proxy(t,{get:(t,e,i)=>(st(e),Reflect.get(t,e,i))})),nt},__checkObsolete__:function(t){for(let e of t)st(e)},_resetDebugSetting:x,absMax:Ni,absMaxComponent:Mi,applyMixins:nc,approx:fi,assert:O,assertID:H,assertIsNonNullable:function(){},assertIsTrue:function(){},assertsArrayIndex:re,bezier:Gh,bezierByTime:qh,binarySearch:function(t,e){return aa(t,e,0)},binarySearchBy:function(t,e,i){let s=0,n=t.length-1,r=n>>>1;for(;s<=n;r=s+n>>>1){const a=t[r];if(i(a,e)<0)n=r-1;else{if(!(i(a,e)>0))return r;s=r+1}}return~s},binarySearchEpsilon:aa,ccenum:ce,clamp:gi,clamp01:yi,color:$i,computeRatioByType:JF,createDefaultPipeline:SW,debug:D,debugID:L,deprecateModuleExportedName:it,deserialize:wp,enumerableProps:Li,equals:mi,error:I,errorID:k,find:tE,flattenCodeArray:sc,floatToHalf:Ui,formerlySerializedAs:Pa,fragmentText:FC,getBaselineOffset:function(){return 0},getEnglishWordPartAtFirst:LC,getEnglishWordPartAtLast:BC,getError:V,getPathFromRoot:function(t,e){let i=t,s="";for(;null!==i&&i!==e;)s=`${i.name}/${s}`,i=i.parent;return s.slice(0,-1)},getSerializationMetadata:function(t){return t[Ra]},getSymbolAt:RC,getSymbolCodeAt:wC,getSymbolLength:xC,getWorldTransformUntilRoot:function(t,e,i){for(_s.identity(i);t!==e;)_s.fromRTS(Mz,t.rotation,t.position,t.scale),_s.multiply(i,Mz,i),t=t.parent;return i},halfToFloat:ki,instantiate:AH,inverseLerp:Pi,isCCClassOrFastDefined:ai,isCCObject:Kn,isDisplayStats:j,isEnglishWordPartAtFirst:function(t){return CC.test(t)},isEnglishWordPartAtLast:function(t){return vC.tes...