Skip to content

fix(web): Create Person face preview not working for video assets#28083

Open
midzelis wants to merge 1 commit intomainfrom
fix-face-editor-video-preview
Open

fix(web): Create Person face preview not working for video assets#28083
midzelis wants to merge 1 commit intomainfrom
fix-face-editor-video-preview

Conversation

@midzelis
Copy link
Copy Markdown
Collaborator

FaceEditor previously required an HTMLImageElement | HTMLVideoElement prop to compute layout metrics and generate the face crop preview. This was unavailable for video assets, so the preview thumbnail in the Create Person modal was always missing, and face positions could be NaN during image load (naturalWidth is 0 before the image decodes), this was causing some e2e flakiness. So, now instead of passing the actual image element to face editor, we pass its dimension instead, which come from the asset metadata - not the image/element.

This PR also cleans up some unused functions in container-utils: getContentMetrics and its tests. It adds computeContentMetrics() and new unit tests.

For videos, VideoNativeViewer now captures the current frame to canvas when face edit mode opens and sets assetViewerManager.imgRef, giving FaceEditor the same image-based preview path as photo assets.

fyi @alextran1502 since you recently added Create Person from face editor in #27364

FaceEditor previously required an HTMLImageElement | HTMLVideoElement prop to
compute layout metrics and generate the face crop preview. This was unavailable
for video assets, so the preview thumbnail in the Create Person modal was always
missing, and face positions could be NaN during image load (naturalWidth is 0
before the image decodes).

Replace the DOM element prop with assetSize: Size and containerSize: Size, using
asset metadata dimensions that are always available from the API response.
computeContentMetrics() is extracted as a pure utility alongside
mapContentRectToNatural() for converting face rect coordinates back to original
image space.

For videos, VideoNativeViewer now captures the current frame to canvas when face
edit mode opens and sets assetViewerManager.imgRef, giving FaceEditor the same
image-based preview path as photo assets.

Change-Id: I0e9da549e3af40211abad4ab2c0270706a6a6964
@meesfrensel
Copy link
Copy Markdown
Collaborator

Is this only for the e2e test flakiness or also a web issue? Creating a new person on a video, the preview image shows a snippet from the frame where I paused the video.

This is about midway through the video, 'face' directly from current frame:

image

And the generated person, whose face is extracted from the preview thumbnail.

image

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants