New issue
Advanced search Search tips

Issue 643606 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug-Regression



Sign in to add a comment

WebView on Android N fails to update/invalidate view correctly

Project Member Reported by sberg...@opera.com, Sep 2 2016

Issue description

Device name: Nexus 5X
Android version: Android N (NRD90M)
WebView version (from system settings -> Apps -> Android System WebView): (Chrome) 52.0.2743.98
Application: Opera Mini
Application version: 18.0.2254.106542

URLs (if applicable): www.google.com

Steps to reproduce:
(1) Launch Opera Mini 18 on Android N (Nexus 5X device with Chrome Stable as WebView impl)
(2) When app is started, go to www.google.com (for example by tapping its Speed dial)
(3) Try to tap search field on Google page
(4) Observe cursor and scroll bar
(5) (optional) start typing text

Expected result: Cursor continues to blink, scroll bar fades out, text is updated as you type

Actual result: Cursor stops blinking, scroll bar never fades out, text is not updated as you type

Additional info:
This does not reproduce on Android M with the same WebView version. Scrolling the page updates the page but as soon as you stop scroll the cursor etc stops updating. We've tried to isolate this into a test case APK but yet to succeed. But to us it looks like it might be something relating to the usage of WebView top margin (which we use to move the view below the address bar) that confuses the invalidation. Also, doesn't seem to reproduce on the N Emulator.


 

Comment 1 by sgu...@chromium.org, Sep 13 2016

Cc: satyavat...@chromium.org boliu@chromium.org
Owner: hush@chromium.org


Comment 2 by boliu@chromium.org, Sep 13 2016

gonna need a repro app, the description by itself isn't really helpful

Comment 3 by sberg...@opera.com, Sep 13 2016

Have you tried the steps? We have no problems reproducing this with those steps and I imagine you have the possibility to enable some more debugging or similar in WebView to dig a little deeper on that end. If you do have troubles reproducing please let us know what you see.

Of course, we are still trying to isolate it into a test app but would be appreciated if you still look into this a little until then.

Comment 4 by hush@chromium.org, Sep 26 2016

Status: Started (was: Unconfirmed)

Comment 5 by hush@chromium.org, Sep 26 2016

I have no idea yet.
Does opera mini have any special code for N only?

Comment 6 by hush@chromium.org, Sep 26 2016

I can reproduce the bug but I don't know what's going on:
Chrome://inspect shows that the texts are typed into the field correctly.
Hierarchyviewer shows the same.
Tracing shows the draw and swap happened.

One thing to note is that if you scroll the page afterwards, the texts are shown. 

sbergner@opera.com: any help will be helpful, like providing us a smaller sample app that reproduces the problem.

Comment 7 by hush@chromium.org, Sep 26 2016

I also enabled "--enable-skia-benchmarking" and I see that LayerTreeHostImpl got the correct frames.

Comment 8 by sberg...@opera.com, Sep 28 2016

> Does opera mini have any special code for N only?
Not in version 18

Still trying to create a test app.

One additional thing to note is that if we put a dummy (but drawing) view behind the WebView area the problem is not seen which further indicates it being some invalidation/draw issue.

Also, enabling the "Show GPU view updates" in Developer options shows a lack of updates when comparing the device (not working) vs. emulator (working). In the emulator the WebView area flashes with every cursor blink, something that does not occur on device.

Comment 9 by sberg...@opera.com, Sep 30 2016

Ok, finally isolated this problem. Turns out that the breaking factor here is if you clear the window background then nothing seem to drive the system to redraw the webview content. Feels like WebView somehow fails to tell the system/windowmgr it needs to redraw as page content changes (animates or text edited or similar). Reproduces with this simple activity:

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final WebView wv = new WebView(this);
        setContentView(wv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        // Avoid overdraw according to http://www.curious-creature.com/2012/12/01/android-performance-case-study/
        // CAUSES BUG: With this WebView will fail to update its cursor/edit fields
        getWindow().setBackgroundDrawable(null);

        final WebSettings settings = wv.getSettings();
        settings.setJavaScriptEnabled(true);
        wv.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }
        });
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                wv.loadUrl("http://www.google.com");
            }
        });
    }
}

Comment 10 by torne@chromium.org, Sep 30 2016

Possibly the same issue as b/31228366 reported internally:

" On the Nexus 6P, running N, the WebView is blank until the app is put into the background (i.e. pressing the square button). When the app is selected and brought to the foreground, the WebView shows the web page. The developer found that this only happens when the Activity has a null windowBackground. Setting the window background to anything other than null, including transparent, causes the web page to be displayed correctly when the app is first launched. "

Sounds very similar.

Comment 11 by hush@chromium.org, Sep 30 2016

yeah.... I think this is the same issue as b/31228366. And it should be a bug in Android N.

Comment 12 by hush@chromium.org, Sep 30 2016

#9:
Thank you sbergner@!

Comment 13 by hush@chromium.org, Oct 21 2016

Cc: tobiasjs@chromium.org
Owner: boliu@chromium.org
Status: Assigned (was: Started)
Bo/Toby:
Could you take a look on this one?

Sign in to add a comment