Hello,Webview team is frequently asked whether there is a mechanism to measure WebView's data consumption. At present WebView does not expose an API for this purpose.Android supports a Traffic Stats API for tagging sockets with some arbitrary tag and then collecting statistics for the given tag (the traffic for tags is visible via adb diagnostics commands or via queryDetailsForUidTag()). When using this, apps set an active tag for the traffic originating from a thread using setThreadStatsTag() and call tagSocket() to tag each socket with the active tag for the current thread. Tags are integers and some range is reserved for platform use (for example for DownloadManager). I am thinking WebView could either use a number from this range or could provide a way to applications to set their own tag.
This API above is in Java but Android team seems to be willing to provide an NDK API and they opened b/29761778 to track this.
We want to understand what Chrome network stack team thinks about it. Specifically, is the current design for Traffic stats reasonable for chrome network stack use or do you want to see any changes? One option that was recommended was changing tagSocket() to always require a tag.
On Tue, Jul 12, 2016 at 3:55 PM, 'Selim Gurun' via net-dev <net...@chromium.org> wrote:Hello,Webview team is frequently asked whether there is a mechanism to measure WebView's data consumption. At present WebView does not expose an API for this purpose.Android supports a Traffic Stats API for tagging sockets with some arbitrary tag and then collecting statistics for the given tag (the traffic for tags is visible via adb diagnostics commands or via queryDetailsForUidTag()). When using this, apps set an active tag for the traffic originating from a thread using setThreadStatsTag() and call tagSocket() to tag each socket with the active tag for the current thread. Tags are integers and some range is reserved for platform use (for example for DownloadManager). I am thinking WebView could either use a number from this range or could provide a way to applications to set their own tag.Having a single tag for WebView seems to be counter to the Android security model of per-app isolation, in that it allows inferrence and analysis based on other applications' activity if they share the same tag.
This API above is in Java but Android team seems to be willing to provide an NDK API and they opened b/29761778 to track this.Note: Public mailing list, internal bug :)We want to understand what Chrome network stack team thinks about it. Specifically, is the current design for Traffic stats reasonable for chrome network stack use or do you want to see any changes? One option that was recommended was changing tagSocket() to always require a tag.Given the security and privacy concerns fundamentally intrinsic to WebView, my understanding was that solutions like Chrome Custom Tabs represented the better, more secure path for users, similar to iOS and the Safari View Controller. Has this view changed?
The reason I ask is such an API is fundamentally incompatible with Chrome Custom Tabs, by more or less intentional design, and has been discussed at length within the Chrome team and Chrome senior leadership. As such, it seems at odds to offer a powerful diagnostic API to users who use WebView, when it fundamentally is problematic for Custom Tabs, as that would seem to create incentives app developers to providing a less than ideal experience to users, via WebView.The networking team has explored, at various times, the tagSocket APIs and use cases, and rejected them every time due to the problem either being ill-defined or the use cases proposed fundamentally unable to be met to being at odds with the web platform. I don't see anything on this thread that changes that conclusion.
I am not aware of any previous work net stack team did. Are there any bugs/threads you can provide.
--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CACvaWvaLNvgOgQnkga_tBn9ViTzoFYYaPmpyKN9iPxGuW%3Doe2g%40mail.gmail.com.
There is similar requests to add traffic tag support to Cronet: https://bugs.chromium.org/p/chromium/issues/detail?id=520198Tagging threads or sockets doesn't seem to match well the network stack which uses one thread, pools sockets and advanced protocols like HTTP/2 and QUIC that multiplex requests over single connection.One possible approach which may work is to tag entire UrlRequestContext with single tag, as it owns all socket pools, etc.In case of Cronet it could be even easier as each CronetEngine owns exactly one UrlRequestContext and associated networking thread.
On Wed, Jul 13, 2016 at 8:42 AM, Misha Efimov <m...@chromium.org> wrote:There is similar requests to add traffic tag support to Cronet: https://bugs.chromium.org/p/chromium/issues/detail?id=520198Tagging threads or sockets doesn't seem to match well the network stack which uses one thread, pools sockets and advanced protocols like HTTP/2 and QUIC that multiplex requests over single connection.One possible approach which may work is to tag entire UrlRequestContext with single tag, as it owns all socket pools, etc.In case of Cronet it could be even easier as each CronetEngine owns exactly one UrlRequestContext and associated networking thread.Right, for Cronet, this could work. The problem with WebView is there exist a variety of URLRequestContexts (or at least, there did). But any change in the process model for WebView, or any sharing of context/state with any other process/use case/application, it doesn't really work well.
I suppose put differently, it could work if everything is in-process and viewed in aggregate (and not trying to be specific). But there's also policy questions about whether that'd be a good thing (again, Web View vs Chrome Plate, feature alignment, etc). I think there's also a question of the use cases trying to be met. I totally understand the argument that it's for debugging, but couldn't that use case be met through other means (such as recording it as device egress)?
I'm hesitant and skeptical, but that's just because we'd need to flesh out more of the use case to explore the SHOULD, and if we SHOULD, then to explore the API of HOW.
WebView actually has only one BrowserContext, which owns the single URLRequestContext.and line 83Perhaps in the long term we can think of having more. but this would probably be a very long term.
--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAA5teAJiSj0UQTX9jht8PiYi9XUeESZG%3DxB8bGsdmSx5-%3DA0Sw%40mail.gmail.com.