GmsCore icon indicating copy to clipboard operation
GmsCore copied to clipboard

Location database bug

Open Pitoucol opened this issue 1 year ago • 10 comments

Hello

I still have the location bug, even after latest version. I'm on 0.3.4.240913.

Before this update, I had the bug, but only when opening some particular apps. But now, after the update, it's more more frequent. With many apps, like brave or Firefox...

To Reproduce Steps to reproduce the behavior: Just open brave or Firefox but may other apps Wait about 20-30 seconds. Information that microg just crashed appears. Here is a log if you can deal with it... https://paste.crdroid.net/a0d4PK

Android 14. Rom crdroid base on lineage os.

Thanks

Pitoucol avatar Nov 18 '24 11:11 Pitoucol

Do you use the official version (from the microG F-Droid repository) or some other version? Did you upgrade from 0.3.2 to 0.3.4 or did you use any other version before?

mar-v-in avatar Nov 18 '24 14:11 mar-v-in

Yes I use the official from fdroid repo. I was on 3.3 before and just upgrade yesterday

Pitoucol avatar Nov 18 '24 15:11 Pitoucol

@Pitoucol Is it possible that your phone crashed and corrupted the database?

ale5000-git avatar Nov 18 '24 15:11 ale5000-git

No idea. How do I check this? My phone didn't crash recently or yesterday, or before.. Can I do something to test or to bring you informations?

Pitoucol avatar Nov 18 '24 15:11 Pitoucol

Can you try to see if the location works in "Satstat" or "my location" apps from Fdroid?. Those are the 2 that actually displays network location. The bug is resolved for me on Crdroid android 15.

You can export the database from Microg settings>location>3 dots menu

zd3sf avatar Nov 19 '24 16:11 zd3sf

Since the paste link may disappear I will post his error here just to be sure:

time: 1731929649460
msg: android.database.sqlite.SQLiteException: no such column: alt (code 1 SQLITE_ERROR): , while compiling: SELECT lat, lon, acc, alt, alt_acc, time, prec FROM cells WHERE mcc = ? AND mnc = ? AND type = ? AND lac = ? AND cid = ? AND psc = ?
stacktrace: android.database.sqlite.SQLiteException: no such column: alt (code 1 SQLITE_ERROR): , while compiling: SELECT lat, lon, acc, alt, alt_acc, time, prec FROM cells WHERE mcc = ? AND mnc = ? AND type = ? AND lac = ? AND cid = ? AND psc = ?
	at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
	at android.database.sqlite.SQLiteConnection.-$$Nest$smnativePrepareStatement(Unknown Source:0)
	at android.database.sqlite.SQLiteConnection$PreparedStatementCache.createStatement(SQLiteConnection.java:1562)
	at android.database.sqlite.SQLiteConnection.acquirePreparedStatementLI(SQLiteConnection.java:1098)
	at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1126)
	at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:686)
	at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:614)
	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:62)
	at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
	at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
	at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1827)
	at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1659)
	at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1516)
	at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1701)
	at org.microg.gms.location.network.LocationDatabase.query(LocationDatabase.kt:138)
	at org.microg.gms.location.network.LocationDatabase.getCellLocation(LocationDatabase.kt:141)
	at org.microg.gms.location.network.NetworkLocationService$queryCellLocationFromDatabase$2.invoke(NetworkLocationService.kt:303)
	at org.microg.gms.location.network.NetworkLocationService$queryCellLocationFromDatabase$2.invoke(NetworkLocationService.kt:303)
	at org.microg.gms.location.network.NetworkLocationService.queryLocationFromRetriever(NetworkLocationService.kt:315)
	at org.microg.gms.location.network.NetworkLocationService.queryCellLocationFromDatabase(NetworkLocationService.kt:303)
	at org.microg.gms.location.network.NetworkLocationService.queryCellLocation(NetworkLocationService.kt:421)
	at org.microg.gms.location.network.NetworkLocationService.access$queryCellLocation(NetworkLocationService.kt:39)
	at org.microg.gms.location.network.NetworkLocationService$onCellDetailsAvailable$3.invokeSuspend(NetworkLocationService.kt:472)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
	at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
	at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
	at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
	at org.microg.gms.location.network.NetworkLocationService.onCellDetailsAvailable(NetworkLocationService.kt:471)
	at org.microg.gms.location.network.cell.CellDetailsSource$startScan$1.onCellInfo(CellDetailsSource.kt:31)
	at android.telephony.TelephonyManager$4.lambda$onCellInfo$0(TelephonyManager.java:7146)
	at android.telephony.TelephonyManager$4$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8601)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:583)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:863)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@6f1ec39, Dispatchers.Main.immediate]

ale5000-git avatar Nov 19 '24 16:11 ale5000-git

I can get location with osm, or satstats and my location, but only with GPS. With my location, network location doesn't work. Even with toggle on, in red you can see "turned off"

Pitoucol avatar Nov 19 '24 18:11 Pitoucol

Hello

Can I get you some data to help you resolve this bug? Or is it a way to reset database? Thanks

Pitoucol avatar Dec 27 '24 10:12 Pitoucol

The simplest way is to reset microG Services app data, but you will also reset microG settings and all GCM registrations.

ale5000-git avatar Dec 27 '24 11:12 ale5000-git

The simplest way is to reset microG Services app data, but you will also reset microG settings and all GCM registrations.

