Fix Android frame buffer crash - #322
Open
jfversluis wants to merge 1 commit into
Open
Conversation
Copy CameraX frames into owned memory before closing ImageProxy and replace unchecked unsafe RGBA reads with bounds-checked managed luminance conversion. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: aca764ae-9747-48a4-8c08-9b937c4b55d5
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.
Summary
Fixes #291.
The crash log shows a native
SIGSEGVon CameraX's analyzer executor. The subsequentCamera3-OutputStreambroken-pipe messages are consequences of the app process dying, not the original failure.The Android frame pipeline had two unsafe lifetime assumptions:
Bitmap2Yuv420ppinnedbuffer.Remaining()bytes, then unconditionally readwidth * height * 4bytes through pointers. An empty or partially consumed buffer could therefore dereference null or read past the managed array.FrameReadywhile still backed byImageProxymemory, even thoughImageProxy.Close()ran immediately after the callback.This change:
ImageProxy;ByteBufferframe API while letting the built-in decoder use the owned bytes directly;ByteBufferdecoding non-mutating by reading from a reset duplicate;Validation
net10.0-androidwith no warnings or errors.SIGSEGV,libsigchain, fatal exception, or camera broken-pipe signature.The exact reporter app/device remains unavailable, so confirmation with the CI NuGet artifact is still requested.