Repository navigation
fix(chat): stop the attach camera preview from reconfiguring on main - #1042
Merged
Merged
Conversation
Bugsnag 6ac9b0b2991833fd09be1dd8 is an App Hang in ChatCameraPreview.makeUIView. Setting a new preview layer's session on the main thread makes AVCaptureSession commit a configuration, and the attach surface mounts the hidden camera card each time it appears, so toggling the panel repeated that rebuild on main. ChatPhotoCamera now creates one AVCaptureVideoPreviewLayer in init, while its session is still empty. The input added later on the session queue connects to it there. ChatCameraPreview hosts that layer instead of making its own, sets its frame in layoutSubviews, and removes it on dismantle only if it is still the view's sublayer, so a remount that already moved it keeps it. The regression test mounts the preview twice and expects the camera's layer both times.
flip() ran its beginConfiguration/commitConfiguration on main, the same kind of session rebuild behind the attach panel hang. The swap now runs on the session queue and hands the new input back to main. Taps while a swap is in flight are ignored, and a lens that fails to attach restores the previous input.
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.
Fixes Bugsnag 6ac9b0b2991833fd09be1dd8, an App Hang in
ChatCameraPreview.makeUIView.Setting a new
AVCaptureVideoPreviewLayer's session on the main thread makesAVCaptureSessioncommit a configuration. The attach surface mounts the hidden camera card every time it appears, so opening and closing the panel repeated that rebuild on main.ChatPhotoCameracreates one preview layer ininit, while the session is still empty. The input added later on the session queue connects to it there.ChatCameraPreviewhosts that layer instead of making its own. It sets the frame inlayoutSubviewsand removes the layer on dismantle only if it is still the view's sublayer, so a remount that already took it keeps it.flip()had the same main-threadbeginConfiguration/commitConfiguration. The swap now runs on the session queue; taps during a swap are ignored, and a lens that fails to attach restores the previous input.Regression_6ac9b0b2991833fd09be1dd8mounts the preview twice and expects the camera's layer both times. It fails on main.