As I'm affected by the same bug, is there another (non simple) way to reset the database without loosing all microG settings and (more importantly) GCM registrations?

leo-liar avatar Dec 27 '24 12:12 leo-liar

If you have root you can run this command: find /data/data/*/shared_prefs -name 'com.google.android.gms.*.xml' -delete

It will delete the gms data from all apps forcing them to re-register GCM (other app data are left intact).

zd3sf avatar Dec 28 '24 17:12 zd3sf

It will delete the gms data from all apps forcing them to re-register GCM (other app data are left intact).

This is unrelated since this ticket is about an issue with the location database.

ale5000-git avatar Dec 28 '24 18:12 ale5000-git

This is unrelated since this ticket is about an issue with the location database.

No, directly related because OP wants to reset microg data but is worried about losing GCM registrations. If GCM is lost from microg, most apps wont re-register without the mentioned trick or deleting all app data. So, helping OP with the location bug by allowing them to reset microg without resetting the whole phone. Thanks

zd3sf avatar Dec 28 '24 19:12 zd3sf

No, directly related because OP wants to reset microg data but is worried about losing GCM registrations. If GCM is lost from microg, most apps wont re-register without the mentioned trick or deleting all app data. So, helping OP with the location bug by allowing them to reset microg without resetting the whole phone. Thanks

It fix the problem of GCM registrations but it need root (the OP hasn't specified this).

ale5000-git avatar Dec 28 '24 19:12 ale5000-git

Hi! I have the same problem as the OP. My device is an FP4 with LineageOS for microg 22.1 GmsCore is 0.3.6.244735. In my case, the microg services always crash as soon as I activate the location services or toggle in locations settings of the microg services “request from online service”. The suggestion from zd3sf unfortunately did not work. Unfortunately I can't export the database in the microg settings. I don't get an error message but also can't find the database and there is no further confirmation that anything has happened.

Is there anything I could do? How do I reset the microg settings and what would be the consequences of losing GCM registrations?

Thank you!

gieselbusch avatar Jan 13 '25 15:01 gieselbusch

If you have LineageOS, the easiest way to solve this issue is to delete the location database file from /data/data/com.google.android.gms/databases/geocache.db.

  • Enable "USB debugging" and "Rooted debugging" via developer settings
  • Connect to a computer
  • Run in terminal:
    • adb root
    • adb shell rm /data/data/com.google.android.gms/databases/geocache.db
  • Disable "Rooted debugging" via developer settings
  • Reboot

The root cause of this issue is a failed migration leading to a broken database state. This can happen if at the time of migration the system is low on available storage or the process is stopped mid-migration for another reason.

mar-v-in avatar Jan 13 '25 15:01 mar-v-in

@mar-v-in Isn't possible to do the migration in a temp db file and then swap the real db file only at the end in case of success? (or alternatively keep a backup copy and restore it in case of failure)

ale5000-git avatar Jan 13 '25 15:01 ale5000-git

This is using the migration logic in Android's SQLiteOpenHelper. It should already use database transactions to guarantee atomic updates and either fail entirely (leaving the version as is and keep the file as is) or complete the migration correctly. I have no idea why this seems to not happen correctly under some conditions for this database file - which means I would also not be able to detect that I should not replace the real file with the temp file.

mar-v-in avatar Jan 13 '25 15:01 mar-v-in

Thank you! This was helpful so far and there are no issues until now. Keeping a backup when deleting files is always a good idea! ;-)

Exporting the database is also working as expected now.

gieselbusch avatar Jan 13 '25 15:01 gieselbusch

@mar-v-in Is possible to do this?

  • First one separate query in a special "status" table while we set the name of the table we process
  • Then do the real migration work
  • At the end another separate query to remove the table name from "status" table

In this way by querying the status table if we find a table name we know that this table is corrupted.

PS: Maybe some devices just have a dummy support for database transactions or it is also possible that it doesn't work when RAM is full.

ale5000-git avatar Jan 13 '25 15:01 ale5000-git

@mar-v-in Thank you very much for this solution. I'm rooted so removing the database file was no problem an one reboot later the problem seems to be solved!

leo-liar avatar Jan 13 '25 17:01 leo-liar

Yesterday I noticed that Mozilla UnifiedNlp Backend shows up under "location" in system settings. Is this normal and intended? Or is it a kind of left over from some old installations years ago because I kept flashing dirty?

I'm just asking because I don't know if this might be casing the problem with the database.

How could I get rid of it as it doesn't show up under the installed apps. It's not functioning anyway:

gieselbusch avatar Jan 14 '25 10:01 gieselbusch

Yesterday I noticed that Mozilla UnifiedNlp Backend shows up under "location" in system settings. Is this normal and intended? Or is it a kind of left over from some old installations years ago because I kept flashing dirty?

I'm just asking because I don't know if this might be casing the problem with the database.

It is probably a left over, it shouldn't cause any problem but I suggest to go in the Android settings and uninstall Mozilla UnifiedNlp Backend (if not possible just disable it).

How could I get rid of it as it doesn't show up under the installed apps. It's not functioning anyway

It isn't possible that it doesn't show up at all, maybe system apps are hidden by default; in this case there should be an option to show system apps.

ale5000-git avatar Jan 14 '25 13:01 ale5000-git

Thanks. It was my fault as I forgot to list system apps. I was able to disable it.

gieselbusch avatar Jan 15 '25 08:01 gieselbusch