OpenBot leverages smartphones as brains for low-cost robots. We have designed a small electric vehicle that costs about $50 and serves as a robot body. Our software stack for Android smartphones supports advanced robotics workloads such as person following and real-time autonomous navigation.
Bug Description
App crashes in the Autopilot fragment when the Auto Mode switch is activated.
To Reproduce
Steps to reproduce the behavior:
Go to Autopilot
Turn on the Auto Mode switch
App may immediately crash
Logcat:
07-22 10:07:53.736 27209-27581/org.openbot E/AndroidRuntime: FATAL EXCEPTION: inference
Process: org.openbot, PID: 27209
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8203)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1309)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:5430)
at android.view.View.invalidateInternal(View.java:13959)
at android.view.View.invalidate(View.java:13923)
at android.view.View.invalidate(View.java:13907)
at android.widget.TextView.checkForRelayout(TextView.java:8373)
at android.widget.TextView.setText(TextView.java:5001)
at android.widget.TextView.setText(TextView.java:4828)
at android.widget.TextView.setText(TextView.java:4803)
at org.openbot.autopilot.AutopilotFragment.handleDriveCommand(AutopilotFragment.java:443)
at org.openbot.autopilot.AutopilotFragment.lambda$processFrame$18$AutopilotFragment(AutopilotFragment.java:424)
at org.openbot.autopilot.-$$Lambda$AutopilotFragment$AD5NQvceNuqdJYNKu4y74kjwNKo.run(lambda)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Fix
In AutopilotFragment.handleDriveCommand the textview controlInfo is being updated from a child thread. It should be called from the main thread, in this way:
Bug Description App crashes in the Autopilot fragment when the Auto Mode switch is activated.
To Reproduce Steps to reproduce the behavior:
Fix In AutopilotFragment.handleDriveCommand the textview controlInfo is being updated from a child thread. It should be called from the main thread, in this way:
In the same way, the onConnectionEstablished is updating another text view:
Screenshots Here is the gif for better explanation:
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.