pxt-microbit icon indicating copy to clipboard operation
pxt-microbit copied to clipboard

WebUSB connection creates high CPU usage, and possible memory leak in console

Open martinwork opened this issue 6 months ago • 3 comments

Describe the bug

Testing in beta, though I think this may apply to live too.

Just being WebUSB connected creates high CPU usage - adds approx. 40% on my computer.

Actually receiving data and displaying it in the console doesn't add much - a few %.

Using "Show data Device" sometimes triggers ever increasing memory usage, while the MakeCode tab is showing with the console displayed. It goes up and down but eventually more up than down.

I'm not sure what triggers it... possibly switching to another tab (like this one), then back to MakeCode while the console is displayed.

Just tested in Edge and it added approximately 2000 MB over 2 hours. First noticed with Chrome because the computer was behaving badly with >90% memory usage.

Example projects created in beta - import both to beta editor before testing skull-heart- https://makecode.microbit.org/_TiKaFo8yEcHq console- https://makecode.microbit.org/_TevYgyJ757Y0

To Reproduce Steps to reproduce the behavior:

  1. Open and Download project skull-heart (with no serial output)
  2. Disconnect WebUSB - CPU usage reduces
  3. Connect WebUSB - CPU usage increases
  4. Open and Download project console (with serial output)
  5. Click "Show data Device"
  6. Check memory usage

Expected behavior Less CPU usage just to be connected. Memory usage does not gradually increase to > 2500MB.

micro:bit version (please complete the following information): Tested with V2.21, but probably not hardware related

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10 Home
  • Browser [e.g. chrome, safari] Chrome, Edge
  • Version [e.g. 22]

martinwork avatar Aug 16 '24 21:08 martinwork