Browser Crash When Using WebUSB and Nano33

I am having an issue with both MS Edge and Chrome crashing when trying to upload the data collected with the accelerometer on the Arduino Nano33 BLE Sense via the WebUSB interface. The data will occasionally upload (~20% of the time). Both Edge and Chrome are the latest versions. The accelerometer data has a duration of 5000ms and a sampling frequency of 100Hz. I have experienced this issue on several Mac and PC devices

EDIT: I can confirm that it is much more prevalent when running on a Mac

1 Like

Hi Corey,

Thanks for your message. We’ve been able to reproduce the crash, and we are investigating. We’ll get back to you as soon as we have more information about it!

Sergi.

1 Like

Hi @CoreyG we’ve identified the root cause and are pushing out a hotfix today or tomorrow.

Some background: when reading a file from the device we’re looking for an ending sequence (\r\nOK) in the data stream as an indication that the file was completely sent. To look for that ending sequence we keep concatting the previously received result and the new frame of data, and then searching for the sequence in the resulting buffer. These buffer concats take longer as the buffers get bigger, and at some point concatting takes longer than the time between ‘new data frames’, which at some point gets Chrome killed.

I’m not entirely sure why all of Chrome would be killed (I’d expect maybe the browser tab, but not the whole browser), nor why this behavior suddenly pops up (this was not the case when we released). Could be that the concatting now takes a slower code path or that we receive far more data events from WebSerial now. Anyway, we’ve rewritten the way we search for the end sequence and now this runs stable even on long samples for me and @sergi.

3 Likes

Awesome! Thank you for the quick response!

1 Like

@janjongboom, In my case the browser is still crashing (Accelerometer and sound), and it is all browser and not only the window. This happened twice during a live demo with my TinyML class (and also the Google Meet section was down). I am using the last version of Browser.
Thanks
Marcelo

@mjrovai Which board are you using and what’s your sample length / frequency?

@janjongboom, I am using Arduino Nano-33 Sense connected using Arduino-CLI. I used the default Studio length / frequency for both accelerometers (10s/100Hz) and mic (10s/16Khz). Using EI-CLI worked without problem, even during class (Google-Meet). BTW, I am using a Mac with Chrome.
Thanks

1 Like

I am having the same issue of Chrome on Mac crashing using WEBUSB with the Arduino Nano 33 Sense. Following the Audio example, five seconds of data is captured then Chrome crashes (or just fails to upload) immediately after data capture count down is reached and reading data attempts to start. In addition, on one occasion, Chrome crashed as soon as selecting the paired Nano 33 to connect. In one instance, Chrome crashed when Reading Data from Device was at 77% (10 second sample length, mic, 16000Hz frequency). Does the documentation link to “cdn.edgeimpulse.com” include the most current version of EdgeImpulse data capture firmware for the Nano 33?

@mjrovai thanks for confirming your success with the EI-CLI. Following the instructions on the tutorial, the install fails on my MacBook but I may troubleshoot the EI-CLI approach if the simpler Chrome WebUSB continues to crash most times.

@janjongboom @sergi I find the Chrome WebUSB data gathering crashes Chrome when reading sampled data (audio from mic tutorial) from the Nano 33 on two different Mac computers, while it works fine on a Windows 10 computer. I wonder if the tutorial link is for the updated nano 33 data capture firmware?

@Jim_Newcaretec Yeah it’s very weird. I’m gonna spend some time this week digging into this.

1 Like

So indeed I can also reproduce this again (immediate crash when offloading data from Nano 33 BLE Sense). So fun! Will investigate today.

edit: My feeling right now (based on the earlier investigation of a similar bug) is that we receive too many events too fast, with some of them potentially overlapping (so a new data frame comes in before the previous one was handled) and there is a mutex somewhere in the Chrome code which gets tripped because of this, leading to the hardfault. We’ve seen this in the past when our buffer handling code in the data event handler of the Web Serial API was not fast enough. The reason why this happens on the Nano 33 BLE Sense is that it’s using a much higher baud rate than other boards, leading to a lot less tolerance here (and changing between releases as well, as @sergi and I spent a lot of time looking at edge cases around random browser crashes a few months back, and the issue did not occur anymore on all fully supported dev boards). My next try is to see if adding artificial delays on the firmware side could help.

edit 2: Using smaller buffers and adding delays between writes indeed seems to resolve the issue, but at the cost of significant lower transmission speed. I’ve put together a beta build here:

https://cdn.edgeimpulse.com/firmware/arduino-nano-webserial-fix.zip

And will work on finalizing and landing a fix for everyone early next week. @Jim_Newcaretec @mjrovai

2 Likes

@janjongboom Excellent! Thanks for sharing the beta build and more importantly, the explanation of your investigation after being able to reproduce the problem. I hope to get a chance to try the beta build and confirm results before you have a chance to finalize the fix release. :smile:

@janjongboom Jan I was able to confirm the beta build of the Arduino Nano 33 BLE Sense firmware works for me using Chrome WebUSB on a MacBook Pro. The data reads much slower from the device but is successful at reading the mic data and uploading to Edge Impulse Data Acquisition. Thanks!

2 Likes

Hi @janjongboom - just to let you know the link gives an access denied msg atm (I’ll go back to using the CLI for now) :upside_down_face:

@Rainycat Oops! I realized I just uploaded the firmware to CDN directly - rather than going through our prebuilt firmware repository - and it was thus deleted when we did a new release of that. Have now added it properly!

Also I still need to fix this in the main firmware, stay tuned :slight_smile:

3 Likes

Hee thanks, Jan - will be interesting to see which method I prefer using! :heart_eyes_cat: :+1: :boom: