buttplug-rs-ffi
buttplug-rs-ffi copied to clipboard
WebBluetooth writes panic on failure
Someone with a fussy on-board bluetooth radio reported a stack that had a panic in the WebBluetoothDevice write() method.
panicked at 'called `Option::unwrap()` on a `None` value', src\wasm\webbluetooth_device.rs:126:53
This was most likely an honest failure to write, but we shouldn't unwrap Nones there, we should return an error.
I've encountered write failures of this exact nature when forcibly removing my computer's bluetooth dongle.
I managed to quell these panics by responding to BluetoothDevice's gattserverdisconnected event as done in chrome's bluetooth samples: https://googlechrome.github.io/samples/web-bluetooth/device-disconnect.html
Here's the WIP branch. It probably doesn't solve all panic cases, but it's a start for this type of error: CirrusNeptune/buttplug-rs-ffi@f211160b1775f3ab0d4462c48e6009bb6a93dfaf