Closed Bug 1272374 Opened 8 years ago Closed 8 years ago

Add UA override for Brightcove-hosted player

Categories

(Web Compatibility :: Site Reports, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED INVALID

People

(Reporter: miketaylr, Assigned: miketaylr)

References

Details

Attachments

(2 files)

      No description provided.
Mike, what are the next steps for spoofing a new UA for Brightcove?

IIUC, we need to choose the new UA string and the domains we should send the new UA to. Anthony suggested that we use the Fennec UA but only change the Android OS version.

Anthony will ask Brightcove for a list of their CDN domains affected.
Flags: needinfo?(miket)
Hey Chris,

The steps are pretty simple:

Step 0. Find the time (My bad...trying to fix some nasty webcompat.com bugs affecting auth'd bug reports right now, I should have time on Friday)
Step 1. Identify the UA string we want, I agree with Anthony we just need to send them the version that they think won't support HLS.
Step 2. Identify the domains we want to spoof on
Step 3. Write a patch against https://dxr.mozilla.org/mozilla-central/source/mobile/android/app/ua-update.json.in.

There's a cron job that checks for updates (daily, I think) against that file and deploys it to the UA override CDN.

The format is a little unintuitive:

"domain": "Search#Replace"
If you don't have a #, it will do a full replacement.

That gets interpreted like so: ua_string.replace(new RegExp("Search", "g"), "Replace")
Flags: needinfo?(miket)
(thx for bug links Adam)

We want to spoof the "new" player that has the "patchCanPlayType" method that looks like:

D.patchCanPlayType=function(){if(u.ANDROID_VERSION>=4){if(!F){F=D.TEST_VID.constructor.prototype.canPlayType}D.TEST_VID.constructor.prototype.canPlayType=function(a){if(a&&G.test(a)){return"maybe"}return
F.call(this,a)}}

(This is because it will lie and say it can "maybe" support m3u8/HLS after they've patched it).

h.supportsNativeHls = function() {
  var a = b.createElement("video");
  if (a && a.canPlayType) {
      return /probably|maybe/i.test(a.canPlayType("application/vnd.apple.mpegurl"))
  }
  return false
}

manchestereveningnews.co.uk:
http://players.brightcove.net/4221396001/4173e39f-74b4-4855-bda0-83de2a6d59a3_default/index.min.js?v=559
babycenter.com:
http://players.brightcove.net/1546279903/NJXn6DZhl_default/index.min.js
lastampa.it (appears to be down right now)
independent.co.uk:
http://players.brightcove.net/624246174001/82f79524-152c-485f-bcb0-09197a216c87_default/index.min.js
a.excite.co.jp:
http://players.brightcove.net/4322430994001/31060188-3f12-456a-8849-bcc8df28a68f_default/index.html?videoId=4903437357001


The following site uses the older Brightcove player (and works in Fennec): 
http://studio1290.com.vip2.535e.blackmesh.com/wolf-gang-back-to-back-studio1290/
That player is hosted on admin.brightcove.com.

So, let's start with a players.brighcove.net spoof.
Haven't verified this yet (because I'm running into weird build errors). Will deal with that on Monday.
> so it dosn't serve HLS

...and fix that typo on Monday as well.
See Also: → 1243304
(In reply to Mike Taylor [:miketaylr] from comment #4)
> Haven't verified this yet (because I'm running into weird build errors).

That turns out to be Bug 1275016. I'd prefer to test my changes locally so hopefully that's fixed soon-ish.
Mike, any updates on the Brightcove UA override? The Android DebugOnly.h build issues (bug 1275016) are now fixed (by me :).
Flags: needinfo?(miket)
We're on the same wavelength -- I'm building a fresh build right now (thx for the bug 1275016 patches, btw). Hopefully just a sanity check then should be ready for review.
Flags: needinfo?(miket)
Attached image Sanity Check
So, the UA override is working as the previous screenshot shows, but when I go to some of the sites linked like http://www.babycenter.com/2_how-to-cut-your-newborns-nails_10405048.bc?scid=mbtw_baby_post6w&pe=MlVGMHpaMXwyMDE2MDQyMA, I'm still getting the MEDIA_ERR_SRC_NOT_SUPPORTED error. Need to take a closer look at the player script to see why.
Before I go too far down this rabbit hole, Hallvord is there any reason you can see why sending a Fennec on Android 2.3.7 UA string to players.brightcove.net would still result in getting sent HLS/m3u8 content? You're pretty familiar with brightcove player code, right?

(Unfortunately in my quick testing, even spoofing as Firefox desktop ends up with some kind of unplayable stream. :/)
Flags: needinfo?(hsteen)
Er, hang on. Is this even possible to spoof at the brightcove CDN player level? The same JS is sent to babycenter.com, for example, and parsed an executed there (which would then be in the context of a regular fennec UA string). 

A domain-level spoof would only work if they sent us different script content per UA string, right?
A UA-level spoof would work if the player detection script ran inside of an IFRAME delivering content from the brightcove servers. That would be a better way to do it for various reasons, and I'm pretty sure I've seen sites do that, but unfortunately these sites all run the Brightcove script directly inside their main page. When the script thus runs in the context of the babycenter.com page you'll have to spoof on that domain.
Flags: needinfo?(hsteen)
So yeah. This is going to have to be a use case we solve with the go faster webcompat add-on. Adding it to my use case/explainer doc.

No point in keeping this open for now.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
That's a bummer. Thanks for investigating this, Hallvord and Mike.
Status: RESOLVED → VERIFIED
Product: Tech Evangelism → Web Compatibility
Component: Mobile → Site Reports
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: