Support using both the WebView Support Library, and normal android.webkit APIs in the same app/process. |
||||
Issue descriptionAn application could choose to use both the WebView Support Library, and the classic android.webkit APIs (e.g. in the case where the app is using some library that itself uses android.webkit APIs). We should ensure we are supporting this use-case. I would imagine we might have some weird global behaviour / state sharing depending on how we choose to fetch/initiate the WebView classloader to use for the support library. This probably just works as-is as long as we don't do anything funky with the WebView classloader. But we should still look out for any complications here IMO.
,
Jun 23 2017
I think the case in #1 should be ok though? initApplicationContext with the same context is a NOP, and ResourcesContextWrapperFactory will return the same wrapped context, assuming it's passed the same application context. But in general any state (including stuff that's implicit due to global initialization and cleanup) encoded in the glue layer should be treated with suspicion. I wonder if such state should be moved outside of both glue layers, so that it's clear that it's shared?
,
Jun 26 2017
Regarding moving stuff outside of the glue-layer: yeah I think that would be nice, I did file crbug.com/735943 to take a look at that. After thinking a bit more about this: The main classes we are concerned with when it comes to WebView-startup are WebViewChromiumFactoryProvider, and WebViewChromium. Most other classes in the glue-layer are pure adapters. WebViewChromiumFactoryProvider is created (at most) once per application process, and can later be retrieved from WebViewFactory.getProvider(). WebViewChromiumFactoryProvider is essentially the static interface for WebView - this the class we call into when calling static WebView APIs like WebView.clearClientCertPreferences(), or WebView.initSafeBrowsing(). Evertyhing happening within the WebViewChromiumFactoryProvider initialization code should only happen once per process, so we don't want to duplicate this initialization. We do however want access to some of the object created during this initialization, from the support_library_glue. For example the AwBrowserContext. So IMO it makes sense to move most of the code in WebViewChromiumFactoryProvider into its own (probably singleton) class that will keep track of all the lower-layer objects that WebViewChromiumFactoryProvider is currently keeping track of. In this way we can access these process-wide lower-level objects from both the old (frameworks-facing), and the new (support library) glue layer. This would also turn WebViewChromiumFactoryProvider into more of a pure adapter class. WebViewChromium is created once per WebView, i.e. it is the interface through which we implement non-static WebView APIs (e.g. WebView.loadUrl()). It is not entirely clear to me whether we want to put this initialization-code in its own class as well - it seems to be heavily dependent on the targetSdkLevel of the app using WebView, and we might want this to work differently in the support library.
,
Jun 26 2017
Hmm, it would probably have made more sense to post comment #3 to crbug.com/735943 ;). Ah well.
,
Jul 7 2017
,
Jul 7 2017
We probably want a WebView-shell test to ensure we are supporting this use case. I.e. the test would create a normal WebView, and a support library WebView, and then ensure they both can be started and load some URL.
,
Sep 27 2017
,
Apr 2 2018
This is covered by the design of the support library glue - we share code between the support library glue and the webkit glue so that they don't interfere with each other. We should add either a webview shell test or a support library test to ensure at least some APIs do work together as expected - i.e. that getters and setters on WebSettings affect the getters and setters of the corresponding WebSettingsCompat.
,
Jun 14 2018
I think we could implement this test nicely with {get,set}WebViewClient. That should be done when we add the API for WebViewCompat#getWebViewClient ( issue 852920 and http://b/110225598)
Since this is tracked implicitly by those issues, I'm going to close this.
|
||||
►
Sign in to add a comment |
||||
Comment 1 by gsennton@chromium.org
, Jun 23 2017