Upcoming bug in Android WebView (currently found in Beta) that afectes CN1 apps hosting a BrowserComponent

23 views
Skip to first unread message

Javier Anton

unread,
Mar 13, 2021, 7:30:29 AM3/13/21
to codenameone...@googlegroups.com
Upcoming bug in Android WebView (currently found in Beta) that affects CN1 apps hosting a BrowserComponent

I have filed this issue with Chromium project https://bugs.chromium.org/p/chromium/issues/detail?id=1187828

The bug isn't yet present in stable releases of Android Webview (89.0.4389.69) but has already made its way from Dev and Canary to Beta (90.0.4430.19)

Basically, a CN1 form that contains a BrowserComponent will lose its browsercomponent when shown back. Strangely, it comes back to life if you open a side Sheet and tap on it (see attached, sometimes it requires opening a Sheet multiple times)

I would normally think that this is a problem in my code but I
-Tested extensively
-Verified that the issue only happens when upgrading WebView

Now, I filed the issue with Chromium using the word "Activities" in place of Form even though this isn't very correct as CN1 is a single activity. I did this to make it easier to understand, but please feel free to contribute if you think you can hint at something that will make it easier to solve this

Thanks


Javier
webView bug.mp4

Javier Anton

unread,
Mar 13, 2021, 9:49:46 AM3/13/21
to codenameone...@googlegroups.com
The following code reproduces the bug. As stated above, to reproduce the error the Android System Webview (Beta) version needs to be installed and chosen as primary WebView in Settings. This version will replace the stable release very soon, so time is of the essence

Notice that when navigating back to the previous form, the BrowserComponent is blank on Android (doesn't always happen, might need to try 2 or 3 times to see it). To test, just call testMethod() from anywhere

public void testMethod()
        {
            Form previous = Display.getInstance().getCurrent();
Form welcomeForm = new Form("Test", new BorderLayout());
                BrowserComponent tstBrowser = new BrowserComponent();
                tstBrowser.setURL("https://www.google.com");
                welcomeForm.add(BorderLayout.CENTER,tstBrowser);
                welcomeForm.getToolbar().addMaterialCommandToRightBar("GO_FORWARD", FontImage.MATERIAL_ARROW_FORWARD, ee -> {
                    testMethod2();
                });
                welcomeForm.show();
        }
        public void testMethod2(){
            Form previous = Display.getInstance().getCurrent();
Form welcomeForm = new Form("Test", new BorderLayout());
                welcomeForm.getToolbar().addMaterialCommandToLeftBar("ShowBack", FontImage.MATERIAL_ARROW_BACK, ee -> {
                    previous.showBack();
                });
                welcomeForm.show();
        }

Javier Anton

unread,
Mar 13, 2021, 11:35:26 AM3/13/21
to codenameone...@googlegroups.com
OK, so even though this happens when the Beta version of WebView is installed on Android, it also stops happening if previous.getContentPane().revalidate() is called right after previous.showBack()

Please look into this when you can because it is bound to cause issues. At least now we know that revalidating the content pane gets rid of this

Javier Anton

unread,
Mar 13, 2021, 11:53:05 AM3/13/21
to codenameone...@googlegroups.com
Last msg about this promise :)

So revalidating the contentpane reduces the number of times that the error occurs, but doesn't remove the error always

Also, a tap is required to bring the BrowserComponent back to visible

It looks like, with the new WebView beta update, CN1 isn't able to animate the BrowserComponent back to the center when showing back a form. It looks like it gets stuck on the left side of the screen

Shai Almog

unread,
Mar 13, 2021, 10:02:27 PM3/13/21
to CodenameOne Discussions
Can you file an issue with this information and include a link to install the beta so we can test that?
Thanks!

Javier Anton

unread,
Mar 14, 2021, 6:04:39 AM3/14/21
to codenameone...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/86db9ac2-d1fd-4fe3-98e6-8b63e8508134n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages