-
Notifications
You must be signed in to change notification settings - Fork 289
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
Proper resources disposal on "reload" #15
Comments
@waltermacambira hey, yep this is bothering me too, there should definately be some way how to do it, I will look into it |
@rusel1989 I am not familiar with Android development, but if you need any help on creating a PR for this, please let me know. I could not find in 'react-native' docs anywhere saying where to add a callback to make this kind of clean up. One way around it, would be to detect the socket is in this state, cleaning it if so. |
@rusel1989 Solved at least for Android. I made the service variable static, so I could properly release the resources ( |
@waltermacambira Cool, so can you please submit pull request with your fixes ? |
@rusel1989 even if it is android only? |
@waltermacambira - I would appreciate an android only fix. Thanks. |
@waltermacambira - Is the fix you mean change this line to: private static RCTBluetoothSerialService mBluetoothService; I need to get this working, and I will make my own fork if necessary. By the way, this is not just a development headache. CodePush deployments corrupt the connection. Any user that is connected at the time a CodePush update is applied will never be able to connect again until he manually unpairs via device Settings. Also by the way, I attempted to implement a workaround using |
I tried changing this line to: private static RCTBluetoothSerialService mBluetoothService; Did not fix the problem. By the way, looking at output from CORRECTION: This does fix the problem. Yay. (I made the dumb error of forgetting that native updates require a new APK because they are not applied by CodePush.) |
Yes, the fix can be as simple as that. A better disposal of the streams would be nice too, but I did not see it as necessary. |
Alas, this fix is not working for me. While it appears to "fix" the connect error (I can successfully connect) the connection is not functional. In my application I have implemented a request-response pattern. I write an AT command, then recursively dead until I reach either "OK" or "ERROR" or timeout. After the re-connect, the reads never return anything. The problem is in fact worse because to achieve a good state I need not only to un-pair the device but to also restart my application. |
My problem seems to be solved by upgrading to I neglected to mention before that I have been using Yesterday I tried I plan to make a PR with two things:
|
When I press "Reload" or the application reloads due to Live Reload being enabled, the onDestroy method of the module is not called. Because of that, the sockets (and streams) are no correctly disposed.
When the reload is finished, I can no longer open a bluetooth socket. It requires me to disable and enable bluetooth, or to restart the application.
Is there ant callback or method I could implement that would correctly dispose these sockets when I reload my application?
The text was updated successfully, but these errors were encountered: