Status Update
Comments
po...@google.com <po...@google.com>
po...@google.com <po...@google.com> #2
Branch: androidx-master-dev
commit c60f33e229e31ab328ef6b59dab63b264954831c
Author: Alexandre Elias <aelias@google.com>
Date: Fri Jul 10 16:23:09 2020
Semantics no-op cleanups
Partly in response to lmr's broad code review, I did a pass of
superficial API/implementation cleanup. The main changes are:
- I changed each Boolean SemanticsProperty where false is equivalent to
not being present to take "Unit" instead. This is conceptually
clearer: it avoids questions like "can I cancel out a semantics from a
merged child by setting it to false?" Because "property = Unit" looks
weird, I also changed the style of these to "property()".
- I moved the Semantics id generator closer to where it's used, in
SemanticsModifierCore. I made it internal and an AtomicInt.
(Note that integer ids are heavily used in the Android
AccessibilityNodeInfo APIs so I can't simply remove them entirely.)
- I deleted dead code. Some examples include SemanticsHintOverrides,
a public API not connected to anything, and SemanticsPropertyKey
merge() open method which is never called. (In both cases I have
a different plan in mind for accessibility.)
Fixes: 145951226
Fixes: 145955412
Test: existing tests
Relnote: "Single-value semantics properties now use a calling style.
For example, 'semantics { hidden = true }' is now written as:
'semantics { hidden() }'."
Change-Id: Ic1afd12ea22c926babc9662f1804d80b33aa0cfc
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
M ui/ui-core/api/0.1.0-dev15.txt
M ui/ui-core/api/current.txt
M ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-core/api/public_plus_experimental_current.txt
M ui/ui-core/api/restricted_0.1.0-dev15.txt
M ui/ui-core/api/restricted_current.txt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
D ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
M ui/ui-foundation/api/0.1.0-dev15.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev15.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
M ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
M ui/ui-text/api/0.1.0-dev15.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev15.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
ch...@google.com <ch...@google.com>
ch...@google.com <ch...@google.com> #3
Hi macocco124,
CameraX
The major difference between SurfaceView
but the TextureView
to implement the SurfaceView
.
I tried to clarify the issue via Android Studio Layout Inspector tool. The dimensions of SurfaceView seem correct, but the inside preview images are really stretched by unknown reason. Please refer to the attached screenshots of the PointerGun and
po...@google.com <po...@google.com> #4
Thank you Charcoal for looking at this. FYI one more report for a similar issue:
ch...@google.com <ch...@google.com> #5
This is a redraw timing related issue which happens when using PreviewView
's SurfaceViewImplementation
mode together with Compose UI
.
Based on the PointerGun
sample project provide in bindPreview()
call, the preview stretched issue disappeared.
Original code:
PreviewView(context).apply {
setBackgroundColor(Color.GREEN)
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
scaleType = PreviewView.ScaleType.FILL_CENTER
post {
cameraProviderFuture.addListener(Runnable {
val cameraProvider = cameraProviderFuture.get()
bindPreview(
cameraProvider,
lifecycleOwner,
this,
)
}, ContextCompat.getMainExecutor(context))
}
}
New code:
PreviewView(context).apply {
setBackgroundColor(Color.GREEN)
post {
cameraProviderFuture.addListener(Runnable {
val cameraProvider = cameraProviderFuture.get()
bindPreview(
cameraProvider,
lifecycleOwner,
this,
)
// Updated layoutParams and ScaleType after bindPreview() call
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
scaleType = PreviewView.ScaleType.FILL_CENTER
}, ContextCompat.getMainExecutor(context))
}
}
But, the above solution won't work if the compose related library version is updated from 1.0.0-beta03
to 1.0.0-beta09
.
I also tried to add onClickListener
to the PreviewView
and change its ScaleType
. The preview can be displayed correctly if ScaleType
is changed to a different type when receiving a click event. It means that the SurfaceViewImplementation's transformation calculation should be correct and the issue might be caused by calling setScaleX/Y
and setTranslationX/Y
too early.
PreviewView(context).apply {
setBackgroundColor(Color.GREEN)
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
scaleType = PreviewView.ScaleType.FILL_CENTER
// Adds onClickListener to change its ScaleType
setOnClickListener { v ->
if (scaleType == PreviewView.ScaleType.FILL_CENTER) {
scaleType = PreviewView.ScaleType.FIT_CENTER
} else {
scaleType = PreviewView.ScaleType.FILL_CENTER
}
}
post {
cameraProviderFuture.addListener(Runnable {
val cameraProvider = cameraProviderFuture.get()
bindPreview(
cameraProvider,
lifecycleOwner,
this,
)
}, ContextCompat.getMainExecutor(context))
}
}
The setScaleX/Y
and setTranslationX/Y
only called after surfaceCreated
event is received. But the issue still exists.
You must ensure that the drawing thread only touches the underlying Surface while it is valid -- between SurfaceHolder.Callback.surfaceCreated() and SurfaceHolder.Callback.surfaceDestroyed().
After the surface is created, it will provide the surface to the SurfaceRequest
requested by the PreviewView
's SurfaceProvider
. Therefore, I tried to only call setScaleX/Y
and setTranslationX/Y
when the surface has been provided. I found the issue disappeared by this change. This might be the solution for this issue and this might also be a reasonable timing to start calling setScaleX/Y
and setTranslationX/Y
since the preview content can be displayed only if the surface has been provided.
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit ed384c5a0be359b021a2eeb76fc92ebb3676ee18
Author: Charcoal Chen <charcoalchen@google.com>
Date: Thu Jun 24 09:03:33 2021
Fixed PreviewView PERFORMANCE mode stretch issue when using together with Compose UI
This is a timing issue. When using PreviewView's SurfaceViewImplementation mode, the images inside the SurfaceView won't be scaled/translated to match the SurfaceView's dimensions if calling setScaleX/Y or setTranslationX/Y functions too early. This issue doesn't exist when not using PreviewView's SurfaceViewImplementation mode together with Compose UI. This issue doesn't occur if calling setScaleX/Y or setTranslationX/Y functions after SurfaceView's surface has been provided. This should be reasonable timing since the preview content can be displayed only if the surface has been provided.
Relnote: "Fixed PreviewView PERFORMANCE mode stretch issue when using together with Compose UI."
Bug: 183864890
Test: ./gradlew camera:camera-view:build && ./gradlew camera:camera-view:connectedAndroidTest && manual test
Change-Id: Ie11371e57cb196552cef786c5567ddb60187fdca
M camera/camera-view/src/main/java/androidx/camera/view/PreviewViewImplementation.java
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit da4a0aed64df0e9636956738162c727195eadcf8
Author: Charcoal Chen <charcoalchen@google.com>
Date: Fri Jun 25 14:42:57 2021
Add new ComposeUiFragment into the view test app
This is a simple fragment to easily check whether preview will be stretched when using PreveiwView together with Compose UI.
Bug: 183864890
Test: ./gradlew camera:integration-tests:camera-testapp-view:build && ./gradlew camera:integration-tests:camera-testapp-view:connectedAndroidTest && manual test
Change-Id: I79a45baf2b80b04dac8b28442fdf407ca3f32b89
M camera/integration-tests/viewtestapp/build.gradle
A camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/ComposeUiFragment.kt
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/MainActivity.java
M camera/integration-tests/viewtestapp/src/main/res/menu/actionbar_menu.xml
M camera/integration-tests/viewtestapp/src/main/res/values/donottranslate-strings.xml
ch...@google.com <ch...@google.com> #8
The solution has been merged in
ch...@google.com <ch...@google.com> #9
Update some more information. After doing more testing for this issue, this issue looks only happen on Android 10 and 11 devices.
Attached PointerGun-Original.apk is built by the original CameraX library setting.
Attached PointerGun-BuiltWithSolution.apk is built by the local verifying library with the solution.
API Level | Android Version | Device Name | Issue Occur |
---|---|---|---|
30 | 11 | Moto One Hyper | Yes |
30 | 11 | Samsung S20+ | Yes |
29 | 10 | Samsung Note 10+ | Yes |
28 | 9 | Samsung Note 10+ | No |
28 | 9 | Moto G7 | No |
27 | 8.1 | Samsung J2 Core | No |
26 | 8.0 | Samsung S8+ | No |
25 | 7.1.1 | Samsung Note 8 | No |
ch...@google.com <ch...@google.com> #10
Hi Mihai,
Could you also help to double check this issue in the Compose UI part? It is because that:
- The issue doesn't happen when using only CameraX's PreviewView (SurfaceViewImplementation mode).
- As mentioned in
, the same code might have the issue when usingcomment#5 1.0.0-beta09
but doesn't have the issue when using1.0.0-beta03
.
If the issue could also possibly have a solution in the Compose UI side, it will benefit the applications which have their own SurfaceView widget implementation and use it together with Compose UI. Or, maybe we can know what we should take care of when using SurfaceView together with Compose UI.
Description
Component used: androidx.compose.ui:ui Version used: 1.0.0-beta03 Devices/Android versions reproduced on:
The camera image appears stretched and only one half is shown. Note that the view occupies the expected amount of space, so maybe the bug lies within cameraX. Works fine in landscape orientation.
Sample project and screenshot are attached.