Fennec/User Agent: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 44: Line 44:


We have taken the opportunity to remove the Gecko date entirely (i.e. reduce to "Gecko/0" - as having <u>something</u> after the / is required by the HTTP spec). We have [http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/ warned people we are going to do this], and starting on mobile means less up-front extra breakage (given that we are making other changes at the same time). Doing this in two batches might mean we'd have to re-evangelise sites. Changing this on desktop can happen on an independent schedule (after, or even before).
We have taken the opportunity to remove the Gecko date entirely (i.e. reduce to "Gecko/0" - as having <u>something</u> after the / is required by the HTTP spec). We have [http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/ warned people we are going to do this], and starting on mobile means less up-front extra breakage (given that we are making other changes at the same time). Doing this in two batches might mean we'd have to re-evangelise sites. Changing this on desktop can happen on an independent schedule (after, or even before).
(If "Gecko/version" doesn't gain traction, what about "Gecko" with a version component? It is valid to have product tokens without a version. WebKit doesn't have a slash in its "like Gecko" string, and now seems like a good opportunity to get rid of nonsense strings, not add new ones like "Gecko/0").


==Q&A==
==Q&A==

Revision as of 14:15, 26 January 2012

This is a proposal for what the Firefox Mobile User Agent string should be. We expect it to be vigorously debated, but ask that people base their points on evidence :-)

Summary

Mobile:

 Mozilla/5.0 (Mobile; rv:12.0) Gecko/0 Firefox/12.0

Tablet (touch screen device):

 Mozilla/5.0 (Tablet; rv:12.0) Gecko/0 Firefox/12.0

Netbook (or tablet with attached pointing device, e.g. in a dock):

 Mozilla/5.0 (X11; rv:12.0) Gecko/0 Firefox/12.0  

(Examples are for Firefox 12; clearly, 12.0 would change for later versions.)

Rationale

User Agent strings accumulate cruft, and complex ones lead to server-side parsing which makes all sorts of wrong assumptions about browser capabilities which can't then be fixed on the client-side apart from by adding more cruft. Note what happened when sites started using "Gecko" as a synonym for "standards-compliant"; WebKit browsers still have "like Gecko" stuck in their User Agents. Here's a highly crufty example from current iPads:

 Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10

In addition, variance in the user agent string adds additional bits of entropy which can be used for browser fingerprinting. For this reason, we have done work in Firefox 4 and beyond to try and reduce UA string variance.

So our hope is to provide the shortest UA string possible, encourage good practice in sniffing, avoid giving developers footguns, and (as much as possible) avoid breaking existing working sites. It is not a goal to make sites which are currently broken to work - we don't think playing that game this way leads to a good outcome, and are committed to solving that problem through evangelism and compatibility improvements to our platform. But we want to and must nail down what the string should be, so we can start the work of evangelism without the risk of telling sites things which later turn out to become false.

The string above fits with the user agent for Firefox 4 and above on desktop. (Our proposal is intended to replace what that blog post says about Mobile.) It also fits with the guidelines of the Gecko User Agent String reference for Firefox products.

Fennec/Firefox

We have removed the "Fennec" identifier because we don't want sites to detect that instead of Firefox or "Mobile" or "Tablet". Our market share is currently small enough that we hope we can get away with this without breaking too many sites. Mobile Firefox is Firefox - it's not something else. That's one of its great selling points - you get the same browser engine everywhere. Our UA string should reflect that.

Platform

