Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
Author: George Mount <
Link:
Fix focus move within child AndroidViews
Expand for full commit details
Fix focus move within child AndroidViews
Fixes: 389994198
Fixes: 391378895
Relnote: "Fixes focus travel within child AndroidViews where it
can sometimes jump out of the child to the ComposeView"
Sometimes the native FocusFinder doesn't act properly and finds
the wrong View when searching. This CL changes the FocusFinder to
use a newer copy of FocusFinder for all focus search operations
in AndroidComposeView.
Test: new test, manual testing
Change-Id: I678c864afe086879c5c45b018dd82da4f23be440
Files:
- M
compose/ui/ui/src/androidInstrumentedTest/AndroidManifest.xml
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusListenerTest.kt
- A
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/test/TestActivity2.kt
- A
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/viewinterop/MixedFocusChangeTest.kt
- M
compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.android.kt
- M
compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/FocusFinderCompat.android.kt
Hash: b028bcc322095634123da91c7146bac9e23c13c7
Date: Tue Jan 14 13:48:11 2025
tr...@gmail.com <tr...@gmail.com> #3
Project: platform/frameworks/support
Branch: androidx-main
Author: Ralston Da Silva <
Link:
Disabling isViewFocusFixEnabled and isRemoveFocusedViewFixEnabled
Expand for full commit details
Disabling isViewFocusFixEnabled and isRemoveFocusedViewFixEnabled
Disabling these flag to unblock 1.8 RC.
These were features/bug-fixes that were not regressions
from 1.7
Bug: 406327273
Bug: 369256395
Bug: 378570682
Bug: 376142752
Bug: 384056227
Bug: 388590015
Bug: 389994198
Bug: 391378895
Test: Ran presubmits and added TODOs to the affected tests
Change-Id: I5ffb7ff27c662838c8b464560d1df830751f015c
Files:
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusViewInteropTest.kt
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/OwnerFocusTest.kt
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/RequestFocusTest.kt
- M
compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/viewinterop/MixedFocusChangeTest.kt
- M
compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/ComposeUiFlags.kt
Hash: 1a33d21734ef7f68d4cad37c8d333831f304a339
Date: Tue Apr 01 17:46:50 2025
tr...@gmail.com <tr...@gmail.com> #4
Oh, and I'm sorry, but I'm using Room 1.1.0-alpha2, not alpha3. I've got a separate issue (that might be a bug in Room as well) that's preventing me from upgrading, otherwise I'd give that a shot to see if the issue is already resolved.
yb...@google.com <yb...@google.com> #5
if you have an easy way to create a repro that would be the fastest because order of calls seems to be important here :/.
also we are about to ship room-beta1 and paging-alpha7, i don't anticipate it to fix this problem but it might allow you update to latest.
also we are about to ship room-beta1 and paging-alpha7, i don't anticipate it to fix this problem but it might allow you update to latest.
tr...@gmail.com <tr...@gmail.com> #6
Sure thing, I'll try to repro it and send you guys a link.
tr...@gmail.com <tr...@gmail.com> #7
Can't seem to reproduce it in a clean codebase, despite it happening constantly in my real codebase... I don't really see any holes in the logic that RoomSQLiteQuery is using to lock the pool and recycle queries, either. I don't have enough time to screw around with it for now, but I'll come back to this and try to reproduce ASAP.
yb...@google.com <yb...@google.com> #8
this is very troubling yet I cannot understand how this happens. I mean, we might have a bug in recycling queries, yet for a Single query, the instance we give to it does not get recycled until the query returns.
below is some sample code generated from a test that returns Single<List>.
@Override
public Single<List<QueryTransactionTest.Entity1>> single() {
final String _sql = "select * from Entity1";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
return Single.fromCallable(new Callable<List<QueryTransactionTest.Entity1>>() {
@Override
public List<QueryTransactionTest.Entity1> call() throws Exception {
final Cursor _cursor = __db.query(_statement);
try {
final int _cursorIndexOfId = _cursor.getColumnIndexOrThrow("id");
final int _cursorIndexOfValue = _cursor.getColumnIndexOrThrow("value");
final java.util.List<android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1> _result = new java.util.ArrayList<android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1>(_cursor.getCount());
while(_cursor.moveToNext()) {
final android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1 _item;
final int _tmpId;
_tmpId = _cursor.getInt(_cursorIndexOfId);
final java.lang.String _tmpValue;
_tmpValue = _cursor.getString(_cursorIndexOfValue);
_item = new android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1(_tmpId,_tmpValue);
_result.add(_item);
}
if(_result == null) {
throw new EmptyResultSetException("Query returned empty result set: " + _statement.getSql());
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
});
}
An option could be that limit offset data source releasing queries that it wants to re-use. But if the count is coming from there, here is the generated count code from a query.
public int countItems() {
final RoomSQLiteQuery sqLiteQuery = RoomSQLiteQuery.acquire(mCountQuery,
mSourceQuery.getArgCount());
sqLiteQuery.copyArgumentsFrom(mSourceQuery);
Cursor cursor = mDb.query(sqLiteQuery);
try {
if (cursor.moveToFirst()) {
return cursor.getInt(0);
}
return 0;
} finally {
cursor.close();
sqLiteQuery.release();
}
}
it again obtains and releases the query in succession so I can't see how it happened to leak it.
below is some sample code generated from a test that returns Single<List>.
@Override
public Single<List<QueryTransactionTest.Entity1>> single() {
final String _sql = "select * from Entity1";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
return Single.fromCallable(new Callable<List<QueryTransactionTest.Entity1>>() {
@Override
public List<QueryTransactionTest.Entity1> call() throws Exception {
final Cursor _cursor = __db.query(_statement);
try {
final int _cursorIndexOfId = _cursor.getColumnIndexOrThrow("id");
final int _cursorIndexOfValue = _cursor.getColumnIndexOrThrow("value");
final java.util.List<android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1> _result = new java.util.ArrayList<android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1>(_cursor.getCount());
while(_cursor.moveToNext()) {
final android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1 _item;
final int _tmpId;
_tmpId = _cursor.getInt(_cursorIndexOfId);
final java.lang.String _tmpValue;
_tmpValue = _cursor.getString(_cursorIndexOfValue);
_item = new android.arch.persistence.room.integration.testapp.test.QueryTransactionTest.Entity1(_tmpId,_tmpValue);
_result.add(_item);
}
if(_result == null) {
throw new EmptyResultSetException("Query returned empty result set: " + _statement.getSql());
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
});
}
An option could be that limit offset data source releasing queries that it wants to re-use. But if the count is coming from there, here is the generated count code from a query.
public int countItems() {
final RoomSQLiteQuery sqLiteQuery = RoomSQLiteQuery.acquire(mCountQuery,
mSourceQuery.getArgCount());
sqLiteQuery.copyArgumentsFrom(mSourceQuery);
Cursor cursor = mDb.query(sqLiteQuery);
try {
if (cursor.moveToFirst()) {
return cursor.getInt(0);
}
return 0;
} finally {
cursor.close();
sqLiteQuery.release();
}
}
it again obtains and releases the query in succession so I can't see how it happened to leak it.
tr...@gmail.com <tr...@gmail.com> #9
I looked over the source that Room generated for my specific case and it all looked totally fine to me, too... I couldn't think of a way this would occur. However, the screenshot is pretty telling and it lines up with the exception I get. My temp "fix" involves just re-issuing the same query and it works fine (because the first failed attempt corrects the condition, despite eventually failing itself).
I'm swamped and under a major deadline for the next week or so, but I'll take a look at this again after that.
I'm swamped and under a major deadline for the next week or so, but I'll take a look at this again after that.
ya...@google.com <ya...@google.com>
yb...@google.com <yb...@google.com> #10
oh stupid me. the bug is actually right there in #8.
You are holding onto the Single so first time you call, it executes and releases the statement, second time you call, it does not allocate a new one :/
Basically this should never release a statement (unless we override finalize in that callable).
Thanks for the report. I'll figure out a way to audit all of these calls.
You are holding onto the Single so first time you call, it executes and releases the statement, second time you call, it does not allocate a new one :/
Basically this should never release a statement (unless we override finalize in that callable).
Thanks for the report. I'll figure out a way to audit all of these calls.
yb...@google.com <yb...@google.com> #11
repro test:
@Test
public void singleUser_keepSingleReference() throws InterruptedException {
User[] users = TestUtil.createUsersArray(1, 2);
mUserDao.insertAll(users);
TestObserver<User> testObserver1 = new TestObserver<>();
Single<User> userSingle1 = mUserDao.singleUserById(1);
Disposable disposable1 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver1);
drain();
testObserver1.assertComplete();
testObserver1.assertValue(users[0]);
disposable1.dispose();
// how get single for 2
TestObserver<User> testObserver2 = new TestObserver<>();
Single<User> userSingle2 = mUserDao.singleUserById(2);
Disposable disposable2 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver2);
drain();
testObserver2.assertComplete();
testObserver2.assertValue(users[1]);
disposable2.dispose();
// now re-use the first single
TestObserver<User> testObserver3 = new TestObserver<>();
Disposable disposable3 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver3);
drain();
testObserver3.assertComplete();
testObserver3.assertValue(users[0]);
disposable3.dispose();
}
@Test
public void singleUser_keepSingleReference() throws InterruptedException {
User[] users = TestUtil.createUsersArray(1, 2);
mUserDao.insertAll(users);
TestObserver<User> testObserver1 = new TestObserver<>();
Single<User> userSingle1 = mUserDao.singleUserById(1);
Disposable disposable1 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver1);
drain();
testObserver1.assertComplete();
testObserver1.assertValue(users[0]);
disposable1.dispose();
// how get single for 2
TestObserver<User> testObserver2 = new TestObserver<>();
Single<User> userSingle2 = mUserDao.singleUserById(2);
Disposable disposable2 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver2);
drain();
testObserver2.assertComplete();
testObserver2.assertValue(users[1]);
disposable2.dispose();
// now re-use the first single
TestObserver<User> testObserver3 = new TestObserver<>();
Disposable disposable3 = userSingle1.observeOn(mTestScheduler)
.subscribeWith(testObserver3);
drain();
testObserver3.assertComplete();
testObserver3.assertValue(users[0]);
disposable3.dispose();
}
tr...@gmail.com <tr...@gmail.com> #12
Solid, thanks!
Description
Version used: 1.1.0-alpha3
Devices/Android versions reproduced on: Pixel 2 XL, Android 8.1.0
The screenshot shows this, but I've got a DAO method that returns a Single<List<RawMetadata>> and for some reason, it seems that the method occasionally runs an incorrect query (I'm guessing it's one that got pulled from RoomSQLiteQuery's pool). This is causing "column not found" issues because the DAO is looking for the columns that make sense for the particular DAO method that was called, but the cursor contains all of the columns from the incorrect/old query.
Note the mQuery value of _statement in the debugger variables pane and how it's different than the _sql value on line 227.