mirror of https://github.com/axmolengine/axmol.git
Merge pull request #12301 from jianglong0156/webviewCrash
fix webview crash in android
This commit is contained in:
commit
9acc51a5eb
|
@ -20,6 +20,9 @@ static bool jsb_cocos2dx_experimental_webView_setOnShouldStartLoading(JSContext
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||||
cobj->setOnShouldStartLoading([=](experimental::ui::WebView *sender, const std::string &url)->bool{
|
cobj->setOnShouldStartLoading([=](experimental::ui::WebView *sender, const std::string &url)->bool{
|
||||||
|
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]
|
||||||
|
{
|
||||||
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
jsval arg[2];
|
jsval arg[2];
|
||||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||||
if(proxy)
|
if(proxy)
|
||||||
|
@ -33,7 +36,7 @@ static bool jsb_cocos2dx_experimental_webView_setOnShouldStartLoading(JSContext
|
||||||
if (!ok && JS_IsExceptionPending(cx)) {
|
if (!ok && JS_IsExceptionPending(cx)) {
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
return true;
|
});
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +53,9 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFinishLoading(JSContext *c
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||||
cobj->setOnDidFinishLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
cobj->setOnDidFinishLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
||||||
|
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]
|
||||||
|
{
|
||||||
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
jsval arg[2];
|
jsval arg[2];
|
||||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||||
if(proxy)
|
if(proxy)
|
||||||
|
@ -64,6 +70,7 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFinishLoading(JSContext *c
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +86,9 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFailLoading(JSContext *cx,
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||||
cobj->setOnDidFailLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
cobj->setOnDidFailLoading([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
||||||
|
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]
|
||||||
|
{
|
||||||
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
jsval arg[2];
|
jsval arg[2];
|
||||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||||
if(proxy)
|
if(proxy)
|
||||||
|
@ -93,6 +103,7 @@ static bool jsb_cocos2dx_experimental_webView_setOnDidFailLoading(JSContext *cx,
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +119,9 @@ static bool jsb_cocos2dx_experimental_webView_setOnJSCallback(JSContext *cx, uin
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, obj, args.get(0)));
|
||||||
cobj->setOnJSCallback([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
cobj->setOnJSCallback([=](experimental::ui::WebView *sender, const std::string &url)->void{
|
||||||
|
Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]
|
||||||
|
{
|
||||||
|
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||||
jsval arg[2];
|
jsval arg[2];
|
||||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||||
if(proxy)
|
if(proxy)
|
||||||
|
@ -122,6 +136,7 @@ static bool jsb_cocos2dx_experimental_webView_setOnJSCallback(JSContext *cx, uin
|
||||||
JS_ReportPendingException(cx);
|
JS_ReportPendingException(cx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue