-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
"RuntimeException: Probable deadlock detected due to WebView API being called on incorrect thread while the UI thread is blocked." #4051
Comments
Hmm, very interesting! I actually saw that error message, even, when looking at Sentry earlier today but didn't think of the plausible connection with that symptom. The timing is puzzling because it doesn't really line up with the rollout of a new version -- the first occurrence was 2020-04-08, and it really takes off starting 2020-04-13, but the majority of our Android users were on 26.25.148 by 2020-04-05, and had moved on to 26.26.149 by 2020-04-12. I wonder if it could be related to a Chrome update. :-/ From the trusty Wikipedia table at [[Google Chrome version history]] and its source here, the update to Chrome 81 for Android was announced 2020-04-07 -- and that graph is a pretty plausible shape for the rollout of a new Chrome version. I seem to have Chrome 81 on my phone, and I haven't observed the #4033 symptom, but of course as reported it's only some of the time. Googling finds this SO question and answer: This feels likely to be an issue in RN, or possibly |
I spent some time this afternoon digging into what's happening here. I haven't fully unraveled it, but here's some notes.
BTW here's that stack trace, for reference here:
public void apply(EditText editText) {
editText.setText(mText);
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
editText.setMinLines(mMinLines);
editText.setMaxLines(mMaxLines);
// ...
PrecomputedText precomputed =
(text instanceof PrecomputedText) ? (PrecomputedText) text : null;
if (type == BufferType.EDITABLE || getKeyListener() != null
|| needEditableForNotification) {
createEditorIfNeeded();
mEditor.forgetUndoRedo();
Editable t = mEditableFactory.newEditable(text);
text = t;
setFilters(t, mFilters);
InputMethodManager imm = getInputMethodManager();
if (imm != null) imm.restartInput(this);
// servedView has changed and it's not editable.
if (!mServedView.onCheckIsTextEditor()) {
maybeCallServedViewChangedLocked(null);
}
@Override
public boolean onCheckIsTextEditor() {
mFactory.startYourEngines(false);
if (checkNeedsPost()) {
return mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
@Override
public Boolean call() {
return onCheckIsTextEditor();
}
});
}
return mAwContents.onCheckIsTextEditor();
}
addTask(task);
try {
return task.get(4, TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
throw new RuntimeException("Probable deadlock detected due to WebView API being called "
+ "on incorrect thread while the UI thread is blocked.",
e);
(cont'd) |
Then,
|
Wow — thanks for this fantastically detailed investigation and writeup, @gnprice.
This sounds like the conclusion; a Chrome update may be combined with another, unknown, factor, to cause #4033, or it might be irrelevant to #4033. |
I had another thought about this in a conversation today with @chrisbobbe: one plausible story which would make this so-relevant-looking commit and its timing not a coincidence is:
If that is what happened, then that would make it pretty likely that Chrome 84 fixes the problem! So, if we ever acquire a way to reproduce the issue -- or if we can get a user who's regularly seeing the issue to try this -- a useful line of investigation would be to upgrade to Chrome 84, which is now in the "dev" channel. See the end of our platform-versions.md for details. AFAICT we don't have any direct evidence that the errors we're seeing are related to
|
An update here: Chrome 83 for Android has been rolling out since 2020-06-08 ("it'll become available on Google Play over the next few weeks"), and Chrome 84 is now in beta. EDIT 2020-06-30: Actually it looks like each of those happened a bit sooner than that: Chrome 83 for Android reached stable on 2020-05-19, and Chrome 84 reached beta on 2020-05-28. The later announcements were for patch releases. (The text of the announcements is pretty misleading about this; now I know, I guess. For future reference here's the feeds for Chrome Beta for Android releases and Chrome [stable] for Android releases.) |
Hi, how do you know this method is related to evaluateJavaScript? In which code does Chrome 84 fix the problem, thank you |
I don't know that this error is related to evaluateJavaScript. I do think it's likely that it's related, for the reasons explained in #4051 (comment) .
The fix in Chrome 84 that I think potentially fixes this issue is the one linked at the top of that comment #4051 (comment). Here's a direct link: @zhuangzhitu Are you using Zulip, and seeing symptoms that you think may be connected to this issue? If so I'd be very interested in hearing more, and in your help trying some things to help debug. Are the symptoms you're seeing similar to #4033, or something else? |
I encountered a similar problem with webView, but this repository is irrelevant, and I wanted to see how I could solve this problem. It all happened with Android 10 system and a lot of crashes occurred, but the local recurrence was not found. Collapse of threads are InputConnectionHandlerThread, I doubt that I don't know where got stuck, causing the message hasn't been scheduling, basic it is stuck a little more than 4 s, 4.09 s, for example, I ask you have no corresponding train of thought? The error stack is:
0
Java. Lang. RuntimeException: Probable deadlock detected due to the WebView API being called on incorrect thread while the UI thread is blocked.
1
The at com.org.chromium.android_webview.WebViewChromiumRunQueue.runBlockingFuture (Zc. Java: 13)
2
At com.org. Webview. Chromium. WebViewChromiumFactoryProvider. RunOnUiThreadBlocking (WebViewChromiumFactoryProvider. Java: 30)
3
At com. org.Webview. Chromium. WebViewChromium. OnCheckIsTextEditor (WebViewChromium. Java: 3)
4
An android. Its. WebView. OnCheckIsTextEditor (WebView. Java: 3058)
5
An android. View. Inputmethod. InputMethodManager. CheckFocusNoStartInput (InputMethodManager. Java: 1909)
6
An android. View. Inputmethod. InputMethodManager. CheckFocus (InputMethodManager. Java: 1871)
7
An android. View. Inputmethod. InputMethodManager. UpdateSelection (InputMethodManager. Java: 2091)
8
The at com.org.chromium.content.browser.input.InputMethodManagerWrapperImpl.updateSelection (ak. Java: 13)
9
The at com.org.chromium.content.browser.input.ImeAdapterImpl.onCurrentModeChanged (ImeAdapterImpl. Java: 29)
onDIPScaleChanged
onDisplayModesChanged
onRotationChanged
onWindowAndroidChanged
updateSelection
10
The at com.org.chromium.content.browser.input.ThreadedInputConnection.updateSelection (Rk Java: 13)
11
The at com.org.chromium.content.browser.input.ThreadedInputConnection.processPendingInputStates (Rk Java: 9)
The access of $000
12
The at com.org.chromium.content.browser.input.ThreadedInputConnection$2.run (Jk. Java: 1)
13
An android. OS. Handler. HandleCallback (Handler. Java: 888)
14
An android. OS. Handler. DispatchMessage (Handler. Java: 100)
15
. An android OS. Stars. Loop (213). Which Java:
16
An android. OS. HandlerThread. Run (HandlerThread. Java: 67)
17
Under Caused by: Java. Util. Concurrent. TimeoutException
18
The at Java. Util. Concurrent. FutureTask. Get (FutureTask. Java: 206)
19
(edited to add <details> wrapper --gnprice) |
Can you provide more analysis? thank you |
@zhuangzhitu It looks like the top few frames of the stack trace you're seeing are the same as ours, from If I understand you right, you've said you can't reproduce the issue you're seeing. We've been unable to reproduce the issue we're seeing too. That does make it harder to debug. If you do manage to reproduce it, or if you're in contact with someone using your app who is regularly seeing your issue, I'd suggest installing (or getting them to install) Chrome 84 from beta, as described at #4033 (comment) . (That comment says the dev channel, but it's now reached the beta channel.) As discussed above, I have a guess that Chrome 84 may fix our issue, and quite possibly yours as well. But it's only a guess -- so if you end up managing to confirm whether it fixes your issue or doesn't fix it, I'll be interested in hearing the result. If that guess is right, then the good news is that within a few weeks Chrome 84 for Android should be released to stable and (almost) all our users will get it. So if we don't manage to confirm before then whether it fixes the issue... then we'll find out then for sure.
I don't think I have any analysis to add that isn't above. I wish you luck in reproducing your issue, or in learning more about it. And whatever we find out about our issue in the future, it's going to wind up on this issue thread, so I think you'll learn about it as a result. |
I spent a lot time trying to fix this problem. Solution is simple, just call: |
@3c133ps3d Very interesting, thanks for the tip! Can you say more (or is there a writeup elsewhere you can point to) about how you discovered that solution, or how you determined that it was a solution for this issue? Meanwhile, Sentry tells us that the rate at which our users were seeing this dropped sharply around 2020-06-27: Meanwhile Chrome 84 for Android rolled out as stable starting 2020-07-14, so almost all our Android users should have it by now. It doesn't appear to have affected the rate of this error. That probably means that the Chrome bugfix I mentioned above at #4051 (comment) is not in fact related. |
We're continuing to see this in Sentry, but now at a low rate where it's affecting many fewer users than it originally did. |
Thank you for detailed tracking. I suffered this issue recently because of conditional(if-else) rendering of Yup, it was an Android Q(10) issue. My WebView use Issue was fixed by removing conditional rendering of webview. Instead I mount a webview and change content of WebView with Screen lifecycle (Issued)
Screen lifecycle (issue gone)
|
(Irrelevant to this repo) For the past week we started seeing this error too in Android 10 devices consistently. What is weird is that in 2 years of working with webview it is the 1st time we see this issue and it happenned started happening out of the blue, since we have not changed our webview's implementation in months.
|
Same issue here. Fatal Exception: java.lang.RuntimeException: Probable deadlock detected due to WebView API being called on incorrect thread while the UI thread is blocked.
at WV.XX.c(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:44)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.h(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:8)
at com.android.webview.chromium.h.a(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:6)
at com.android.webview.chromium.WebViewChromium.onCheckIsTextEditor(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:19)
at android.webkit.WebView.onCheckIsTextEditor(WebView.java:3054)
at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:2494)
at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:2451)
at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:2037)
at android.widget.TextView.setText(TextView.java:6697)
at android.widget.TextView.setText(TextView.java:6630)
at android.widget.EditText.setText(EditText.java:140)
at android.widget.TextView.<init>(TextView.java:1879)
at android.widget.EditText.<init>(EditText.java:106)
at android.widget.EditText.<init>(EditText.java:102)
at android.widget.EditText.<init>(EditText.java:98)
at android.widget.EditText.<init>(EditText.java:94)
at com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText(ReactTextInputShadowNode.java:236)
at com.facebook.react.views.textinput.ReactTextInputShadowNode.setThemedContext(ReactTextInputShadowNode.java:82)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:239)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:419)
at com.facebook.react.uimanager.ReanimatedUIManager.createView(ReanimatedUIManager.java:51)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:919) Caused by java.util.concurrent.TimeoutException:
at java.util.concurrent.FutureTask.get(FutureTask.java:206)
at WV.XX.c(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:25)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.h(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:8)
at com.android.webview.chromium.h.a(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:6)
at com.android.webview.chromium.WebViewChromium.onCheckIsTextEditor(chromium-TrichromeWebViewGoogle6432.aab-stable-609923033:19)
at android.webkit.WebView.onCheckIsTextEditor(WebView.java:3054)
at android.view.inputmethod.InputMethodManager.checkFocusNoStartInput(InputMethodManager.java:2494)
at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:2451)
at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:2037)
at android.widget.TextView.setText(TextView.java:6697)
at android.widget.TextView.setText(TextView.java:6630)
at android.widget.EditText.setText(EditText.java:140)
at android.widget.TextView.<init>(TextView.java:1879)
at android.widget.EditText.<init>(EditText.java:106)
at android.widget.EditText.<init>(EditText.java:102)
at android.widget.EditText.<init>(EditText.java:98)
at android.widget.EditText.<init>(EditText.java:94)
at com.facebook.react.views.textinput.ReactTextInputShadowNode.createInternalEditText(ReactTextInputShadowNode.java:236)
at com.facebook.react.views.textinput.ReactTextInputShadowNode.setThemedContext(ReactTextInputShadowNode.java:82)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:239)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:419)
at com.facebook.react.uimanager.ReanimatedUIManager.createView(ReanimatedUIManager.java:51)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:919) |
Marking P1 because this is new (within the last two weeks) and may (unconfirmed) be a cause of symptoms like #4033 which we've had multiple reports of.
Here's the Sentry link (only accessible to core team members).
Looks like it was first seen on 26.25.148 (GitHub, CZO).
It may be too early to tell, but it looks like an upward trend is developing (screenshot from Sentry):
(The pink dot on the time axis, at left, is first seen; green, on the right, is last seen)
Looks like it may be coming from https://github.com/chromium/chromium/blob/master/android_webview/java/src/org/chromium/android_webview/WebViewChromiumRunQueue.java#L75?
The text was updated successfully, but these errors were encountered: