Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java

Issue 2246833002: Ignore reentrancy for ImeThread triggering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed scope and fixed nits Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnection.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java b/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
index 0b94f2292d9d3e21d0dd19d67d31a1033dd01a64..f81493c3508156b9f4930708f3fe2181b40b8c08 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnectionFactory.java
@@ -36,6 +36,7 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
private ThreadedInputConnectionProxyView mProxyView;
private ThreadedInputConnection mThreadedInputConnection;
private CheckInvalidator mCheckInvalidator;
+ private boolean mReentrantTriggering;
// A small class that can be updated to invalidate the check when there is an external event
// such as window focus loss or view focus loss.
@@ -105,6 +106,14 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
int selectionEnd, EditorInfo outAttrs) {
ImeUtils.checkOnUiThread();
+ // Compute outAttrs early in case we early out to prevent reentrancy. (crbug.com/636197)
+ // TODO(changwan): move this up to ImeAdapter once ReplicaInputConnection is deprecated.
+ ImeUtils.computeEditorInfo(
+ inputType, inputFlags, selectionStart, selectionEnd, outAttrs);
+ if (DEBUG_LOGS) {
+ Log.w(TAG, "initializeAndGet. outAttr: " + ImeUtils.getEditorInfoDebugString(outAttrs));
+ }
+
// IMM can internally ignore subsequent activation requests, e.g., by checking
// mServedConnecting.
if (mCheckInvalidator != null) mCheckInvalidator.invalidate();
@@ -118,14 +127,17 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
if (mThreadedInputConnection == null) {
if (DEBUG_LOGS) Log.w(TAG, "Creating ThreadedInputConnection...");
mThreadedInputConnection = new ThreadedInputConnection(view, imeAdapter, mHandler);
+ } else {
+ mThreadedInputConnection.resetOnUiThread();
}
- mThreadedInputConnection.initializeOutAttrsOnUiThread(inputType, inputFlags,
- selectionStart, selectionEnd, outAttrs);
return mThreadedInputConnection;
}
private void triggerDelayedOnCreateInputConnection(final View view) {
if (DEBUG_LOGS) Log.w(TAG, "triggerDelayedOnCreateInputConnection");
+ // Prevent infinite loop when View methods trigger onCreateInputConnection
+ // on some OEM phones. (crbug.com/636197)
+ if (mReentrantTriggering) return;
// We need to check this before creating invalidator.
if (!view.hasFocus() || !view.hasWindowFocus()) return;
@@ -135,8 +147,10 @@ public class ThreadedInputConnectionFactory implements ChromiumBaseInputConnecti
if (mProxyView == null) {
mProxyView = createProxyView(mHandler, view);
}
+ mReentrantTriggering = true;
// This does not affect view focus of the real views.
mProxyView.requestFocus();
+ mReentrantTriggering = false;
view.getHandler().post(new Runnable() {
@Override
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ThreadedInputConnection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698