Skip to content

APDS9960: App crashes when trying to read data from sensor #2608

Closed
@AsCress

Description

@AsCress

Actual Behaviour
The app crashes whenever one tries to read data from the APDS9960 sensor.

Expected Behaviour
The app shouldn't crash in any circumstances.

Steps to reproduce it

  1. Connect the APDS9960 to the PSLab and the PSLab device to the mobile.
  2. Open SensorActivity and try to read data from the APDS9960.
  3. The app crashes.

LogCat for the issue

Process: io.pslab, PID: 25865 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
                                                                                                    	at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8282)
                                                                                                    	at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1445)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:380)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.widget.ScrollView.requestLayout(ScrollView.java:1646)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.view.View.requestLayout(View.java:24525)
                                                                                                    	at android.widget.TextView.checkForRelayout(TextView.java:9725)
                                                                                                    	at android.widget.TextView.setText(TextView.java:6296)
                                                                                                    	at android.widget.TextView.setText(TextView.java:6124)
                                                                                                    	at android.widget.TextView.setText(TextView.java:6076)
                                                                                                    	at io.pslab.sensors.SensorAPDS9960$SensorDataFetch.updateUi(SensorAPDS9960.java:162)
                                                                                                    	at io.pslab.sensors.AbstractSensorActivity$SensorDataFetch.execute(AbstractSensorActivity.java:342)
                                                                                                    	at io.pslab.sensors.AbstractSensorActivity.lambda$getTimerTask$0(AbstractSensorActivity.java:143)
                                                                                                    	at io.pslab.sensors.AbstractSensorActivity.$r8$lambda$CtbQmazQbDhPICCZGZ_trI5o3R8(Unknown Source:0)
                                                                                                    	at io.pslab.sensors.AbstractSensorActivity$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:883)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at android.os.Looper.loop(Looper.java:241)
                                                                                                    	at android.os.HandlerThread.run(HandlerThread.java:67)

Screenshots of the issue
A screen recording demonstrating the issue:

Screen_recording_20250109_221227.mp4

Would you like to work on the issue?
Maybe, but I guess @marcnause knows better about this 😂.
This seems to have be caused by 3d66bf5 merged in #2605.

Metadata

Metadata

Assignees

Labels

BugUnexpected problem or unintended behavior in appInstrument: Sensors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions