Help - Technical Problem loading Freetrade on Blackshark 1 - Android 9

Hi all

I’m not sure if this is a Freetrade or Android issue, but the app has stopped loading on my son’s Blackshark 1 phone since he received an upgrade to Android 9.

An ADB catlog of ActivityManager and AndroidRuntime shows a stack trace that balks when trying to gain a lock on Firebase’s offline persistence database.

From looking I cannot tell whether this a fault of the Blackshark upgrade or whether it is related to the Freetrade app itself. Not sure where to go next…

Can anybody help by shedding some light on this?

10-13 10:32:05.154 6157 6200 I ActivityManager: Start proc 8109:io.freetrade.android/u0a218 for activity io.freetrade.android/in.icon.Default
10-13 10:32:05.172 6157 7247 W ActivityManager: Request to remove task ignored for non-existent task 15806
10-13 10:32:05.513 6157 6241 I ActivityManager: Displayed io.freetrade.android/in.icon.Default: +373ms
10-13 10:32:07.937 8109 8109 E AndroidRuntime: JUNK_FATAL_EXCEP: FATAL EXCEPTION: main,Process: io.freetrade.android, PID: 8109
10-13 10:32:07.938 8109 8109 E AndroidRuntime: FATAL EXCEPTION: main
10-13 10:32:07.938 8109 8109 E AndroidRuntime: Process: io.freetrade.android, PID: 8109
10-13 10:32:07.938 8109 8109 E AndroidRuntime: java.lang.RuntimeException:
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.a.c$1$1.run(SourceFile:98)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6746)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: Caused by: com.google.firebase.a.c: Failed to gain exclusive lock to Firebase Database’s offline persistence. This generally means you are using Firebase Database from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so you may need to avoid initializing FirebaseDatabase in your Application class. If you are intentionally using Firebase Database from multiple processes, you can only enable offline persistence (i.e. call setPersistenceEnabled(true)) in one of them.
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.a.d.a(SourceFile:830)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.a.d.(SourceFile:214)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.a.c.a(SourceFile:171)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.d.d.b(SourceFile:156)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.d.k.c(SourceFile:130)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.d.k.a(SourceFile:55)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.d.k$1.run(SourceFile:94)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: Caused by: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:569)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:549)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:460)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: at com.google.firebase.a.a.d.a(SourceFile:813)
10-13 10:32:07.938 8109 8109 E AndroidRuntime: … 12 more
10-13 10:32:08.009 6157 7247 W ActivityManager: Force finishing activity io.freetrade.android/in.icon.Default
10-13 10:32:08.068 6157 12579 I ActivityManager: Process io.freetrade.android (pid 8109) has died: vis +99TOP
10-13 10:32:08.095 6157 6241 W ActivityManager: setHasOverlayUi called on unknown pid: 8109
10-13 10:32:17.999 6157 6200 I ActivityManager: Start proc 8328:com.android.providers.calendar/u0a4 for content provider com.android.providers.calendar/.CalendarProvider2
10-13 10:32:38.161 6157 6198 I ActivityManager: Killing 1132:com.android.cellbroadcastreceiver/u0a8 (adj 906): empty #31

Thanks @caribo - this is a great log. We should have seen this in our monitoring if it were widespread but we’ll definitely take a look and see if we can recreate. Cheers!

1 Like

Thanks @Ian

Forgot to mention, that we have cleared storage, uninstalled and re-installed the app to no avail… app v 1.0.5730

Hey @caribo - so we’ve had a handful of other reports and they’re all from the same device type. We’re going to have a look at see if we can do anything to mitigate it on our side. In theory what the logs show shouldn’t be possible but we’ll see if we can work around it. Thanks!

Thanks @Ian … I’d be keen to understand more about the technicalities of the problem and whether it’s an android issue… of course it’d be great if you can fix it regardless :grinning: what I could’t figure out is where sqlite fits into the picture when you are using firebase for local persistence…

Local caching as provided by the Firebase SDK. Once we know more I’ll send over but right now its something between the Firebase SDK and the device type.

Any news on this @Ian ?

Have you been able to establish whether this is a Xiaomi or Freetrade issue? and is there anything more that I can do to test ? or help debugging?

Apologies for the delay. Judging from the crash reports it’s not something specific that we’re doing. Right now the only device type reporting this is the Xiaomi. We’ve been trying to reproduce on other devices too but no look. Let me check in with the team today and see what else we can try. I’ll make sure to come back latest tomorrow.

@caribo unfortunately we’ve been unable reproduce this with our current suite of test devices.

We have a release going out today to update Firebase and enable persistence earlier on in our app lifecycle. Fingers crossed this helps your situation, but we’ve been unable to verify this ourselves.

We’re also in the the process of deploying to BrowserStack, so we can test on more devices in the cloud. There’s a chance this might allow us to see the crash for ourselves.