We have put the "Mobile" and "Tablet" identifiers where the platform identifiers were because that's the logical place for them to go. Anyone sniffing for the string "Mobile" doesn't care where they are. Firefox is not going to match anyone sniffing for "Mobile Safari" wherever we put the word "Mobile" (and sometimes that string isn't present on WebKit anyway, as some Webkit UAs have "Mobile/<ver> Safari"). Mobile Internet Explorer uses "IEMobile". So really, just sniffing for "Mobile" is the way to find all these mobile browsers. (Although iPad also says "Mobile".)

On the tablet side, Opera already calls itself "Opera Tablet" when running on a tablet, so there is also precedent for using that string to identify tablets, and for varying a tablet UA compared to desktop. The iPad identifies itself as an "iPad" instead of a "Macintosh" (clearly, Apple isn't going to use the generic device name).

If the device is not actually a touch tablet, e.g. a netbook, we want a "desktop-like" UA. Saying the platform is "X11", while not always technically correct, is our attempt to balance accuracy, cross-platformness and compatibility with existing desktop sniffing.

Gecko Date

We have taken the opportunity to remove the Gecko date entirely (i.e. reduce to "Gecko/0" - as having something after the / is required by the HTTP spec). We have warned people we are going to do this, and starting on mobile means less up-front extra breakage (given that we are making other changes at the same time). Doing this in two batches might mean we'd have to re-evangelise sites. Changing this on desktop can happen on an independent schedule (after, or even before).

(If "Gecko/version" doesn't gain traction, what about "Gecko" with a version component? It is valid to have product tokens without a version. WebKit doesn't have a slash in its "like Gecko" string, and now seems like a good opportunity to get rid of nonsense strings, not add new ones like "Gecko/0").

Q&A

What happens next?

This is a proposal. We want people to comment on whether our rationale is sound. It would also be useful to get data on whether it breaks a lot of stuff, or fixes a lot of stuff, or has no real effect (which would be a good result, actually).

Do you think this will fix everything?

No. There's a lot of hard evangelism work ahead. But hopefully if we are evangelising while using a UA string with the properties we outline above, it means we'll not have to do another lot of evangelism when B2G ships, or when/if Firefox ships on iOS, or some other development we can't even imagine happens. Part of what we are doing here is trying to make our job easier in the future.

Why "Mobile;" rather than "M;" or something shorter?

IE Mobile already has the string "Mobile" in their UA, as does Mobile Safari. Opera Mobile apparently avoids this string in favour of "Mobi"; however, that's an older product, and if there were problems with it today, we suspect the other two browsers would have seen it. Anyone who wants to include Opera as well can sniff for "Mobi" to catch them all. "Mobile" is also self-documenting.

Recent versions of Android use "Mobile" in the default browser's UA on devices that should be served mobile-optimized content.

Why have a tablet identifier at all? Why not just use the desktop user agent?

Often, given a choice of a "mobile site" vs. a "desktop site", the desktop site is better for a tablet. So we definitely don't want to call tablets "Mobile".

However, it is reasonable for sites to adapt behaviour to tablets as compared to desktops. For example, touch devices have no concept of "mouseover". There's no obvious way to indicate that other than in the UA. Some sites differentiate iPad vs. Mac using UA sniffing, and convincing them to use a mechanism other than UA sniffing would be difficult.

What about the hardware version?

There is a large array of hardware out there on which the platforms which support Firefox Mobile run, and doubtless there will be more in the future. A bug to add specific device information to the User Agent was WONTFIXED. The goal is for Firefox to work the same across all of these. In addition, adding hardware/OS information can have unexpected side effects; e.g. adding "Nokia" for the N900 led to us being served content appropriate for feature phones (non-smartphones).

What about the OS? Why don't you include the string "Android"?

Because Firefox Mobile does not only run on Android, and we would like to discourage sites from sniffing for "Android" to mean "Mobile". B2G will probably not run on Android (in any meaningful sense - exact technology choices TBD yada yada) and so would prefer not to include "Android" in their User Agent; but they will still be running something on a phone which will work very like Firefox on Android. So it should have the same UA. The fewer sites who sniff for particular OSes, the better off we will be.

For tablets, it has been found that including the string "Android" in the UA is actually a disadvantage. Many sites have a "mobile" version and a desktop version. Given that choice, the desktop version is much better for tablets, but when sites see "Android", they take it to mean "Mobile", and send the mobile version.

OS sniffing has some value on the desktop to allow sites to serve the appropriate downloads (Windows/Mac/Linux etc.) to users. As mobile and tablet users get most or all of their software via app stores, this use case does not apply.

The Android UA blogpost talks about including the "Android" string so sites can supply Android-specific features. Of course, it is in their interests for websites to have Android-specific features; but it is not in the interests of the open web.

Open Questions

Gecko Date

There is a question of what should follow the slash - Gecko/0 avoids breaking sites which expect an integer. But a counter-argument suggests we should fail fast and break such sites, because if they do get an integer, they'll treat it like a date - and who knows what they'll make of "0". Other options include "#", "!", "X" and "12.0" (i.e. matching the Gecko version in the rv: string).

Dao: Let's please go with Gecko/12.0 or Gecko/12. (The latter might have less potential to break scripts.) There's no good reason to introduce new junk here and keep confusing people trying to make sense of the UA string. We should also freeze the rv: token and see if we can drop it in a few years time.

Mozilla/5.0

This string has been ever-present in Firefox since the start, and in Chrome and Safari, and in IE since 7.0 (released October 2006) - IE 6 was "Mozilla/4.0", like Netscape Navigator 4.x. However, it's not present at all in Opera's default (non-spoofing) UA. Given this, is anyone still doing any detection at all with this string? If not, could we remove it.

Given that we are Mozilla, there's a strong emotional attachment there. But that may not be enough to outweigh the fewer-bytes-sent argument, if the compatibility impact is weak.

X11

Is using X11 the right balance between desktop compatibility (it's a way of saying "not Windows, not Mac, and not any specific OS, but a desktop machine") and accuracy? Should we just bite the bullet and put "Desktop" in that space?