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

Droid: InjectJavascriptAsync can return the result of a different call #116

Open
tossingc opened this issue Jan 18, 2019 · 0 comments
Open

Comments

@tossingc
Copy link

tossingc commented Jan 18, 2019

Describe the bug
InjectJavascriptAsync can return the result of a different call (calls are not synchronized). The problem is that, on Android in FormsWebViewRenderer, there is a shared instance of JavascriptCallbackValue which holds the result that is reused for all calls to InjectJavascriptAsync on that FormsWebView. If two calls to InjectJavascriptAsync are running in parallel, the first result returned from one of the pending invocations will be returned as the result for ALL pending InjectJavascriptAsync invocations.

To Reproduce
Steps to reproduce the behavior:

  1. call InjectJavascriptAsync which delays for 3000ms returns "Invocation1" and assign the Task<string> result to a local variable
  2. call InjectJavascriptAsync which immediately returns "Invocation2" and assign the Task<string> result to a second local variable
  3. await the two Tasks and assign the results to local variables
  4. notice that the result of the Task<string> from the second call to InjectJavascriptAsync gets the result "Invocation1"

Expected behavior
The second call to InjectJavascriptAsync should get the result "Invocation2"

Smartphone (please complete the following information):

  • Device: ANY
  • OS: Android
tossingc added a commit to tossingc/Xam.Plugin.Webview that referenced this issue Jan 18, 2019
…lt of a different call

1. added sample page which tests this behavior
2. [Droid] modified FormsWebViewRenderer to create a new instance of JavascriptValueCallback for each call to InjectJavascriptAsync
tossingc added a commit to tossingc/Xam.Plugin.Webview that referenced this issue Jan 18, 2019
…lt of a different call

1. added sample page which tests this behavior
2. [Droid] modified FormsWebViewRenderer to create a new instance of JavascriptValueCallback for each call to InjectJavascriptAsync
tossingc added a commit to tossingc/Xam.Plugin.Webview that referenced this issue Jan 18, 2019
…vascriptAsync-can-return-the-result-of-a-different-call

Fix #5 - Droid: InjectJavascriptAsync can return the result of a different call

1. added sample page which tests this behavior
2. [Droid] modified FormsWebViewRenderer to create a new instance of JavascriptValueCallback for each call to InjectJavascriptAsync
3. revert previous hacky fix which synchronized every call to InjectJavascriptAsync (will cause performance issues)
fixes #5 (corresponding issue in SKLn-Rad repo is 116 - SKLn-Rad#116)
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

1 participant