Bug 137180

Summary: [iOS] Optimize media controls AirPlay discovery
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: calvaris, commit-queue, dino, glenn, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch. none

Description Eric Carlson 2014-09-27 10:42:21 PDT
The iOS media controls register for AirPlay discovery events to know when to include a target picker in the UI. Putting the hardware into discovery mode uses more battery, so don't do it until we can display inline controls, and stop if the element fails to load.
Comment 1 Eric Carlson 2014-09-27 10:55:22 PDT
Created attachment 238780 [details]
Proposed patch.
Comment 2 Radar WebKit Bug Importer 2014-09-27 10:58:45 PDT
<rdar://problem/18479051>
Comment 3 Darin Adler 2014-09-28 17:26:12 PDT
Comment on attachment 238780 [details]
Proposed patch.

I’d like to understand more about why we always end up listening soon enough with this code. The trickiest bit of code here is the removeEventListeners case; subtle that it’s always OK to not listen there because setControlsType will always be called later.
Comment 4 Eric Carlson 2014-09-29 09:09:43 PDT
(In reply to comment #3)
> (From update of attachment 238780 [details])
> I’d like to understand more about why we always end up listening soon enough with this code. The trickiest bit of code here is the removeEventListeners case; subtle that it’s always OK to not listen there because setControlsType will always be called later.

This works because HTMLMediaElement fires an event every time an event listener is added. This means that if we register an event listener when we are about to display the inline controls, we will always get an event so we can configure the controls correctly.
Comment 5 WebKit Commit Bot 2014-09-29 11:12:22 PDT
Comment on attachment 238780 [details]
Proposed patch.

Clearing flags on attachment: 238780

Committed r174073: <http://trac.webkit.org/changeset/174073>
Comment 6 WebKit Commit Bot 2014-09-29 11:12:26 PDT
All reviewed patches have been landed.  Closing bug.