runnerup icon indicating copy to clipboard operation
runnerup copied to clipboard

App crashes when DB was pruned and new activity should be started

Open Uatschitchun opened this issue 4 years ago • 4 comments

Steps to reproduce:

Start RU > Preferences > Maintenance > Prune > Goto Start Tab > Start GPS > Start recording => Crash

The pruning closes the DB (also to be seen in 'App Inspection' in Android Studio watching the DB).

I've had a look, but haven't found where the DB should be opened again.

Maybe it would be good to quit RU after import & prune, as it needs to be restarted anyways ;)

Here's the log

org.runnerup.free.debug E/org.runnerup.tracker.Tracker: Query failed:
    java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/org.runnerup.free.debug/databases/runnerup.db
        at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:57)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1567)
        at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
        at org.runnerup.tracker.Tracker.createActivity(Tracker.java:318)
        at org.runnerup.tracker.Tracker.start(Tracker.java:350)
        at org.runnerup.view.StartActivity.startWorkout(StartActivity.java:619)
        at org.runnerup.view.StartActivity.access$400(StartActivity.java:100)
        at org.runnerup.view.StartActivity$3.onClick(StartActivity.java:631)
        at android.view.View.performClick(View.java:7125)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2021-10-07 15:41:36.895 26488-26488/org.runnerup.free.debug D/AndroidRuntime: Shutting down VM
2021-10-07 15:41:36.901 26488-26488/org.runnerup.free.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.runnerup.free.debug, PID: 26488
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentValues org.runnerup.tracker.filter.PersistentGpsLoggerListener.getKey()' on a null object reference
        at org.runnerup.tracker.Tracker.setNextLocationType(Tracker.java:607)
        at org.runnerup.tracker.Tracker.start(Tracker.java:369)
        at org.runnerup.view.StartActivity.startWorkout(StartActivity.java:619)
        at org.runnerup.view.StartActivity.access$400(StartActivity.java:100)
        at org.runnerup.view.StartActivity$3.onClick(StartActivity.java:631)
        at android.view.View.performClick(View.java:7125)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Uatschitchun avatar Oct 07 '21 13:10 Uatschitchun

I looked at that some time. When db is pruned, the app need to be terminated or some fancy ay to reinit the db is needed. The app could exit in a nicer way or show a popup.

gerhardol avatar Oct 07 '21 17:10 gerhardol

Where is the DB initiation done on app start? All places where the DB is needed, it gets opened with either getreadable or getwritable. Why not just do what RU does on start up after pruning and closing the db?

Uatschitchun avatar Oct 08 '21 07:10 Uatschitchun

Where is the DB initiation done on app start? All places where the DB is needed, it gets opened with either getreadable or getwritable. Why not just do what RU does on start up after pruning and closing the db?

From what I recall it was not so easy to change this. I have no deep knowledge of the setup, follow the DbHelper file, see init etc. You are welcome to investigate, but I find this a very marginal error myself.

gerhardol avatar Oct 08 '21 07:10 gerhardol

It's no showstopper, no :-)

Uatschitchun avatar Oct 08 '21 18:10 Uatschitchun