Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling reset before a Javascript method returns causes a crash. #99

Closed
lanephillips opened this issue Aug 14, 2014 · 2 comments
Closed

Comments

@lanephillips
Copy link

Here's the scenario:

  1. Objective-C code calls callHandler:data:responseCallback: on WebViewJavascriptBridge.
  2. WebViewJavascriptBridge puts the callback in a dictionary with key objc_cb_1.
  3. Objective-C code calls reset on the bridge.
  4. WebViewJavascriptBridge sets its callback counter back to 0 and clears the callback dictionary.
  5. Objective-C code calls callHandler:data:responseCallback: on WebViewJavascriptBridge.
  6. WebViewJavascriptBridge puts the callback in a dictionary with key objc_cb_1.
  7. The javascript function named in step 1 finishes. (My understanding of how WebViewJavascriptBridge works on the javascript side may be a bit fuzzy, but I'm pretty confident about the Objective-C side.)
  8. WebViewJavascriptBridge looks up the callback with key objc_cb_1 (which is actually the callback from step 5), calls it, and removes it from the dictionary.
  9. The javascript function named in step 5 finishes.
  10. WebViewJavascriptBridge looks up the callback with key objc_cb_1, finds a nil pointer and calls it and crashes the app.

Our workaround has been to simply build a new bridge instead of trying to reset an existing one, and that seems to work fine for us.

@marcuswestin
Copy link
Owner

Good call. I will review whether reset makes sense to keep around, and if not I'll mark it as deprecated.

I love the thoroughness of your bug report. Thanks for that!
-- while mobile

On Thu, Aug 14, 2014 at 10:37 AM, milkllc notifications@github.com
wrote:

Here's the scenario:

  1. Objective-C code calls callHandler:data:responseCallback: on WebViewJavascriptBridge.
  2. WebViewJavascriptBridge puts the callback in a dictionary with key objc_cb_1.
  3. Objective-C code calls reset on the bridge.
  4. WebViewJavascriptBridge sets its callback counter back to 0 and clears the callback dictionary.
  5. Objective-C code calls callHandler:data:responseCallback: on WebViewJavascriptBridge.
  6. WebViewJavascriptBridge puts the callback in a dictionary with key objc_cb_1.
  7. The javascript function named in step 1 finishes. (My understanding of how WebViewJavascriptBridge works on the javascript side may be a bit fuzzy, but I'm pretty confident about the Objective-C side.)
  8. WebViewJavascriptBridge looks up the callback with key objc_cb_1 (which is actually the callback from step 5), calls it, and removes it from the dictionary.
  9. The javascript function named in step 5 finishes.
  10. WebViewJavascriptBridge looks up the callback with key objc_cb_1, finds a nil pointer and calls it and crashes the app.

Our workaround has been to simply build a new bridge instead of trying to reset an existing one, and that seems to work fine for us.

Reply to this email directly or view it on GitHub:
#99

marcuswestin added a commit that referenced this issue Aug 27, 2014
@marcuswestin
Copy link
Owner

Alright, done. Thanks mate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants