-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
It seems that sometimes, callbacks are ignored. It appears notably when we call multiple times the same interface method in a small gap of time.
This is caused by iframe loading in easyjs-inject.js :
iframe.setAttribute("src", "easy-js:" + obj + ":" + encodeURIComponent(functionName) + argStr);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
This triggers a call to (void)webViewDidStartLoad:(UIWebView *) in EasyJSWebViewProxyDelegate that reinjects again the EasyJS callback handling, resetting the EasyJS.__callbacks variable to an empty array, forgotting any other callbacks in progress.
Solved
Solved by injecting the EasyJS javascript stuff ONLY one time, by checking a boolean variable set to true when the javascript stuff is injected.
In the same method :
if (!_injectJSDone) {
NSString* js = INJECT_JS;
//inject the basic functions first
[webView stringByEvaluatingJavaScriptFromString:js];
//inject the function interface
[webView stringByEvaluatingJavaScriptFromString:injection];
_injectJSDone = YES;
}
Metadata
Metadata
Assignees
Labels
No labels