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

feat: Throw an Error if Frame is already destroyed #3099

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

mrousavy
Copy link
Owner

What

Previously we only checked if Frame was already destroyed when trying to access it through JS (through FrameHostObject) - but some people/companies (cc @terrysahaidak / @marblemedia / @canfan / @thomas-coldwell) have custom Frame Processor solutions where they access Frame directly (the ObjC/Java class), and call incrementRefCount()/decrementRefCount() there.

In there, we didn't really check if the Frame is still valid, and so we didn't throw any nice errors if it wasn't - apps just crashed with SIGBART.

So this PR now changes that and moves all checks to see if a frame is valid inside the actual Frame implementation (where it should've belonged in the first place imo).

This is safer, and also more efficient on Java since it's one less JNI call per each prop you access. 🎉

Changes

Tested on

Related issues

Copy link

vercel bot commented Jul 24, 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 Jul 24, 2024 0:35am

@mrousavy mrousavy merged commit b3f5ab6 into main Jul 24, 2024
11 checks passed
@mrousavy mrousavy deleted the feat/throw-error-if-frame-is-destroyed branch July 24, 2024 12:42
isaaccolson pushed a commit to isaaccolson/deliveries-mobile that referenced this pull request Oct 30, 2024
* feat: Throw an error if ObjC `Frame` is invalid

* fix: Remove duplicate Frame closed checks
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.

1 participant