-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export app crash restart #579
Comments
that's not a crash, only a warning trace showing the SerialInputOutputManager thread termination reason |
To stop communication yourself, close the UsbSerialPort. |
Hey @kai-morich, almost created a new issue before checking this one, which is the exact same one I encounter. I tried many (Not to say dozen) of code check in order to avoid this issue without any success. I've got the same warning as @0cococ and after that the onPause of my app is called and everything seems "restarted" but in a very stange way. So I admit this come from the plugin as it never appear if we don't use COM object. I tried your solution with addition of my private closeConnection function inside the onRunError listener, but it didn't change anything. I've checked the code of the plugin another time (Already done a PR on this project a year before) and think it can be workarounded by adding a Looper on the listerner call. Do you think its viable? Here is what I do for closing connection:
Here's the workaround
Thanks in advance |
The listener is invoked in the same background thread as the |
Thanks for the infos (Sorry, wrong account on the first post). But I don't do any UI operations (Except if you count UsbSerial disconnection and other disconnect things as UI Operations). I use this plugin in order to communicate with custom Serial object and it just get status every 30 seconds and send it to a server online. If I don't disconnect anything in case of failure, do the app can "crash" too? Thanks in advance |
So, I just tested what you've said (Added Handler(Looper.getMainLooper()).post() inside the onRunError) and It didn't change anything, the behavior is still the same. Do you have any other potential fix for this issue? |
what kind of "crash" do you get? Can you provide a callstack or logcat output? |
It's doens't seems to be a real crash, but the onPause of my current activity is called, then, the activity is fully relaunched on top of the previous one, so, something bad seems to happen. I got the same Warning as the first post of the issue and then everything goes wrong. Here is the logcat log that is generated:
|
Android lifecycle is complex. I recommend https://github.com/xxv/android-lifecycle. |
Thanks, I know Android Lifecycle is complex, but it shouldn't be triggered with the plugin and a warning. I already tried to setup singleTask and singleTop but it just a bad workaround that create other problems. This behavior only happen with USB plugged in and the plugin running. So, do you have more infos about this behavior and maybe a fix? As there is already 3 issues opened that seems to trigger this problem :/ Thank you very much in advance |
Ok! I have some (good?) news about this! I think I've managed to find the root cause of all the problems! The problem was an app restart after the get_status error. The fact is, when this issue is triggered it seems that the COM device (I admitted this come from the device) create a micro-disconnection that trigger the warning (Which is right, as the connection is/seems lost) and the micro-disconnection trigger the Intent registered with the app. SO, the app onPause is called in order to let another instance (Of the same app/Activity) to be launched and this is why there is this strange behavior. So, for all the other that will read this, you have mainly two solutions:
|
what kind of intent are you using? |
I'm using android.hardware.usb.action.USB_DEVICE_ATTACHED, so when a device is attached it launch my Launchscreen, this is why I'm thinking of micro-disconnection from the COM device |
android.hardware.usb.action.USB_DEVICE_ATTACHED is not really needed. Access permissions are handled differently. USB_DEVICE_ATTACHED is more like a convenience feature for your App and for users. If multiple Apps can handle USB devices the previously selected can be automatically started.
|
How can I stop communicating with the device? I try to change the device status or unplug the device, which causes the app to crash and restart. I try to close it with mSerialIoManager.stop()
port.close()
connection.close(), but it still crashes. Is there any way to close the device connection as long as the device status changes or is unplugged? I don't want the app to crash and restart.
The text was updated successfully, but these errors were encountered: