Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location database bug #2635

Open
Pitoucol opened this issue Nov 18, 2024 · 24 comments
Open

Location database bug #2635

Pitoucol opened this issue Nov 18, 2024 · 24 comments
Labels

Comments

@Pitoucol
Copy link

Pitoucol commented Nov 18, 2024

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 Pitoucol added the bug label Nov 18, 2024
@mar-v-in
Copy link
Member

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?

@Pitoucol
Copy link
Author

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

@ale5000-git
Copy link
Member

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

@Pitoucol
Copy link
Author

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?

@zd3sf
Copy link

zd3sf commented Nov 19, 2024

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

@ale5000-git
Copy link
Member

ale5000-git commented Nov 19, 2024

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 ale5000-git changed the title Location bug Location database bug Nov 19, 2024
@Pitoucol
Copy link
Author

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
Copy link
Author

Hello

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

@ale5000-git
Copy link
Member

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

@leo-liar
Copy link

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?

@zd3sf
Copy link

zd3sf commented Dec 28, 2024

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).

@ale5000-git
Copy link
Member

ale5000-git commented Dec 28, 2024

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.

@zd3sf
Copy link

zd3sf commented Dec 28, 2024

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

@ale5000-git
Copy link
Member

ale5000-git commented Dec 28, 2024

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).

@gieselbusch
Copy link

gieselbusch commented Jan 13, 2025

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!

@mar-v-in
Copy link
Member

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.

@ale5000-git
Copy link
Member

ale5000-git commented Jan 13, 2025

@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)

@mar-v-in
Copy link
Member

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.

@gieselbusch
Copy link

gieselbusch commented Jan 13, 2025

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.

@ale5000-git
Copy link
Member

@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.

@leo-liar
Copy link

@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!

@gieselbusch
Copy link

gieselbusch commented Jan 14, 2025

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:

@ale5000-git
Copy link
Member

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.

@gieselbusch
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants