Skip to content

Centralize media element ownership in PlaybackObserver - #1878

Open
peaBerberian wants to merge 1 commit into
devfrom
misc/playback-observer-media-element-ownership
Open

Centralize media element ownership in PlaybackObserver#1878
peaBerberian wants to merge 1 commit into
devfrom
misc/playback-observer-media-element-ownership

Conversation

@peaBerberian

@peaBerberian peaBerberian commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

I was rebasing all my branches on dev and dived into one of my old PRs, #1754

This PR did two things:

  1. Centralized ownership of the media element inside the PlaybackObserver (instead of handling it directly in the modules that needed it)
  2. Renamed PlaybackObserver to MediaElementMonitor

For a review, (1) was much more interesting than (2).
Yet because the term PlaybackObserver is everywhere in the code, the rename was most of the diff and the interesting centralization part was lost in it.

I decided to split that PR in two. This one is only about (1), while #1754 continues to combine the logic and name change.


Keeping the ownership of the media element in one single place simplified the implementation of multiple PoCs that have since been deprioritized: the preload feature (#1646) and the ""core dump"" feature.

Even without those two features, I still find the work interesting in that only one area would be changed when doing HTMLMediaElement-adjacent work instead of several.

Still not perfect though (re-reading it, formatMediaError could be moved into the PlaybackObserver, and there are remaining calls to getMediaElement that should be removed) - so there's still some work to do on it.

@peaBerberian peaBerberian added proposal This Pull Request or Issue is only a proposal for a change with the expectation of a debate on it Priority: 3 (Low) This issue or PR has a low priority. work-in-progress This Pull Request or issue is not finished yet labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit 1fb923b8736fe2e7db4c5257fdf25a7aa6cc7761 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 24.69ms -> 26.41ms (-1.716ms, z: 2.68344) 34.50ms -> 34.65ms
seeking 221.04ms -> 200.58ms (20.457ms, z: 1.25667) 18.00ms -> 18.15ms
audio-track-reload 30.72ms -> 30.65ms (0.064ms, z: 1.06300) 44.90ms -> 44.70ms
cold loading multithread 51.36ms -> 50.68ms (0.677ms, z: 12.32689) 75.90ms -> 74.55ms
seeking multithread 209.06ms -> 187.85ms (21.214ms, z: 0.11138) 18.60ms -> 18.75ms
audio-track-reload multithread 29.93ms -> 29.93ms (-0.001ms, z: 1.11287) 43.95ms -> 43.80ms
hot loading multithread 20.55ms -> 20.47ms (0.084ms, z: 1.96686) 29.85ms -> 29.70ms

@peaBerberian
peaBerberian force-pushed the misc/playback-observer-media-element-ownership branch from b1c9ca4 to 3ff625f Compare August 7, 2026 14:15
@peaBerberian
peaBerberian force-pushed the dev branch 2 times, most recently from 01b00b9 to 3a8968e Compare August 7, 2026 15:08
@peaBerberian
peaBerberian force-pushed the misc/playback-observer-media-element-ownership branch from 3ff625f to d30da12 Compare August 7, 2026 15:11
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit 0873312ad6ad5608d899a702dc37e473aa9853f7 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 25.11ms -> 26.11ms (-1.002ms, z: 2.03351) 35.25ms -> 35.40ms
seeking 205.42ms -> 210.16ms (-4.738ms, z: 0.67067) 18.45ms -> 18.30ms
audio-track-reload 31.13ms -> 31.06ms (0.069ms, z: 0.63239) 45.60ms -> 45.45ms
cold loading multithread 52.08ms -> 52.55ms (-0.477ms, z: 11.68438) 77.10ms -> 75.45ms
seeking multithread 205.34ms -> 190.78ms (14.559ms, z: 0.89903) 19.05ms -> 19.35ms
audio-track-reload multithread 30.47ms -> 30.28ms (0.194ms, z: 0.58210) 44.45ms -> 44.40ms
hot loading multithread 21.08ms -> 20.90ms (0.181ms, z: 2.47230) 30.75ms -> 30.45ms

@peaBerberian
peaBerberian force-pushed the misc/playback-observer-media-element-ownership branch from d30da12 to 6759a00 Compare August 11, 2026 15:30
@github-actions

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit 92be34f9ed1715caefd88778c5f9e074a84ed7ca with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 25.35ms -> 25.72ms (-0.371ms, z: 2.44751) 35.70ms -> 35.85ms
seeking 187.89ms -> 191.92ms (-4.027ms, z: 0.67857) 18.75ms -> 18.60ms
audio-track-reload 32.33ms -> 32.28ms (0.056ms, z: 0.26793) 47.70ms -> 48.00ms
cold loading multithread 53.60ms -> 52.44ms (1.154ms, z: 16.13092) 78.90ms -> 77.25ms
seeking multithread 91.44ms -> 88.32ms (3.123ms, z: 2.69874) 20.55ms -> 21.00ms
audio-track-reload multithread 31.29ms -> 31.36ms (-0.065ms, z: 0.23517) 45.90ms -> 45.90ms
hot loading multithread 21.21ms -> 21.93ms (-0.711ms, z: 0.99020) 31.05ms -> 30.90ms

@peaBerberian
peaBerberian force-pushed the misc/playback-observer-media-element-ownership branch from 6759a00 to 5610847 Compare September 1, 2026 09:43
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit 2d9f02fd20e8f4d8b9c9535d179992896bf74141 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
loading 36.81ms -> 37.09ms (corrected: 1.947ms, A/A bias: -2.228ms, z: 0.23094) 30.40ms -> 30.30ms (corrected: -0.325ms, A/A bias: 0.000ms, z: 0.84678)
seeking 141.51ms -> 176.59ms (corrected: -85.165ms, A/A bias: 50.088ms, z: 2.43449) 11.50ms -> 11.75ms (corrected: -0.300ms, A/A bias: 0.325ms, z: 1.42894)
audio-track-reload 31.72ms -> 31.59ms (corrected: 0.210ms, A/A bias: -0.076ms, z: 0.58697) 30.40ms -> 30.40ms (corrected: 0.475ms, A/A bias: -0.400ms, z: 1.28942)
loading over active content 23.12ms -> 24.02ms (corrected: -0.949ms, A/A bias: 0.045ms, z: 0.97187) 21.10ms -> 21.85ms (corrected: -2.200ms, A/A bias: 0.050ms, z: 0.97187)
large multi-period manifest 93.76ms -> 94.90ms (corrected: -1.909ms, A/A bias: 0.761ms, z: 0.86603) 84.90ms -> 87.50ms (corrected: -4.375ms, A/A bias: 3.225ms, z: 0.86603)
cold loading multithread 53.73ms -> 52.01ms (corrected: 1.748ms, A/A bias: -0.034ms, z: 2.77128) 51.75ms -> 50.50ms (corrected: 1.175ms, A/A bias: -0.125ms, z: 4.48409)
seeking multithread 193.67ms -> 216.29ms (corrected: 29.733ms, A/A bias: -52.352ms, z: 0.73131) 13.80ms -> 14.10ms (corrected: -0.100ms, A/A bias: -0.100ms, z: 0.12990)
audio-track-reload multithread 30.86ms -> 30.80ms (corrected: 0.003ms, A/A bias: 0.055ms, z: 0.17321) 29.90ms -> 29.85ms (corrected: 0.325ms, A/A bias: -0.075ms, z: 0.76980)
hot loading multithread 21.45ms -> 21.13ms (corrected: 0.168ms, A/A bias: 0.151ms, z: 0.55811) 20.50ms -> 20.30ms (corrected: 0.000ms, A/A bias: 0.000ms, z: 0.47150)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 3 (Low) This issue or PR has a low priority. proposal This Pull Request or Issue is only a proposal for a change with the expectation of a debate on it work-in-progress This Pull Request or issue is not finished yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant