Repository navigation
Upload Media: Video poster test plugin runs a step after the upload - #83334
Draft
swissspidy wants to merge 1 commit into
Draft
swissspidy wants to merge 1 commit into
swissspidy wants to merge 1 commit into
Conversation
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
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 8.21 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
See #82035. Third of the step-3 proofs of concept for the upload operation API: a plugin step that runs after
core/uploadfor 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' }forvideo/*files. A video's default pipeline is[ core/upload ], so this is the only step after the upload.item.attachment.id— present only because the upload step ran first — plays the video muted untilrequestVideoFrameCallbackfires (a recording may have no index to seek by, but always has a first frame), draws it to anOffscreenCanvas, encodes a JPEG, and POSTs it withwp.apiFetchtogutenberg-test/v1/video-poster/<id>, passingcontext.signalso a cancelled upload aborts the request.packages/e2e-tests/plugins/upload-operation-video-poster.phpregisters that endpoint (checks the attachment is a video,wp_handle_uploadrestricted to JPEG, stores the URL as post meta) and exposesvideo_posteron attachments.test/e2e/specs/editor/various/upload-operation-video-poster.spec.jsrecords its own video in the browser — a canvas captured withMediaRecorderfor a second — rather than adding a binary fixture, uploads it through the Video block, drains the queue, and asserts the attachment'svideo_posterends in-poster.jpgand fetches back as a JPEG (FF D8). A second test checks the operation and its pool throughgetUploadOperation().Findings for the API
addSideloadItemcannot carry a plugin's companion file. The sideload endpoint validatesimage_sizeagainst 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 throughaddSideloadItem, and the proposal's "the server side is the plugin's job" only holds if the plugin also owns the endpoint — which means bypassingaddSideloadItem, its parent/child tracking and thecore/finalizegate. Either the endpoint gains an extension point for companion names, oraddSideloadItemgains a way to target a plugin's endpoint. I'd lean to the former: the parent/child bookkeeping is the valuable part.@wordpress/video-conversion's worker can demux or mux a video (mediabunnyis internal to it, and the worker only exportsconvertGifToVideo). 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.signalreaching 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.jsChromium only (no
@webkittag): the spec relies onMediaRecorderover a canvas stream, and the step onrequestVideoFrameCallback. 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