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

Issue 1514903002: Move some calls from the Android UI thread to the Chrome one (Closed)

Created:
5 years ago by dgn
Modified:
5 years ago
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Move some calls from the Android UI thread to the Chrome one Some callbacks (from AsyncTasks, broadcasts reciever and other sources) are received on the Android UI thread but the code expects to run on the Chrome UI thread. BUG=568602 TBR=atwilson@chromium.org Committed: https://crrev.com/172f720710be2008df620438736d19224f0ebcc4 Cr-Commit-Position: refs/heads/master@{#364476}

Patch Set 1 #

Patch Set 2 : Add more thread switching #

Patch Set 3 : Remove some AsyncTasks #

Total comments: 2

Patch Set 4 : Pass findbug #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -26 lines) Patch
M android_webview/java/src/org/chromium/android_webview/AwContents.java View 1 1 chunk +6 lines, -1 line 1 comment Download
M android_webview/java/src/org/chromium/android_webview/AwDataReductionProxyManager.java View 1 2 2 chunks +16 lines, -13 lines 0 comments Download
M components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java View 1 2 3 3 chunks +17 lines, -12 lines 0 comments Download
M components/policy/android/java/src/org/chromium/policy/PolicyProvider.java View 1 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (9 generated)
dgn
PTAL
5 years ago (2015-12-10 16:55:10 UTC) #4
Torne
+sgurun who might be familiar with some of the code being changed here.
5 years ago (2015-12-10 17:12:57 UTC) #6
Torne
This looks pretty reasonable for now. Longer-term, we should probably consider implementing a Chromium-specific form ...
5 years ago (2015-12-10 17:55:21 UTC) #7
sgurun-gerrit only
On 2015/12/10 17:55:21, Torne wrote: > This looks pretty reasonable for now. Longer-term, we should ...
5 years ago (2015-12-10 17:56:06 UTC) #8
sgurun-gerrit only
On 2015/12/10 17:56:06, sgurun wrote: > On 2015/12/10 17:55:21, Torne wrote: > > This looks ...
5 years ago (2015-12-10 18:05:10 UTC) #9
sgurun-gerrit only
lgtm https://codereview.chromium.org/1514903002/diff/40001/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java File components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java (right): https://codereview.chromium.org/1514903002/diff/40001/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java#newcode83 components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java:83: new Handler(ThreadUtils.getUiThreadLooper())); that would probably be the only ...
5 years ago (2015-12-10 18:09:50 UTC) #10
sgurun-gerrit only
lgtm
5 years ago (2015-12-10 18:10:02 UTC) #11
Torne
On 2015/12/10 18:09:50, sgurun wrote: > lgtm > > https://codereview.chromium.org/1514903002/diff/40001/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java > File > components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java > ...
5 years ago (2015-12-10 19:00:47 UTC) #12
dgn
https://codereview.chromium.org/1514903002/diff/40001/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java File components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java (right): https://codereview.chromium.org/1514903002/diff/40001/components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java#newcode83 components/policy/android/java/src/org/chromium/policy/AbstractAppRestrictionsProvider.java:83: new Handler(ThreadUtils.getUiThreadLooper())); On 2015/12/10 18:09:50, sgurun wrote: > that ...
5 years ago (2015-12-10 19:52:49 UTC) #13
dgn
Thanks
5 years ago (2015-12-10 19:52:53 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1514903002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1514903002/60001
5 years ago (2015-12-10 19:56:19 UTC) #17
commit-bot: I haz the power
Committed patchset #4 (id:60001)
5 years ago (2015-12-10 21:10:32 UTC) #19
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/172f720710be2008df620438736d19224f0ebcc4 Cr-Commit-Position: refs/heads/master@{#364476}
5 years ago (2015-12-10 21:12:22 UTC) #21
boliu
5 years ago (2015-12-10 22:03:14 UTC) #23
Message was sent while issue was closed.
ahh non-main-UI thread fun..

https://codereview.chromium.org/1514903002/diff/60001/android_webview/java/sr...
File android_webview/java/src/org/chromium/android_webview/AwContents.java
(right):

https://codereview.chromium.org/1514903002/diff/60001/android_webview/java/sr...
android_webview/java/src/org/chromium/android_webview/AwContents.java:643:
ThreadUtils.runOnUiThread(new Runnable() {
I think new code is not wrong, but I kinda want to revert back to old code here:

Webview relies the the trim call to be delivered synchronously. That's why it's
not using MemoryPressureListener here. So new code is not broken since
runOnuiThread is also synchronous if this is the UI thread. But assuming
runOnuiThread behavior is bad imo.

So there are a few cases:
1) all webviews used on a single non-main thread, has activity context, then the
whole activity lives on that thread, and all the trim signals also gets
delivered on that thread, so both new and old code are fine
2) all webview used on a single non-main thread, has global application context,
then I guess new code is more correct then old code, but then every access to
app context is not thread safe already, and this is only one of them, so
probably not worth worrying too much (app context affects case 1 too, but let's
not think too hard on that..)
3) webviews used from multiple threads, and then gets merged to a single
chromium UI thread (context doesn't matter), I don't ever see this scenario
being thread safe, since chromium will be access all the view tree on its UI
thread, so again not worth worrying about this case imo

Maybe we should test 1) and crash hard on 2) and 3)?

Other webview owners have thoughts here?

Powered by Google App Engine
This is Rietveld 408576698