To help us continue to debug this, I’ve got a couple more questions:

  • Are you able to pull any more logs around what other processes running at the same time?
  • Do you have any other apps running which might interfere with the currently running processes, or allow you to run the same app multiple times?
  • Did you do a clean install or just upgrade to Android 9?

Thanks for your help, I really appreciate you bearing with us while we continue to investigate this.

Hey @milo
Thanks for the detailed response. I realise that the blackshark is a niche device , so your attention to this is much appreciated.

The latest upgrade has not changed the situation and the app fails with the same SQLITE error…

As you know the blackshark is a gaming phone so I am sure there are many optimizations under the cover, but no options that I can see other than standard android options. Not using any parallel apps software of any kind.

The phone was upgraded to android 9.0 and all other apps are working okay, next step is a factory reset, but i’m not convinced this will help.

What logs would you like? I could do a fuller adb logcat and DM it if needed…

Thanks

Thanks for the additional info! Would you mind doing a fuller logcat and then dropping me a DM with the details? That’d be super useful. :pray: To help resolve this, we’ve added some additional logging around process IDs to try and identify what else is locking the DB. We’re also going to file an issue with Firebase to see if they have can help us out.

Hi Milo

I’ve DM’d you some additional logs as requested.

Happy reading!

hey @caribo - we’re chatting to Google about whether they have anything to report, stay tuned!

Many thanks @alexc-at-freetrade !!

:boom: really impressed that you are going out of your way to help … really great support from :freetrade:

Hey @caribo - apologies for not getting back to you sooner.

We haven’t had much more luck getting to the bottom of the issue, although I have one more idea which is to disable the offline behaviour on that brand of device specifically. Unfortunately you won’t be able to use the app offline but online should be fine!

I’ll confirm the rollout over the next couple of days.

Hey Alex , that sounds great! Requiring online access is no problem and a great workaround!

hey @caribo! We should have the fix out as part of the first release of 2020.

Please let us know after that if it fixes the issue!

1 Like

Happy New Year! We rolled out the latest Android release yesterday (version 1.0.6800) which should contain a fix for your device. Can you please update and let us know?

1 Like

Hi @alexc-at-freetrade,

The latest update does not resolve the issue. The app force closes early on. I’ll grab some logs over the weekend and share with you.

Cheers
Paul

Hi @alexc-at-freetrade

As mentioned, we have the same problem using FreeTrade v1.0.6981 (log extract below)

My son, who owns the phone is looking to replace it shortly, so don’ t worry too much about a fix… Hopefully he will get his account back once he gets his new phone!

Log extract

01-14 20:38:03.481 25299 31321 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=io.freetrade.android/in.icon.Default bnds=[237,1058][439,1392]} from uid 10033
01-14 20:38:03.529 25299 25327 I ActivityManager: Start proc 5975:io.freetrade.android/u0a226 for activity io.freetrade.android/in.icon.Default
01-14 20:38:03.899 25299 25344 I ActivityManager: Displayed io.freetrade.android/in.icon.Default: +388ms
01-14 20:38:06.323 5975 5975 E AndroidRuntime: JUNK_FATAL_EXCEP: FATAL EXCEPTION: main,Process: io.freetrade.android, PID: 5975
01-14 20:38:06.324 5975 5975 E AndroidRuntime: FATAL EXCEPTION: main
01-14 20:38:06.324 5975 5975 E AndroidRuntime: Process: io.freetrade.android, PID: 5975
01-14 20:38:06.324 5975 5975 E AndroidRuntime: java.lang.RuntimeException:
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.a.h$1$1.run(SourceFile:96)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6746)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: Caused by: com.google.firebase.database.c: Failed to gain exclusive lock to Firebase Database’s offline persistence. This generally means you are using Firebase Database from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so you may need to avoid initializing FirebaseDatabase in your Application class. If you are intentionally using Firebase Database from multiple processes, you can only enable offline persistence (i.e. call setPersistenceEnabled(true)) in one of them.
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.a.i.a(SourceFile:830)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.a.i.(SourceFile:214)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.a.h.a(SourceFile:164)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.d.d.b(SourceFile:157)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.d.n.c(SourceFile:132)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.d.n.a(SourceFile:56)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.d.n$1.run(SourceFile:95)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: Caused by: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:569)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:549)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:460)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: at com.google.firebase.database.a.i.a(SourceFile:813)
01-14 20:38:06.324 5975 5975 E AndroidRuntime: … 12 more
01-14 20:38:06.388 25299 31321 W ActivityManager: Force finishing activity io.freetrade.android/in.icon.Default
01-14 20:38:06.447 25299 25315 I ActivityManager: Process io.freetrade.android (pid 5975) has died: vis +99TOP
01-14 20:38:06.471 25299 25344 W ActivityManager: setHasOverlayUi called on unknown pid: 5975