Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Trigger measure and layout manually to fix Preview stretching #2588

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Feb 19, 2024

What

While the aspect ratio calculations for the Preview View are now seemingly correct (I think), there were some issues reported by users that the Preview View was still stretched.

According to this comment: #2583 (comment) the onMeasure function was not called after updating the Surface size. I believe this is related to this bug in react-native: facebook/react-native#17968 - which means requestLayout does not call onMeasure.

So in this PR I fix this by manually calling measure for this component, so it calls onMeasure as expected - causing the PreviewView to update it's aspect ratio accordingly.

Changes

Tested on

Related issues

Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 1:40pm

@mrousavy mrousavy merged commit 7ac6f4d into main Feb 19, 2024
5 checks passed
@mrousavy mrousavy deleted the fix/trigger-measure branch February 19, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant