Fixed
Status Update
Comments
wu...@google.com <wu...@google.com>
sc...@google.com <sc...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit e464b76ff38cb8bb1f4e52df2d51f47451ea194b
Author: repo sync -c -j8 <scottnien@google.com>
Date: Tue Mar 15 23:23:36 2022
Fix preview sideway issue in PreviewView when rotating in multi-window
- PreviewView now listens to DisplayListener to change preview
transformation unless Preview#setTargetRotation is called explicitly.
- The behavior of Preview#setTargetRotation and
Preview#getTargetRotation is not changed. When apps call
setTargetRotation on Preview, it will use this targetRotation to
rotate the preview instead. getTargetRotation will return the
initial display rotation if targetRotation is not set.
Relnote: "Fixed the issue that preview becomes sideway in PreviewView
when activity is not restarted after rotating devices in multi-window
."
Bug: 223488673
Test: camera2/PreviewTest, manual
Change-Id: I1ea3633cceb751cc101ab45dace4973f41dcd593
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/DisplayInfoManager.java
M camera/camera-core/src/main/java/androidx/camera/core/Preview.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-core/src/main/java/androidx/camera/core/SurfaceRequest.java
M camera/camera-core/src/main/java/androidx/camera/core/UseCase.java
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewMeteringPointFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/PreviewTest.kt
M camera/camera-core/src/main/java/androidx/camera/core/impl/ImageOutputConfig.java
https://android-review.googlesource.com/2026843
Branch: androidx-main
commit e464b76ff38cb8bb1f4e52df2d51f47451ea194b
Author: repo sync -c -j8 <scottnien@google.com>
Date: Tue Mar 15 23:23:36 2022
Fix preview sideway issue in PreviewView when rotating in multi-window
- PreviewView now listens to DisplayListener to change preview
transformation unless Preview#setTargetRotation is called explicitly.
- The behavior of Preview#setTargetRotation and
Preview#getTargetRotation is not changed. When apps call
setTargetRotation on Preview, it will use this targetRotation to
rotate the preview instead. getTargetRotation will return the
initial display rotation if targetRotation is not set.
Relnote: "Fixed the issue that preview becomes sideway in PreviewView
when activity is not restarted after rotating devices in multi-window
."
Bug: 223488673
Test: camera2/PreviewTest, manual
Change-Id: I1ea3633cceb751cc101ab45dace4973f41dcd593
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/DisplayInfoManager.java
M camera/camera-core/src/main/java/androidx/camera/core/Preview.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-core/src/main/java/androidx/camera/core/SurfaceRequest.java
M camera/camera-core/src/main/java/androidx/camera/core/UseCase.java
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewMeteringPointFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/PreviewTest.kt
M camera/camera-core/src/main/java/androidx/camera/core/impl/ImageOutputConfig.java
sc...@google.com <sc...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 041dc566719607c66740500278f4c2d8ef38ef6f
Author: Xi Zhang <xizh@google.com>
Date: Fri Mar 03 17:59:47 2023
Preview distorted when using View display
In PreviewView, we recalculate the transformation when 1) layout is changed or 2) display is changed. However it seems that on certain devices, Display#getRotation returns the previous value at the time DisplayRotationListener#onDisplayChanged is invoked, which leads to the incorrect result. A mitigation would be always setting the current display rotation before calculating the transformation.
Change:
- always set display rotation before redrawing. So if DisplayRotationListener#onDisplayChanged returns the wrong display, OnLayoutChangeListener#onLayoutChange can fix it.
Relnote: Fixed a PreviewView bug that if the app handles screen orientation itself. the preview might become distorted upon rotation. This only happens on certain devices. It can be reproduced on Pixel a4, Pixel 5, and Pixel 6a.
Bug: 223488673
Test: manual test and ./gradlew bOS
Change-Id: I14340cc9790f22c70717217f8f1d9fdfe338dfeb
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
https://android-review.googlesource.com/2469881
Branch: androidx-main
commit 041dc566719607c66740500278f4c2d8ef38ef6f
Author: Xi Zhang <xizh@google.com>
Date: Fri Mar 03 17:59:47 2023
Preview distorted when using View display
In PreviewView, we recalculate the transformation when 1) layout is changed or 2) display is changed. However it seems that on certain devices, Display#getRotation returns the previous value at the time DisplayRotationListener#onDisplayChanged is invoked, which leads to the incorrect result. A mitigation would be always setting the current display rotation before calculating the transformation.
Change:
- always set display rotation before redrawing. So if DisplayRotationListener#onDisplayChanged returns the wrong display, OnLayoutChangeListener#onLayoutChange can fix it.
Relnote: Fixed a PreviewView bug that if the app handles screen orientation itself. the preview might become distorted upon rotation. This only happens on certain devices. It can be reproduced on Pixel a4, Pixel 5, and Pixel 6a.
Bug: 223488673
Test: manual test and ./gradlew bOS
Change-Id: I14340cc9790f22c70717217f8f1d9fdfe338dfeb
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.camera:camera-view:1.3.0-alpha05
ma...@gmail.com <ma...@gmail.com> #5
FYI, I noticed that passing a main thread handler (handler = Handler(Looper.getMainLooper())
) when registering the display listener, AND running handler.post { }
in onDisplayChanged
, ensures that rotation is updated to the real value.
Might be better than querying the display on every frame (if that's what you are doing).
sc...@google.com <sc...@google.com> #6
Hi this is a great feedback ! Thanks !
Actually we have changed the behavior just like what you describe (See CL inhttps://android-review.googlesource.com/2469881 ) and released in 1.3.0-alpha05.
Actually we have changed the behavior just like what you describe (See CL in
Description
When rotating devices from portrait to landscape in multi-window mode, sometimes the activity won't restart and the preview using PreviewView becomes sideway. (e.g, Samsung Z fold 2 / 3 in unfold state).
Or when rotating devices from 90 degrees directly to 270 degrees, the activity won't restart , and the issue will happen.
The issue happens only when COMPATIBLE mode is used for PreviewView.