New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 785928 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocking:
issue 781754



Sign in to add a comment

How to deal with posting WebViewProvider tasks to the UI thread in the support library glue?

Project Member Reported by gsennton@chromium.org, Nov 16 2017

Issue description

Many methods in WebViewChromium uses one of the following mechanisms:

if (checkNeedsPost()) {
    mFactory.addTask(new Runnable() {
...


or

if (checkNeedsPost()) {
    mFactory.runOnUiThreadBlocking(new Callable<String[]>() {

I'm assuming we should do the same thing in the new glue layer. The question is, should we re-use the existing mechanism for doing so, i.e. WebViewChromiumRunQueue in WebViewChromiumFactoryProvider? If so, maybe we should move that mechanism into a (new) lower layer that can be used by both the old and the new glue layer.



Bo/Torne do you have any thoughts here - do you think we should be using the same queue for scheduling tasks from android.webkit as from the support library?


I think it makes sense to have them on the same queue to preserve call orders between e.g. WebView and WebViewCompat - not preserving that order seems unexpected.



Note: whatever we choose, we should be able to go ahead with the implementation for this without having implemented the rest of the glue layer.
Leaving this as Available for now - we want it for 65, but I don't know when I'll have time to get to it :)
 
Yes, we need the same mechanism for a lot of those if chromium is not yet started [1]. In some of the classes, this is only a postToUiThread, to catch app mistakes--this is not a critical use case (ex. [2]).

> I think it makes sense to have them on the same queue to preserve call orders between e.g. WebView and WebViewCompat - not preserving that order seems unexpected.

Agreed. And duplicating work is a downside too.

[1] https://cs.chromium.org/chromium/src/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java?type=cs&q=f:android_webview/glue/+f:java$+checkneedspost&sq=package:chromium&l=265
[2] https://cs.chromium.org/chromium/src/android_webview/glue/java/src/com/android/webview/chromium/GeolocationPermissionsAdapter.java?type=cs&q=f:android_webview/glue/+f:java$+geo&sq=package:chromium&l=107
So we need to provide the WebViewChromiumRunQueue API to the new glue layer, and also share the instance of WebViewChromiumRunQueue used by WebViewFactoryProvider with the new glue layer objects. I would suggest moving WebViewChromiumRunQueue out of WebViewFactoryProvider into a lower layer (possibly a completely new layer), and then share the WebViewChromiumRunQueue instance used by WebViewFactoryProvider with the new glue layer through some kind of shared object (e.g. named AwSharedState).

Nate, WDYT?

Comment 3 by boliu@chromium.org, Nov 20 2017

> I'm assuming we should do the same thing in the new glue layer.

It sounds like you were considering alternatives, but I don't actually see any. So what alternatives were you considering? Just a separate queue instead?
Yeah, that would be the only alternative I can think of. It sounds like sharing queues makes more sense.
Owner: gsennton@chromium.org
Status: Assigned (was: Available)
Project Member

Comment 6 by bugdroid1@chromium.org, Dec 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a9e3445a05849125d9a68eb9ebc4db845a040df0

commit a9e3445a05849125d9a68eb9ebc4db845a040df0
Author: Gustav Sennton <gsennton@google.com>
Date: Mon Dec 11 19:43:57 2017

Move WebViewChromiumRunQueue into its own class out of the glue layer.

The WebView Support Library glue layer should post tasks to the
WebViewChromiumRunQueue owned by WebViewChromiumFactoryProvider, so that
new glue layer needs access to the WebViewChromiumRunQueue class
definition. Therefore we move that definition out of the existing glue
layer.

BUG= 785928 

Change-Id: I5b4e41baf6bef11d8dd6762372e5a764732ad96f
Reviewed-on: https://chromium-review.googlesource.com/819638
Commit-Queue: Gustav Sennton <gsennton@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523175}
[modify] https://crrev.com/a9e3445a05849125d9a68eb9ebc4db845a040df0/android_webview/BUILD.gn
[modify] https://crrev.com/a9e3445a05849125d9a68eb9ebc4db845a040df0/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
[add] https://crrev.com/a9e3445a05849125d9a68eb9ebc4db845a040df0/android_webview/java/src/org/chromium/android_webview/WebViewChromiumRunQueue.java

Status: Fixed (was: Assigned)

Sign in to add a comment