microsoft / microsoft/pxt-microbit
WebUSB connection creates high CPU usage, and possible memory leak in console
@jwunderl is already working on this.
Since Aug 16, 2024.
- 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:
- Open and Download project skull-heart (with no serial output)
- Disconnect WebUSB - CPU usage reduces
- Connect WebUSB - CPU usage increases
- Open and Download project console (with serial output)
- Click "Show data Device"
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.