Status Update
Comments
cl...@google.com <cl...@google.com> #2
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
kh...@gmail.com <kh...@gmail.com> #3
ad...@guardian.co.uk <ad...@guardian.co.uk> #4
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
cl...@google.com <cl...@google.com> #5
It seems the problem here is using paging-runtime 3.2.x
along with paging-common 3.3.0
.
You likely see this error here because paging-common 3.3.0
(along with paging-compose / paging-testing) was commonized into kmp structure.
In the stacktrace you'll notice the file name PagingLogger.android.kt:29
has an android.kt
suffix, meaning it was intended only for android platform (androidTests
).
Re:androidTest
and see if it passes, or upload a sample app?
We should probably add a constraint to ensure paging-common 3.3.0
is used with paging-runtime 3.3.0
ad...@guardian.co.uk <ad...@guardian.co.uk> #6
Hey!
You were right, there were different minor versions - paging-runtime 3.2.1
and paging-compose 3.3.0
. However, updating both to 3.3.0
didn't fix the test issue either.
The tests do pass when running in an androidTest
.
Does this mean that all paging related tests now need to run as androidTest
s instead of jvm test
s? That'd be a bummer with the cost and time of instrumented tests :(
kf...@gmail.com <kf...@gmail.com> #8
Hi, I have the same issue since androidx.paging:paging-runtime:3.3.0
and androidx.paging:paging-testing:3.3.0
.
Here is a sample test that fails:
@Test
fun asSnapshot() = runTest {
val data = listOf(1, 2, 3)
val pagingData = PagingData.from(data)
val pagingDataStream = flowOf(pagingData)
val result = pagingDataStream.asSnapshot()
assertEquals(data, result)
}
Method isLoggable in android.util.Log not mocked. See https://developer.android.com/r/studio-ui/build/not-mocked for details.
java.lang.RuntimeException: Method isLoggable in android.util.Log not mocked. See https://developer.android.com/r/studio-ui/build/not-mocked for details.
at android.util.Log.isLoggable(Log.java)
at androidx.paging.PagingLogger.isLoggable(PagingLogger.android.kt:29)
at androidx.paging.PagingDataPresenter$collectFrom$2$1.emit(PagingDataPresenter.kt:521)
at androidx.paging.PagingDataPresenter$collectFrom$2$1.emit(PagingDataPresenter.kt:118)
at kotlinx.coroutines.flow.FlowKt__BuildersKt$flowOf$$inlined$unsafeFlow$2.collect(SafeCollector.common.kt:112)
at androidx.paging.PagingDataPresenter$collectFrom$2.invokeSuspend(PagingDataPresenter.kt:118)
at androidx.paging.PagingDataPresenter$collectFrom$2.invoke(PagingDataPresenter.kt)
at androidx.paging.PagingDataPresenter$collectFrom$2.invoke(PagingDataPresenter.kt)
at androidx.paging.SingleRunner$runInIsolation$2.invokeSuspend(SingleRunner.kt:59)
at androidx.paging.SingleRunner$runInIsolation$2.invoke(SingleRunner.kt)
at androidx.paging.SingleRunner$runInIsolation$2.invoke(SingleRunner.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:261)
at androidx.paging.SingleRunner.runInIsolation(SingleRunner.kt:49)
at androidx.paging.SingleRunner.runInIsolation$default(SingleRunner.kt:44)
at androidx.paging.PagingDataPresenter.collectFrom(PagingDataPresenter.kt:116)
at androidx.paging.testing.PagerFlowSnapshotKt$asSnapshot$4$collectPagingData$1$1.invokeSuspend(PagerFlowSnapshot.kt:119)
at androidx.paging.testing.PagerFlowSnapshotKt$asSnapshot$4$collectPagingData$1$1.invoke(PagerFlowSnapshot.kt)
at androidx.paging.testing.PagerFlowSnapshotKt$asSnapshot$4$collectPagingData$1$1.invoke(PagerFlowSnapshot.kt)
at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(Merge.kt:213)
at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt)
at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:30)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:27)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:90)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:43)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:29)
at kotlinx.coroutines.flow.FlowKt__BuildersKt$flowOf$$inlined$unsafeFlow$2.collect(SafeCollector.common.kt:112)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invokeSuspend(Merge.kt:23)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Merge.kt)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.invoke(Merge.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:61)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:261)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest.flowCollect(Merge.kt:21)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:153)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(ChannelFlow.kt)
at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:56)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42)
at androidx.paging.SingleRunner.runInIsolation(SingleRunner.kt:49)
at androidx.paging.testing.PagerFlowSnapshotKt$asSnapshot$4$collectPagingData$1$1.invokeSuspend(PagerFlowSnapshot.kt:119)
at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(Merge.kt:213)
at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:30)
at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:56)
at androidx.paging.testing.PagerFlowSnapshotKt$asSnapshot$4$collectPagingData$1.invokeSuspend(PagerFlowSnapshot.kt:117)
As a workaround, it does work as an instrumented test.
However, it should still work as a local test and should not depend on the Android framework.
cl...@google.com <cl...@google.com> #9
As a quick update, the core cause of this issue is that in 3.3.0
paging was commonized to support Kotlin Multiplatform.
As a result, when an android project depends on Paging 3.3, it pulls in the android implementation for the main source as well as android unit tests. Hence you see PagingLogger.android.kt
in the stacktrace.
at androidx.paging.PagingLogger.isLoggable(PagingLogger.android.kt:29)
This will need to be fixed on our end so that unit tests do not trigger logs.
le...@gmail.com <le...@gmail.com> #10
Thanks a lot.
cl...@google.com <cl...@google.com> #11
While we work on the fix, here are a few workarounds in the meantime. Either option works:
- Make your project KMP and put paging tests in jvmTest
- Use Robolectric in your androidTest to run the tests as is
- Move the tests to instrumented androidTest and run the tests with emulator
ad...@guardian.co.uk <ad...@guardian.co.uk> #12
Thanks Clara!
"While we work on the fix... " - Does this mean we can expect this to be resolved in near future to work with non-KMP projects in regular jvm tests?
Migrating to KMP is a larger task and beyond our scope. Introducing Roboelectric just for paging tests also feels excessive.
Moving the tests to androidTest
feels like a reasonable approach in the moment. The only issue with this is that instrumented tests are slow and expensive, and once we move these tests there, we're quite likely to forget about ever moving them back to jvm.
If there's a solution for jvm tests without KMP in sight, we'd rather continue holding back from upgrading to 3.3.x
rather than migrate to androidTests.
It there's no change expected anytime soon (as Ian suggested in another channel), then we'd rather to bite the bullet now and migrate to androidTest
.
cl...@google.com <cl...@google.com> #13
Yup I get where you're coming from. I'm looking into makings the logs no-op in android tests (or making it optional) to remove the burden from developers. Not sure how viable this is though but if a fix on our end is possible, it will be released in 3.3.4
.
ap...@google.com <ap...@google.com> #14
Project: platform/frameworks/support
Branch: androidx-main
Author: Clara Fok <
Link:
Disable Paging logs on android unit tests
Expand for full commit details
Disable Paging logs on android unit tests
Non-kmp projects pulling in Paging 3.3 or later will automatically pull in android dependencies for android unit tests. This is by nature of how multiplatform sources are resolved.
Paging logger is an android dependency that requires instrumented tests or robolectric. As such it throws in non-instrumented unit tests. This CL checks os BUILD id and disables logging if null. This does not affect instrumented tests or robolectric tests as the ID in either case is non-null.
Test: existing tests pass
Bug: 331684448
Relnote: "Android unit tests pulling in Paging 3.3 or later will no longer throw from PagingLogger"
Change-Id: Ia9400db995e7f0357cae2647cbd2cef9cf6c3398
Files:
- M
paging/paging-common/src/androidMain/kotlin/androidx/paging/PagingLogger.android.kt
Hash: 77041951f769c8e98a60da2dbe540505d98084ad
Date: Wed Oct 30 17:21:10 2024
cl...@google.com <cl...@google.com> #15
Fixed internally and will be available in paging 3.3.4
ad...@guardian.co.uk <ad...@guardian.co.uk> #16
--
This e-mail and all attachments are confidential and may also be
privileged. If you are not the named recipient, please notify the sender
and delete the e-mail and all attachments immediately. Do not disclose the
contents to another person. You may not use the information for any
purpose, or store, or copy, it in any way. Guardian News & Media Limited
is not liable for any computer viruses or other material transmitted with
or as part of this e-mail. You should employ virus checking software.
Guardian News & Media Limited is a member of Guardian Media Group plc.
Registered Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP.
Registered in England Number 908396
na...@google.com <na...@google.com> #17
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.paging:paging-common:3.3.4
androidx.paging:paging-common-android:3.3.4
androidx.paging:paging-common-iosarm64:3.3.4
androidx.paging:paging-common-iossimulatorarm64:3.3.4
androidx.paging:paging-common-iosx64:3.3.4
androidx.paging:paging-common-jvm:3.3.4
androidx.paging:paging-common-linuxarm64:3.3.4
androidx.paging:paging-common-linuxx64:3.3.4
androidx.paging:paging-common-macosarm64:3.3.4
androidx.paging:paging-common-macosx64:3.3.4
androidx.paging:paging-common-tvosarm64:3.3.4
androidx.paging:paging-common-tvossimulatorarm64:3.3.4
androidx.paging:paging-common-tvosx64:3.3.4
androidx.paging:paging-common-watchosarm32:3.3.4
androidx.paging:paging-common-watchosarm64:3.3.4
androidx.paging:paging-common-watchossimulatorarm64:3.3.4
androidx.paging:paging-common-watchosx64:3.3.4
Description
Version used: 3.2.1
Devices/Android versions reproduced on: it's in unit-test
here is the error log
```
java.lang.RuntimeException: Method isLoggable in android.util.Log not mocked. See
at android.util.Log.isLoggable(Log.java)
at androidx.paging.AsyncPagingDataDiffer$Companion$1.isLoggable(AsyncPagingDataDiffer.kt:433)
at androidx.paging.PagingDataDiffer$collectFrom$2$1.emit(PagingDataDiffer.kt:555)
at androidx.paging.PagingDataDiffer$collectFrom$2$1.emit(PagingDataDiffer.kt:140)
at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:87)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
at androidx.paging.CachedPageEventFlow$downstreamFlow$1$2.emit(CachedPageEventFlow.kt:106)
at androidx.paging.CachedPageEventFlow$downstreamFlow$1$2.emit(CachedPageEventFlow.kt:103)
at kotlinx.coroutines.flow.FlowKt__LimitKt$takeWhile$lambda$6$$inlined$collectWhile$1.emit(Limit.kt:143)
at kotlinx.coroutines.flow.SubscribedFlowCollector.emit(Share.kt)
at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:382)
at kotlinx.coroutines.flow.SharedFlowImpl.collect(SharedFlow.kt)
at kotlinx.coroutines.flow.SubscribedSharedFlow.collect(Share.kt:409)
at kotlinx.coroutines.flow.FlowKt__LimitKt$takeWhile$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:125)
at androidx.paging.CachedPageEventFlow$downstreamFlow$1.invokeSuspend(CachedPageEventFlow.kt:103)
at androidx.paging.CachedPageEventFlow$downstreamFlow$1.invoke(CachedPageEventFlow.kt)
at androidx.paging.CachedPageEventFlow$downstreamFlow$1.invoke(CachedPageEventFlow.kt)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
at kotlinx.coroutines.flow.FlowKt__EmittersKt$onStart$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:121)
at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:115)
at androidx.paging.PagingDataDiffer$collectFrom$2.invokeSuspend(PagingDataDiffer.kt:140)
at androidx.paging.PagingDataDiffer$collectFrom$2.invoke(PagingDataDiffer.kt)
at androidx.paging.PagingDataDiffer$collectFrom$2.invoke(PagingDataDiffer.kt)
at androidx.paging.SingleRunner$runInIsolation$2.invokeSuspend(SingleRunner.kt:59)
at androidx.paging.SingleRunner$runInIsolation$2.invoke(SingleRunner.kt)
at androidx.paging.SingleRunner$runInIsolation$2.invoke(SingleRunner.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
at androidx.paging.SingleRunner.runInIsolation(SingleRunner.kt:49)
at androidx.paging.SingleRunner.runInIsolation$default(SingleRunner.kt:44)
at androidx.paging.PagingDataDiffer.collectFrom(PagingDataDiffer.kt:138)
at androidx.paging.AsyncPagingDataDiffer.submitData(AsyncPagingDataDiffer.kt:229)
```