diff options
author | jdduke <jdduke@chromium.org> | 2014-09-15 13:00:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-15 20:05:11 +0000 |
commit | 1dcbab8b36837b7c43bf18f778d0363fa0af9b8a (patch) | |
tree | 95d7be6f769bc1c924579f105957d51e4b046736 /base | |
parent | 168a50242236a69a58fec9c4ce357d78b121bc55 (diff) | |
download | chromium_src-1dcbab8b36837b7c43bf18f778d0363fa0af9b8a.zip chromium_src-1dcbab8b36837b7c43bf18f778d0363fa0af9b8a.tar.gz chromium_src-1dcbab8b36837b7c43bf18f778d0363fa0af9b8a.tar.bz2 |
Revert of [Android] Mark posted UI thread tasks as asynchronous (patchset #4 id:60001 of https://codereview.chromium.org/512333002/)
Reason for revert:
This patch was purely experimental, and the experiment has expired.
Original issue's description:
> [Android] Mark posted UI thread tasks as asynchronous
>
> Chromium shares a message loop with Android on the browser UI thread.
> This can cause problems when the associated Looper has a sync barrier,
> preventing posted Chromium tasks from being dispatched until the
> barrier is removed. Make this sharing more fair by marking all Chromium
> Message tasks as asynchronous, avoiding stalls when there is a sync
> barrier.
>
> Note: This change is for gathering data about the perf impact and we'll
> revert it before cutting a release branch.
>
> BUG=407149,380781,407133
>
> Committed: https://crrev.com/feabeebb3ac5810f896ac8303a77ee695acaf9d4
> Cr-Commit-Position: refs/heads/master@{#292551}
TBR=aelias@chromium.org,epenner@chromium.org,nyquist@chromium.org,sievers@chromium.org,skyostil@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=407149,380781,407133
Review URL: https://codereview.chromium.org/564373005
Cr-Commit-Position: refs/heads/master@{#294875}
Diffstat (limited to 'base')
-rw-r--r-- | base/android/java/src/org/chromium/base/SystemMessageHandler.java | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/base/android/java/src/org/chromium/base/SystemMessageHandler.java b/base/android/java/src/org/chromium/base/SystemMessageHandler.java index 5f0b3d3..e1fbb0f 100644 --- a/base/android/java/src/org/chromium/base/SystemMessageHandler.java +++ b/base/android/java/src/org/chromium/base/SystemMessageHandler.java @@ -6,43 +6,18 @@ package org.chromium.base; import android.os.Handler; import android.os.Message; -import android.util.Log; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; class SystemMessageHandler extends Handler { - private static final String TAG = "SystemMessageHandler"; - private static final int SCHEDULED_WORK = 1; private static final int DELAYED_SCHEDULED_WORK = 2; - // Reflected API for marking a message as asynchronous. This is a workaround - // to provide *fair* Chromium task dispatch when served by the Android UI - // thread's Looper, avoiding stalls when the Looper has a sync barrier. - // Note: Use of this API is experimental and demonstrative, and is likely - // to be removed in the near future. - private Method mMessageMethodSetAsynchonous; - // Native class pointer set by the constructor of the SharedClient native class. private long mMessagePumpDelegateNative = 0; private long mDelayedScheduledTimeTicks = 0; private SystemMessageHandler(long messagePumpDelegateNative) { mMessagePumpDelegateNative = messagePumpDelegateNative; - - try { - Class<?> messageClass = Class.forName("android.os.Message"); - mMessageMethodSetAsynchonous = messageClass.getMethod( - "setAsynchronous", new Class[]{boolean.class}); - } catch (ClassNotFoundException e) { - Log.e(TAG, "Failed to find android.os.Message class:" + e); - } catch (NoSuchMethodException e) { - Log.e(TAG, "Failed to load Message.setAsynchronous method:" + e); - } catch (RuntimeException e) { - Log.e(TAG, "Exception while loading Message.setAsynchronous method: " + e); - } } @Override @@ -56,7 +31,7 @@ class SystemMessageHandler extends Handler { @SuppressWarnings("unused") @CalledByNative private void scheduleWork() { - sendMessage(obtainAsyncMessage(SCHEDULED_WORK)); + sendEmptyMessage(SCHEDULED_WORK); } @SuppressWarnings("unused") @@ -66,7 +41,7 @@ class SystemMessageHandler extends Handler { removeMessages(DELAYED_SCHEDULED_WORK); } mDelayedScheduledTimeTicks = delayedTimeTicks; - sendMessageDelayed(obtainAsyncMessage(DELAYED_SCHEDULED_WORK), millis); + sendEmptyMessageDelayed(DELAYED_SCHEDULED_WORK, millis); } @SuppressWarnings("unused") @@ -76,28 +51,6 @@ class SystemMessageHandler extends Handler { removeMessages(DELAYED_SCHEDULED_WORK); } - private Message obtainAsyncMessage(int what) { - Message msg = Message.obtain(); - msg.what = what; - if (mMessageMethodSetAsynchonous != null) { - // If invocation fails, assume this is indicative of future - // failures, and avoid log spam by nulling the reflected method. - try { - mMessageMethodSetAsynchonous.invoke(msg, true); - } catch (IllegalAccessException e) { - Log.e(TAG, "Illegal access to asynchronous message creation, disabling."); - mMessageMethodSetAsynchonous = null; - } catch (IllegalArgumentException e) { - Log.e(TAG, "Illegal argument for asynchronous message creation, disabling."); - mMessageMethodSetAsynchonous = null; - } catch (InvocationTargetException e) { - Log.e(TAG, "Invocation exception during asynchronous message creation, disabling."); - mMessageMethodSetAsynchonous = null; - } - } - return msg; - } - @CalledByNative private static SystemMessageHandler create(long messagePumpDelegateNative) { return new SystemMessageHandler(messagePumpDelegateNative); |