microsoft / microsoft/pxt-microbit

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

Open
#5,832 3 comments 0 reactions 1 assignee View on GitHub

@jwunderl is already working on this.

Since Aug 16, 2024.

P2 performance webusb
Dominant language
TypeScript
Stars
804
Forks
721
Avg merge
2d 9h
Merged PRs (30d)
2

Description

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]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.