ponewheel / android-ponewheel

pOneWheel Android app
MIT License
71 stars 25 forks source link

Accessing logged rides crashes app #30

Closed kwatkins closed 6 years ago

kwatkins commented 6 years ago

Testing out the database updates, sometimes it opens the logged ride, and as soon as I try and move the map I get a crash.

The exception that gets thrown:

11-29 10:08:03.337 9197 9268 E AndroidRuntime: Process: net.kwatts.powtools, PID: 9197 11-29 10:08:03.337 9197 9268 E AndroidRuntime: at net.kwatts.powtools.MapActivity.setupChart(MapActivity.java:250) 11-29 10:08:03.337 9197 9268 E AndroidRuntime: at net.kwatts.powtools.MapActivity.lambda$onCreate$0$MapActivity(MapActivity.java:89) 11-29 10:08:03.337 9197 9268 E AndroidRuntime: at net.kwatts.powtools.MapActivity$$Lambda$0.run(Unknown Source) 11-29 10:08:03.337 9197 9268 E AndroidRuntime: at net.kwatts.powtools.App.lambda$dbExecute$25$App(App.java:58) 11-29 10:08:03.337 9197 9268 E AndroidRuntime: at net.kwatts.powtools.App$$Lambda$0.run(Unknown Source) 11-29 10:08:03.349 1149 3228 W ActivityManager: Force finishing activity net.kwatts.powtools/.MapActivity 11-29 10:13:01.039 1149 3228 W ActivityManager: Force finishing activity net.kwatts.powtools/.RidesListActivity 11-29 10:13:01.140 1149 3228 W ActivityManager: Force finishing activity net.kwatts.powtools/.MainActivity

And other times this:

11-29 10:21:54.650 11980 12343 E AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1 11-29 10:21:54.650 11980 12343 E AndroidRuntime: Process: net.kwatts.powtools, PID: 11980 11-29 10:21:54.650 11980 12343 E AndroidRuntime: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6892) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1048) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.requestLayout(View.java:19781) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.setBackgroundDrawable(View.java:18356) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.setBackground(View.java:18247) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at android.view.View.setBackgroundColor(View.java:18209) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at net.kwatts.powtools.MapActivity.setupChart(MapActivity.java:250) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at net.kwatts.powtools.MapActivity.lambda$onCreate$0$MapActivity(MapActivity.java:89) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at net.kwatts.powtools.MapActivity$$Lambda$0.run(Unknown Source) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at net.kwatts.powtools.App.lambda$dbExecute$25$App(App.java:58) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at net.kwatts.powtools.App$$Lambda$0.run(Unknown Source) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 11-29 10:21:54.650 11980 12343 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761) 11-29 10:21:54.654 1149 2453 W ActivityManager: Force finishing activity net.kwatts.powtools/.MapActivity

I'll dig into it deeper as well.

ebabel commented 6 years ago

I fixed that, it was because we needed to switch to the UI thread. sha c27e7e6

ebabel commented 6 years ago

@kwatkins You weren't on that sha yet right?

kwatkins commented 6 years ago

Oh, no, I'll grab that. Yeah just found out that was the issue lineChart.invalidate() - you might want to add some exception handling in places, threading can be helll

ebabel commented 6 years ago

Thanks for testing!