Bug 258808

Summary: Initialising many a/v players on Safari is done very inefficiently
Product: WebKit Reporter: Derk-Jan Hartman <hartman.wiki>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: aestes, ap, beidson, eric.carlson, jer.noble, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   

Description Derk-Jan Hartman 2023-07-03 07:01:30 PDT
This was initially noticed on https://en.wikivoyage.org/wiki/Portuguese_phrasebook with Safari 16.5.1

This page has 440 audio players. Even if we disable all JS for this page, this page is incredibly slow to load in Safari (some 20 or so seconds). When loading the same page in FF or Chrome it loads within 3 seconds (even with JS enabled). I have pinpointed this to the initialisation of the audio players on this page.

Analysing the behaviour, it seems that the page uses 1 single callback to initialise the UI for all the players on the page but does so dynamically based on the available space and it seems to do some sort x ** n measuring.

I've filed this under Page loading instead of media, because of the serious effect on the loading phase.
Comment 1 Alexey Proskuryakov 2023-07-03 15:23:02 PDT
Yes, this wikipedia page is very slow to load and to scroll.

It spends half of the time in layout trying to figure out if layers want to composite, and another half in JavaScript code under ensureMediaControls(), notably in a callout to WebCore::jsMediaControlsHostPrototypeFunction_base64StringForIconNameAndType().

I think that I've seen an earlier bug about slowness loading a page with many audio elements, but I cannot find it now.
Comment 2 Radar WebKit Bug Importer 2023-07-05 08:02:10 PDT
<rdar://problem/111786613>