felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.81k stars 589 forks source link

App is getting hanged when kill the app by user. #290

Open imbichitra opened 4 years ago

imbichitra commented 4 years ago

HI all developer of UsbSerial i am integrating examplemultipleports for communicating two port the connection and communication with device work fine, but when the user kill the app in middle and open it second time the app is going to hang state just display a white screen , and when i disconnect the Usb and reconnect the device it work fine.

Please help me to solve this problem.

brktrk commented 4 years ago

Yes, It does.

Shreyas-R commented 4 years ago

I too encountered this issue while impending multi port example for my requirements. I root caused this issue till usb read function thread. If we use any of inputStream or syncRead in read thread then the app hangs. Just try to comment this read function call, the hang issue goes away. I was unable to get any log during the hang even when I had got strict thread rules enabled for 100% adb logging.

Update: Further I root caused the issue to read timeout. By default, both inputStream & syncRead use infinite timeout with value zero. This is having some problem internally within the library which the developer has to take care. Currently, I'm no longer seeing this hang issue by manually setting timeout to some constant value.

LjieQ commented 4 years ago

@Shreyas-R How to solve this problem specifically?Can You show me how your code works?, thank you