fix(web): Create Person face preview not working for video assets#28083
Open
fix(web): Create Person face preview not working for video assets#28083
Conversation
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
Collaborator
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.


FaceEditorpreviously required anHTMLImageElement | HTMLVideoElementprop 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 beNaNduring image load (naturalWidthis 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:
getContentMetricsand its tests. It addscomputeContentMetrics()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