Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
wu...@google.com <wu...@google.com> #3
Here's my entity:
@Entity(tableName = "palette")
class ManualPaletteEntity(
@PrimaryKey @ColumnInfo(name = "id") val id: String,
@ColumnInfo(name = "name") val name: String,
@ColumnInfo(name = "time_millis") val timeMillis: Long,
)
@Entity(
tableName = "float_hsv",
foreignKeys = [
ForeignKey(
entity = ManualPaletteEntity::class,
parentColumns = ["id"],
childColumns = ["palette_id"],
onDelete = ForeignKey.CASCADE
)
]
)
data class FloatHSVEntity(
@ColumnInfo(name = "hue") val hue: Float,
@ColumnInfo(name = "saturation") val saturation: Float,
@ColumnInfo(name = "value") val value: Float,
@ColumnInfo(name = "alpha") val alpha: Float,
@ColumnInfo(name = "palette_id") val paletteId: String,
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") val id: Int = 0,
)
sc...@google.com <sc...@google.com> #4
FK violation would happen based on the data in the database.
For that example, if you have anything in float_hsv
where palette_id
does not match an id
from ManuelPaletteEntity
, it would crash.
I'm also not sure sqlite is even able to detect that match after the fact, we should probably test that and figure out if we can workaround it.
sh...@google.com <sh...@google.com> #5
Alright, I'll try to figure out what's wrong
da...@gmail.com <da...@gmail.com> #6
Yep, you were right. There's a FK violation
da...@gmail.com <da...@gmail.com> #7
Thanks for checking it. @Elif, lets use this bug to see if we can improve the message.
We could even consider checking for FKey violations ourselves by generating a query and printing a better message. Though if that happens on production, that would mean repeatedly crashing the application :/.
That is probably the right thing to do. Room used to migrate destructively by default and developers didn't like it. We might also consider providing an API to delete violating entries in a future release.
sc...@google.com <sc...@google.com> #8
tr...@google.com <tr...@google.com> #9
sc...@google.com <sc...@google.com> #10
float_hsv
had a palette_id
that was deleted before. That's why I added the foreign key and onDelete = ForeignKey.CASCADE
to automatically delete float_hsv
when the palette was deleted.
mi...@google.com <mi...@google.com> #11
Branch: androidx-main
commit 7917c78c2e0212794a90e46fb6db554c90eec4b9
Author: Elif Bilgin <elifbilgin@google.com>
Date: Mon Jun 07 13:58:31 2021
Handle foreign key violations during Auto Migration more gracefully.
When doing a PRAGMA foreign key check after complex changes have been performed on the database, in the case of a foreign key violation, we are now outputting a clear error message notifying the user that a violation has been found, including the name of the relevant entity.
Bug: 190113935
Test: TransactionMethodProcessorTest.kt
Change-Id: I68e256074d2aa801bb8db9fced5e0099ff51b6df
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/1.json
M room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/2.json
A room/integration-tests/testapp/schemas/androidx.room.integration.testapp.migration.AutoMigrationDb/3.json
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/AutoMigrationDb.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/AutoMigrationTest.java
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/src/main/java/androidx/room/util/DBUtil.java
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 874ef5abba7929d0110fd54392ae9d8ee91003f0
Author: mingdatsai <mingdatsai@google.com>
Date: Mon May 09 20:32:42 2022
Catch CameraCharacteristicsBaseImpl exceptions
Some devices may throw AssertionError, which is not the expected
behavior, when failed to get CameraCharacteristic. When that happens,
we catch the error and return null to workaround it.
Bug: 231701345
Test: ZoomControlTest, ZoomControlDeviceTest &
Camera2CameraControlImplDeviceTest
Change-Id: Ia248ae5580b9d4a0949f4448ccbafcedd1ba7b9b
M camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/ZoomControlTest.java
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/ZoomControl.java
M camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/Camera2CameraControlImplDeviceTest.java
M camera/camera-camera2/src/androidTest/java/androidx/camera/camera2/internal/ZoomControlDeviceTest.java
mi...@google.com <mi...@google.com> #13
We have tested both Android 11 and Android 12 versions on JioPhone Next and couldn't reproduce the bug. I'm guessing it might have be fixed in an earlier device update. The code to handle the AsserionError has been merged, and will be included in a following release.
da...@gmail.com <da...@gmail.com> #14
That makes sense since we're not seeing enough of the errors for it to be impacting all of them. Play Store doesn't provide more than the major version though and we don't have any of our own crash reporting.
mi...@google.com <mi...@google.com> #15
Thanks for the information, it seems match with the guess.
ju...@google.com <ju...@google.com> #16
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.camera:camera-camera2:1.2.0
Description
We're receiving these crash reports for our app on the Play Store (https://play.google.com/store/apps/details?id=app.grapheneos.camera.play ). I'm unsure why it's happening, but perhaps you can get one of these devices and reproduce it. Ideally, CameraX could at least start catching this exception and turning it into an error surfaced to the app.
We're mostly seeing these crashes from the Jio JioPhone Next which is a very widely used, very cheap device in India. The crash traceback is nearly identical across the around 5 device models where we've seen it with only minor variations in Camera2 implementation line numbers. All of the impacted devices are Android 11.