Exception : Only the original thread that created a view hierarchy can touch its view

Djembefola

Active Member
Licensed User
Longtime User
When i run my app in debug mode, the log file sometimes shows this error message:

Exception : Only the original thread that created a view hierarchy can touch its views.

Meanwhile, the IDE shows a different error message ("Index out ouf bounds"), but no hint, which of the 5000 lines could have caused the error.


This only happens in debug mode, everything is fine when i compile/run in release mode.

I use a separate thread for recording audio in my app.
During recording the microphone level is displayed and frequently updated. The procedure is called with
B4X:
RecordingThread.RunOnGuiThread( "ShowVolume", Array As Object(CurrentVolume))

Maybe this line is related to the exeption error message.

Can i ignore the exception, because it is only thrown in Debug Mode? Is there a way to get rid of it?
 

Djembefola

Active Member
Licensed User
Longtime User
You should not step into code executed by other threads with the debugger.

Does this mean, i should never run the app in debug mode (with or without setting breakpoints), when a separate thread is involved?
I ask this, because there were no breakpoints when the exception happened.

Why do you need another thread?

i need a separate recording thread for the audio record object, because reading the bytes from the hardware into the recording buffer in a loop is blocking and time-critical.
 
Upvote 0
Top