-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved API to detect metered or expensive connections #41
Comments
Actually, Google's |
I agree, and wrote about it in some length a while back. The idea of |
React native has |
Then let's open a bug where we discuss how and where this can be exposed. Saying X is not useful because you need Y does not mean X is not useful, it just means you want Y :-)
I think we covered most of those points in: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/tU_Hqqytx8g/Gl3P86AwBAAJ.
Tracing it down to the source:
It's only supported on Android and maps to a simple switch on MOBILE vs WIFI. shrug... |
@igrigorik I think you have to be conscious about the difference between current implementation, and possible future implementations. Yes, currently all implementations are bad, and perfect implementations are not possible. All vendors complain that they can't make any metered/expensive property 100% reliable. However, OTOH Compare site A using:
with B:
Currently both behave the same. However, if 5G or 6G networks become fast and cheap: Site A: screws 5G/6G users. When wifi is very slow (bad signal, conference Wifi), and the OS can detect that (Android tries to, so it's not a fantasy). If that was exposed to the browsers: Site A: unaware, screws lie-fi users If miraculously network providers start exposing data plan metadata (or Google Fi does this themselves for their own network/OS/browser) Site A: unware, bad experience So basically even though today Netinfo.type and |
@igrigorik maybe the title needs to change but this is already the issue where I'm discussing an alternative API, explaining why the current one isn't fit for the purpose. |
Unfortunately shipping ~"we know this doesn't work but we might be able to improve it in the future—fingers crossed, really" doesn't lend itself well to a standards process or intent's to ship. Given this constraint, the best we can do is expose related signals that we can define and allow developers to build own (smarter) models on top. For example, nothing stops the developer from taking wifi vs cellular distinction as a bootstrap signal and then augment that with own logic and feedback from the user — e.g. a video streaming application can prompt the user to confirm conditional on some network type, etc. In fact, that's exactly what React team has done, and I encourage you to build own libraries that can help developers avoid various pitfalls. As far as exposing "metered" signal: in principle I'm all for it, but the underlying implementations on the platforms we care about are just wrapping the exact same logic you can implement in user space with existing API. As such, personally I don't see a lot of value in exposing it as a standalone+first class primitive.. at least as of today. |
I think Netinfo API that is know to be bad and unfixable is even less suited to be shipped. I see the options as:
Improvement of *) for that to actually happen Android OS devs must cooperate with Chrome devs, but difficulty there is not in API design or technology limitations, but Google's product decisions/policies to make that happen.
I disagree, for two reasons:
I do have much more faith in browser vendors getting the algorithm right, once, with access to user settings and system information, than millions of developers re-inventing the model themselves (and sometimes making it buggy, short-sighted or maybe even decent at the time when they built the site, but unable to update it later when new technology becomes available).
I've shown you clear examples known today where the Netinfo.type API is going to backfire, and an abstraction over that API will not. |
Note that previous versions of the NetInfo API included a With connection type, you can create a user setting, "play videos while on cellular data?". This is what mobile apps do that worry about metered data. If there wasn't connection type, and just a bogus |
The problem is that the current implementation only serves visitors directly on cellular and the rest of them are essentially locked out. There are plenty of mifi users. Wimax in Japan is widely used... and metered, while
The implementation would still have to be defined and shared across the browsers to avoid that. |
Implementations don't (usually) get shared among different rendering engines. Specifications do. And specifying
I'd claim that an overly-optimistic-about-its-own-accuracy API, such as Developers would choose to download that oversized video that they normally wouldn't, without making a conscious tradeoff and without asking the user, because the API would lie to them and tell them that it's OK. Now, maybe that broken state will be fixed at some point in the future when all browsers implement smarter heuristics that we currently cannot fathom. Maybe. But it's a pretty big bet. |
I don't understand how abandoning bad heuristics of We know developers assume WiFi is fast/cheap, and cellular is slow/expensive. It's not a choice between: bad heuristics of In the it's a choice between: bad heuristics of |
@pornel the difference is that NetInfo.{type, downlinkMax} allows developers and framework authors to build own implementations that match their expectation, or encode local knowledge - e.g. geography specific rules, user provided feedback, and so on. As such, it enables rapid (developer driven) iteration that's decoupled from the multi-year standards cycle: React team can ship a new version in each release as they iterate on what "isExpensive" means to them. Yes, mistakes will be made in the process, but same is true for every other low level API in the platform. |
Can you give an example what an author can actually do? Can they do better than have a checkbox that sets a cookie that overrides their heuristic? (and users having to do this for each and every website whenever they switch to a network not behaving like a typical wifi/cellular?) If I give feedback that I use a MiFi device, what can they do? If I give feedback that generally I have nearly unlimited cellular, but very expensive roaming, what can they do? Will I have to allow them to track my location? Can a user from India expect a Czech website to encode local knowledge? How can I in UK provide a good heuristic for my visitors from Japan? If my network is generally not expensive, but this month I've exceeded my limit, and now it's expensive, how can sites know that? (Android knows that) OTOH if I told the Chrome team that my network provider made roaming free, would they need a multi-year standards process to change It seems to me that sites are a wrong place to solve this problem. They will always have less information than the browser. Giving feedback to one website is not nearly as effective as giving feedback to one browser vendor. Network characteristics are not a site-specific thing. They're device and time/situation-dependent, so they're best configured per device, in one place, rather than per-website, on every website individually. Users with unusual networks could install browsers encoding local knowledge (I hear Chinese browsers rock at this). They could install browser extensions that flip the switch for all sites. |
They can override their heuristics with user preference. Yes, the application can also request Geolocation to re-prompt the user later if it detects a country change.
You can expose a config flag in your application that users can toggle. Also, Android doesn't really know that.. it only knows it if the user set a threshold, which is very very rare.
It would be significantly longer than a library updating such logic. Also, it's rarely that "clean", more often it'll be a special type of plan, restrictions in certain countries, etc. This type of logic is better handled higher up in the stack. |
This is a thing that both browser and site can do, but browser can do it better (e.g. know difference between actual roaming and free wifi in another country), and once for all sites.
This is a thing that both browser and site can do, but browser can do it better, and once for all sites.
Sites never know that. This means that Android can handle rare cases, sites can't.
The difference is that browsers are generally evergreen, so the code change will reach users faster via the browser, than via sites. With JS libraries I think there's only small portion of sites that use similar evergreen dependency update process. I'd expect majority of sites to update libraries ad-hoc, if ever. e.g. A major website I'm familiar with will launch a new section next month that uses jQuery 1.0.1. |
@pornel I think we're going in circles.. :) I think the root of our disagreement is: I believe application developers are smart -- yes, they make mistakes, but they are able to fix them too; they are able to fix them faster than browsers are able to ship new versions. As such, I believe the current API provides more flexibility to smart developers to do smart things, and I have faith that they will do so. You may disagree with this position, and if so, then we'll just have to agree to disagree -- this is a subjective argument. Back to the topic of this bug:
|
I don't disagree, but this is not what I'm arguing about. My argument is that, for this particular feature, everything smart site developers can do, smart browser vendors can do just as well or better (and conversely, all the limitations browser vendors face, sites will face too). My other argument is that all major browser vendors keep their browsers updated and generally keep high quality, but this unfortunately is not true in case of all websites. There is a significant portion of sites that are badly written with poor assumptions, and which never get updated. Therefore, if this heuristic is in the browser, it'll be of quality as good as NetInfo allows (or better), and regularly updated for all sites. If it's implemented on sites, it'll be of varying quality, sometimes very bad quality, and quite often out of date, even for decades. This is not a hypothetical speculation — this keeps happening with every web API. If we only had to deal with "smart developers" who know what they're doing and keep their sites updated, "webcompat" wouldn't be a pain. For example it was quicker for IE and Firefox to add support for So it's quite reasonable to expect that if heuristic around Netinfo API will need to be updated, it'll be quicker for all browser vendors to make this API lie, than for all sites to update their heuristic. |
No, we can't. As a developer I can come up with any number of heuristics that leverage local context + user feedback and iterate on those rapidly... such heuristics may work for my particular use case, but may not be applicable outside of my region/application. As a browser developer, on the other hand, I need to come up with globally correct defaults.. which is a very different and significantly harder (intractable, as of today) problem. |
I agree that updating versioned libraries deployed over many sites is hard. At the same time, one can envision a service (not unlike https://polyfill.io/) which provides a single URL and provides JS code that wraps around current netinfo, heuristics, user input, etc. Such a service can provide evergreen userland code that performs these assumptions on behalf of site developers, and improves them over time. |
Copying from #60:
|
A few thoughts on nomenclature...
The underlying question and primitive seems to be "is connection expensive". For sake of argument, let's say we exposed such boolean, how would the UA implement it without falling into the same false-{positive, negative} traps of For context, we tried to tackle this very problem via Data-plan Info API a few years back, but that didn't get far off the ground: carriers are reluctant to expose such data (for good reasons), billing cycles and accounting are way more complex than we anticipated, and exposing such data carries legal implications -- in short, it didn't go anywhere. Since then, there's been work on a new (scoped down) effort that tries to address some of the above by limiting how/where the data is exposed - see (Google) mobile data plan sharing API; YT is piloting it with a few carriers. Perhaps there's a way to expose those bits to the underlying OS.. not sure what Android team is thinking there. The other gotcha is that this requires explicit one-by-one carrier integration. In short, I'd love to see — and spent a lot of time pursuing plausible routes — a reliable "this connection is expensive" flag to users. However, based on what we have access to today, personally I don't think that's something the UA can deliver with a useful level of accuracy. There are heuristics that can be applied here (e.g. connection properties, country scope, user prefs, etc.), but none of these work reliably across the board and need to be augmented by app developers -- and in order for that to happen, we need to give developers the underlying signals so they can make their own tradeoffs, instead of hiding all of them behind a single boolean they can't trust. In that spirit, I think one concrete improvement we can make here is expose "data saver" preference via JS -- see #42. Right now it's delivered in HTTP headers only. |
Here's the thing that confuses me: if we think the UA can't reliably figure out anything here, why do we think app developers will be able to? The latter seems to be the fundamental assumption behind the "just expose all the information to app developers and throw our hands up in the air"... (And that's assuming they had access to the same information to start with... in practice, the UA has the option of taking use prefs into account but the proposed API doesn't expose such prefs to app developers.) If we posit that people will create imperfect heuristics on top of the information we have for now, and we will then try to improve the setup, which is more likely to get updated to a new and improved setup: uas or apps? |
It's not the UA "can't figure out anything", and more that the underlying complexity of this space simply does not lend itself to a single attribute that developers are willing to trust at face value -- at least, none of the developers I've talked to at Google and other major properties. Also, each application has own specific rules for how and when to trigger certain features -- e.g. YouTube rules on when to toggle different app modes vs cost tradeoffs are completely different from Google Search, which differ from Twitter (which provides an app-level pref) from.. you get the point. What they want, and need, are lower level signals that allow them to build own logic that accounts for connection properties, UA-level prefs, device prefs, app-level prefs, etc.
Apps. Because they can learn and iterate at several orders of magnitude faster and optimize this process to fit their specific requirements and user + app-level prefs. That said, these efforts are not exclusive.. Case in point, we expose both effectiveType and rtt + downlink attributes to allow for both types of users: those that need lower level signals to meet their product needs, and a higher-level signal that others can use and the UA can improve over time. Similarly, in this case, we can work towards a solution that enables both types of users. |
That's fair. But we're still not exposing all the signals UAs have access to to them. And, honestly, I would not be happy, as a user, with exposing all that to random sites I have no particular relationship with.
Except for all the ones that stop being maintained, yes? What you say may be true of active Google properties, but I think is quite false of the vast majority of websites that just pull in some JS library and leave it at that, never updating either the library or their code.
Where by "users" you mean "authors", yes? |
Me neither. My point is not that we must to expose every low-level signal we can get our hands on. Rather, I just wanted to motivate why we can't abstract all of the complexity of NetInfo behind a single enum or attribute like "isSlow" or "isExpensive". The right answer(s) here are somewhere in the middle: the goal is to identify meaningful signals that have low false positive/negative ratio and have reasonable path for cross-UA and platform adoption, while minimizing overall exposure and bits revealed about the user.
Yep.
I think we can serve both masters here.. |
I think the problem I have is all the folks who think they're "power users" but don't actually maintain their code once it's written... I suspect they vastly outnumber actual "power users". |
@bzbarsky perhaps, but we don't define web platform features by lowest denominator. Based on all the feedback I've seen from teams that expressed interest in this API, they do need lower-level information to implement their use cases. Unwinding the stack.. from my earlier reply (#41 (comment)):
Does that sound reasonable and a step in the right direction? |
We try to define web standards in a way that will not create horrible situations that we have to unwind a few years later. That's not the same thing as "lowest common denominator", but it does mean that normal expected usage of the API should not be a footgun. Exposing a "data saver" boolean makes sense to me, I think. I still think that the various teams who think they need lower-level information will end up misusing it such that a few years down the line we'll have browsers either breaking things or lying to preserve compat... |
Copying from #59:
|
This may have come up before, but could the isConnectionExpensive (or similar) boolean be driven by the UA via the user instead of the network on an opt-in basis. Maybe there could be a confirmation option for a user wherein they can note that specific network connections are metered. Could even happen at the OS level (which may make the most sense) and be a passthrough to the UA. Then it may not be defined in all instances (which is ok) but it could provide better context when it is available. So I'm other words it exists, but is bull by default and is up to the UA & user to determine whether it gets populated. This would also reduce some privacy concerns since it's opt-in and it would bypass the carrier issues altogether. |
That's basically just the compatibility library's fallback implementation for older OS versions. Windows also allows treating a Wifi connection as being metered since Windows 8 I think. |
Google has the right solution: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Save-Data |
Waaw. 7 years later we still can't hide youtube iframes if the visitor is using cellular... |
Let me begin to say that I never contributed to a formal forum so please pardon my mistakes.
What is the purpose of reporting the underlying technology to a website? Technologies come and go and they give the website no useful information at best, and a placebo at worst.
These are the current connection types:
And these are the current motivations: (source)
I only see one theme: cellular is a metered connection.
You can't determine whether a connection is metered by the way the device connects to the internet. Examples:
I read Why not expose if the connection is "metered"?. You're acknowledging the issue and still deciding to put the burden on the developers. OSes and browsers have definitely more data to figure out the type of connection, at least with a better degree of certainty.
"other"/"unknown" users will be left out entirely, possibly because they are using a technology not formally recognized or not-yet standardized, while OSes can definitely know more (with drivers; because of global
metered
switches like in Windows 8+; because the devices and OS are made by the same manufacturer; or because OSes have access to historic data usage)In short, while the current
type
API might be useful for some networking tool, or as a basis for future development, what we really need is ametered
property.A
metered
property could return yes/no/unknown values or, better yet, an indication of (essentially) how much data costs, to avoid putting 200GB-metered connections in the same category as somebody who's running out of their 200MB plan.Edit: As an easy alternative,
metered
could be a user agent-defined 0%-100% likeliness that a connection is metered, where "unknown" would be 50%, "cellular" ~90% and wifi ~10%. Absolute certainty would be reserved for situations where a user option is exposed (like Windows 8+)The text was updated successfully, but these errors were encountered: