Skip to content

Upload Media: Video poster test plugin runs a step after the upload - #83334

Draft
swissspidy wants to merge 1 commit into
try/82035-upload-operation-apifrom
try/82035-upload-operation-video-poster
Draft

swissspidy wants to merge 1 commit into
try/82035-upload-operation-apifrom
try/82035-upload-operation-video-poster

Conversation

@swissspidy

Copy link
Copy Markdown
Member

What?

See #82035. Third of the step-3 proofs of concept for the upload operation API: a plugin step that runs after core/upload for videos, reads what the upload produced, and sends a poster frame to its own endpoint.

Stacked on #83331 (which is stacked on #82474); sibling of #83332 and #83333. The diff here is only the test plugin and its spec.

Why?

The proposal named "video sub-sizes and poster generation" as the first real consumer, because it needs addSideloadItem, a pool, and a plan that reacts to what an earlier step produced. Building it from a plain plugin turned up two limits worth deciding on before step 2 is final — see Findings — so this PR is scoped to what a plugin can do today: the poster, the pool, and a step that depends on the upload having happened.

How?

packages/e2e-tests/plugins/upload-operation-video-poster/index.js:

  • registerUploadConcurrencyPool( 'gutenberg-test/video-poster', { limit: 1 } ), and the step joins it, so two videos never decode at once.
  • plan() places the step { after: 'core/upload' } for video/* files. A video's default pipeline is [ core/upload ], so this is the only step after the upload.
  • The handler reads item.attachment.id — present only because the upload step ran first — plays the video muted until requestVideoFrameCallback fires (a recording may have no index to seek by, but always has a first frame), draws it to an OffscreenCanvas, encodes a JPEG, and POSTs it with wp.apiFetch to gutenberg-test/v1/video-poster/<id>, passing context.signal so a cancelled upload aborts the request.

packages/e2e-tests/plugins/upload-operation-video-poster.php registers that endpoint (checks the attachment is a video, wp_handle_upload restricted to JPEG, stores the URL as post meta) and exposes video_poster on attachments.

test/e2e/specs/editor/various/upload-operation-video-poster.spec.js records its own video in the browser — a canvas captured with MediaRecorder for a second — rather than adding a binary fixture, uploads it through the Video block, drains the queue, and asserts the attachment's video_poster ends in -poster.jpg and fetches back as a JPEG (FF D8). A second test checks the operation and its pool through getUploadOperation().

Findings for the API

  1. addSideloadItem cannot carry a plugin's companion file. The sideload endpoint validates image_size against registered sub-sizes plus five fixed tokens (original, scaled, source_original, animated_video, animated_video_poster) with no filter. So a plugin companion has nowhere to land through addSideloadItem, and the proposal's "the server side is the plugin's job" only holds if the plugin also owns the endpoint — which means bypassing addSideloadItem, its parent/child tracking and the core/finalize gate. Either the endpoint gains an extension point for companion names, or addSideloadItem gains a way to target a plugin's endpoint. I'd lean to the former: the parent/child bookkeeping is the valuable part.
  2. A rendition is out of reach for a plain plugin. Nothing outside @wordpress/video-conversion's worker can demux or mux a video (mediabunny is internal to it, and the worker only exports convertGifToVideo). A 720p rendition needs either a generic conversion utility exposed by core or the work in Client-side media: Add video transcoding to web-safe formats #79375. Not an API gap so much as a missing primitive; noting it so the "video sub-sizes" consumer isn't expected of the API alone.

What the plugin could do without friction: a step after the upload that depends on the upload's result, a pool of its own, and context.signal reaching the plugin's own request. That part of the contract holds.

Testing Instructions

npm run test:e2e -- test/e2e/specs/editor/various/upload-operation-video-poster.spec.js

Chromium only (no @webkit tag): the spec relies on MediaRecorder over a canvas stream, and the step on requestVideoFrameCallback. It skips itself where client-side media processing is inactive. I could not run it locally (no Docker in this environment), so CI is the first run; the plugin JS and the spec pass eslint, the PHP passes phpcs.

Testing Instructions for Keyboard

N/A — no UI changes.

Screenshots or screencast

N/A.

Use of AI Tools

Authored with Claude Code: the plugin, the spec and this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sr7G5nRsbso744zkruyGHZ


Generated by Claude Code

An e2e test plugin with a step planned after core/upload for videos: it
reads the attachment ID the upload step produced, plays the video far
enough to render a first frame, draws it to a JPEG and posts it to the
plugin's own endpoint, which keeps it as the video's poster. The step
joins a pool of its own so two videos never decode at once.

The poster does not travel through addSideloadItem: the sideload
endpoint accepts only the companion files core defines, with no way for
a plugin to add one, so a plugin's companion has to go to an endpoint
the plugin provides. The rendition the proposal named as the first
consumer is out of reach for the same kind of reason — nothing outside
the video-conversion worker can mux a video — and waits on #79375.

The spec records its own video in the browser rather than shipping a
fixture, uploads it through the Video block, and reads the poster back
through the REST API.

Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sr7G5nRsbso744zkruyGHZ
@github-actions github-actions Bot added the [Package] E2E Tests /packages/e2e-tests label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: 0 B

Total Size: 8.21 MB

e996313 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 7be971e try/82035-upload-operation-api % Change
timeToFirstByte 44.3 ms +5.53% -1.35% 45.65 ms +2.96% -3.4% -2.96%
largestContentfulPaint 82 ms +4.88% -9.76% 76 ms +10.53% -5.26% 7.89%
lcpMinusTtfb 34.2 ms +12.57% -12.87% 29.7 ms +11.62% -2.86% 15.15%
wpBeforeTemplate 21.59 ms +8.48% -2.92% 21.66 ms +5.63% -1.43% -0.32%
wpTemplate 19.6 ms +8.67% -3.37% 20.33 ms +5.07% -4.87% -3.59%
wpTotal 40.83 ms +6.25% -0.69% 42.5 ms +2.31% -3.86% -3.93%
wpMemoryUsage 7.59 MB +0% -0% 7.58 MB +0% -0% 0.09%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 7be971e try/82035-upload-operation-api % Change
timeToFirstByte 37.6 ms +5.45% -3.32% 37.3 ms +3.75% -3.35% 0.8%
largestContentfulPaint 84 ms +4.76% -0% 84 ms +0% -4.76% 0%
lcpMinusTtfb 46.9 ms +5.65% -5.12% 44.75 ms +4.25% -1.79% 4.8%
wpBeforeTemplate 19.06 ms +2.83% -2.26% 18.62 ms +8.81% -1.18% 2.36%
wpTemplate 15.48 ms +6.07% -4.46% 14.8 ms +5.47% -2.23% 4.59%
wpTotal 34.75 ms +5.99% -2.99% 34.12 ms +4.95% -2.55% 1.85%
wpMemoryUsage 6.21 MB +0% -0% 6.20 MB +0% -0% 0.11%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric 7be971e try/82035-upload-operation-api % Change
mediaProcessingJpeg 343.51 ms +2.58% -1.07% 344.75 ms +2.04% -1.15% -0.36%
mediaProcessingAvif 5035.66 ms +0.15% -0.2% 5024.72 ms +0.28% -0.13% 0.22%
mediaProcessingJpegToAvif 3419.61 ms +0.8% -0.13% 3410.41 ms +0.95% -0.41% 0.27%

media-upload

Metric 7be971e try/82035-upload-operation-api % Change
jpegUploadProcessing 1419.62 ms +2.82% -1.76% 1401 ms +1.8% -0.8% 1.33%
pngUploadProcessing 193.69 ms +5.06% -4% 185.76 ms +7.24% -7.1% 4.27%
largeJpegUploadProcessing 1395.78 ms +0.6% -0.31% 1395.03 ms +0.24% -0.25% 0.05%
multipleImageUploadProcessing 1458.53 ms +1.28% -0.41% 1501.68 ms +0.44% -0.71% -2.87%

post-editor

Metric 7be971e try/82035-upload-operation-api % Change
serverResponse 538.38 ms +4.53% -1.74% 523.47 ms +3.07% -5.51% 2.85%
firstPaint 284.88 ms +17.12% -15.86% 225.25 ms +17.42% -12.84% 26.47%
domContentLoaded 1132.4 ms +0.73% -3.07% 1101.14 ms +0.66% -2.31% 2.84%
loaded 1133.67 ms +0.73% -3.06% 1102.4 ms +0.66% -2.3% 2.84%
firstContentfulPaint 461.37 ms +3.62% -5.65% 451.17 ms +2.42% -7.27% 2.26%
firstBlock 3370.44 ms +1% -0.29% 3282.68 ms +1.28% -1.02% 2.67%
type 20.69 ms +1.98% -4.74% 18.63 ms +4.88% -4.62% 11.06%
typeWithoutInspector 21.17 ms +5.1% -3.78% 18.61 ms +6.23% -2.04% 13.76%
typeWithTopToolbar 26.08 ms +6.44% -4.68% 23.88 ms +3.14% -2.47% 9.21%
typeContainer 9.84 ms +15.85% -9.76% 8.56 ms +5.26% -4.09% 14.95%
focus 78.55 ms +6.43% -4.05% 73.35 ms +7.24% -9.35% 7.09%
firstFocus 239.44 ms +0% -0% 219.38 ms +0% -0% 9.14%
selectAll 516.77 ms +3.13% -2.97% 525.95 ms +4.93% -6.71% -1.75%
listViewOpen 73.2 ms +6.23% -6.38% 72.2 ms +1.93% -7.17% 1.39%
inserterOpen 23.24 ms +6.15% -6.8% 23.07 ms +6.5% -7.89% 0.74%
inserterHover 3 ms +10% -2.67% 2.99 ms +7.36% -11.04% 0.33%
inserterSearch 7.58 ms +14.91% -3.96% 8.16 ms +10.91% -12.75% -7.11%
loadPatterns 634.51 ms +5.12% -3.78% 647.07 ms +4.47% -2.7% -1.94%
wpTotal 528.55 ms +4.56% -1.81% 513.18 ms +2.85% -5.65% 3%
wpMemoryUsage 13.13 MB +0% -0% 13.12 MB +0% -0% 0.07%
wpDbQueries 54 +0% -1.85% 54 +0% -0% 0%

site-editor

Metric 7be971e try/82035-upload-operation-api % Change
serverResponse 489.35 ms +3% -3.21% 510.74 ms +1.74% -7.54% -4.19%
firstPaint 293.41 ms +7.57% -7.05% 222.21 ms +26.67% -4.59% 32.04%
domContentLoaded 1138.64 ms +0.97% -1.98% 1132.74 ms +1.54% -1.18% 0.52%
loaded 1139.8 ms +0.97% -1.99% 1133.82 ms +1.55% -1.16% 0.53%
firstContentfulPaint 446.06 ms +2.46% -1.43% 447.63 ms +2.29% -2.64% -0.35%
firstBlock 4126.98 ms +1.53% -0.29% 4124.13 ms +0.55% -0.5% 0.07%
type 18.93 ms +10.94% -2.75% 19.8 ms +2.02% -2.42% -4.39%
navigate 114.35 ms +8.48% -1.48% 114.1 ms +8.08% -0.53% 0.22%
loadPatterns 1490.4 ms +4.36% -19.51% 1270.61 ms +18.1% -7.13% 17.3%
loadPages 1039.84 ms +9.97% -0.25% 1057.1 ms +0.88% -1.42% -1.63%
wpTotal 479.81 ms +3% -3.3% 501.46 ms +1.67% -7.78% -4.32%
wpMemoryUsage 12.11 MB +0% -0% 12.10 MB +0% -0% 0.05%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

e996313 Run

This branch has not been deployed

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

Labels

[Feature] Client Side Media Media processing in the browser with WASM [Package] E2E Tests /packages/e2e-tests [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants