Descriptionandroid_webview: stop leaking Contexts.
We were leaking activity Contexts in ResourcesContextWrapperFactory's
cache of wrapped contexts, because WeakHashMap only references its
*keys* weakly, and the ContextWrapper objects used as values in the
hashmap have a strong reference to the Context being used as a key, so
nothing was ever removed from the map.
Fix this by deleting the cache entirely, as it's not really necessary;
the number of wrapped contexts we create is already bounded to two per
WebView (one for the activity context and one for the application
context), and the objects are very small, so it's not worth the
complexity of trying to avoid lifetime issues while reusing them.
We do still need to ensure that WebViewChromiumFactoryProvider always
uses the same wrapper for the application context, though, since in some
initialisation paths we set the application context more than once and
the underlying code only permits that if the same context object is used
each time.
BUG=473146
Committed: https://crrev.com/33f1cb1b80896a97041e4b87457e4f036d7a7ad9
Cr-Commit-Position: refs/heads/master@{#324425}
Patch Set 1 #
Messages
Total messages: 7 (2 generated)
|