Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Chrome out of memory on large programs #1804

Open
laurensvalk opened this issue Sep 5, 2024 · 11 comments
Open

[Bug] Chrome out of memory on large programs #1804

laurensvalk opened this issue Sep 5, 2024 · 11 comments
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application

Comments

@laurensvalk
Copy link
Member

laurensvalk commented Sep 5, 2024

While creating a few big programs to test the limits of our hub file storage, I noticed that Pybricks Code can crash Chrome. In one case, it dropped into the debugger before the potential memory issue. In other cases, Chrome crashes with SIGILL.

This is a bit of an unusual program, but not entirely out of the ordinary. If someone wants to include a binary blob to include some extra data, a program may look not unlike the one below.

Example. long_program.py.txt

It still works if you cut it in half. It's only 18Kb as a compiled .mpy program. Should probably retry with randomized strings to avoid string compression being a factor.

from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch

hub = PrimeHub()

data = b"132456789132456789132456789132456789132456789132456789132456789132456789"
data = b"132456789132456789132456789132456789132456789132456789132456789132456789"
data = b"132456789132456789132456789132456789132456789132456789132456789132456789"

# Repeat this MANY more times. Too big for a GitHub post. See attachment for whole file.

data = b"132456789132456789132456789132456789132456789132456789132456789132456789"
data = b"132456789132456789132456789132456789132456789132456789132456789132456789"
data = b"132456789132456789132456789132456789132456789132456789132456789132456789"
data = b"132456789132456789132456789132456789132456789132456789132456789132456789"

hub.light.on(Color.BLUE)
wait(10000)
@laurensvalk laurensvalk added bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application labels Sep 5, 2024
@dlech
Copy link
Member

dlech commented Sep 8, 2024

Apparently, this is caused by the Python parser that we are using to find resolve imports.

https://github.com/pybricks/python-program-analysis

@ggramlich
Copy link

@laurensvalk One of my boys uses Chrome and when trying to open code.pybricks.com, the browser and also screen recording software crashes after a few seconds, so I could not record a video.
I already tried to delete cookies and caches.
In incognito mode he can use pybricks.
I think that the programs are still in stored in chrome and that causes the problem, but I don't know how to delete them.
Might this be related with this bug? Can you help us deleting the programs, if that might cause the problem?

@laurensvalk
Copy link
Member Author

Thanks for reporting. I watched your video. Very unusual.

I think that the programs are still in stored in chrome and that causes the problem, but I don't know how to delete them.

From your video, you can see clear site data. That should do it.

image

@ggramlich
Copy link

ggramlich commented Oct 3, 2024 via email

@laurensvalk
Copy link
Member Author

Is there anything left in local storage?

image

Or IndexedDB > pybricks.fileStorage > contents

image

@laurensvalk
Copy link
Member Author

laurensvalk commented Oct 3, 2024

Does anything show in the console?
image

@ggramlich
Copy link

@laurensvalk Unfortunately I was not able to dig deeper into it and probably won't be able to do so within the next week as the boy has his laptop with him.
The boy now uses the beta version, which does not cause the problem (neither does incognito mode).
As you saw in the videos, you only have about one second to react after opening the page, so opening a specific node in the Indexed DB tree will be close to impossible. But I will try to see, what I can find in the file system under AppData\Local\Google\Chrome\User Data\Default\Local Storage

@ggramlich
Copy link

@laurensvalk We were able to look at the console output. It showed only the first output "starting Pyodide..." before Chrome crashed.
Then I was able to locate the IndexedDB Folder under AppData\Local\Google\Chrome\User Data\IndexedDB
The folder for code.pybricks.com showed 4 GB (3.73 GiB) Disk Usage. After deleting the folder, it is possible to use pybricks again.

image

@laurensvalk
Copy link
Member Author

Were you able to create a backup of the folder before deleting it, by any chance?

@ggramlich
Copy link

Sorry - I don't have a backup. I wanted to copy the folder over to our Google Drive shared folder, but the 4 GB were too much. I could have used a USB Stick but we were in our practice under a bit of time pressure.

@laurensvalk
Copy link
Member Author

No problem at all. Thanks as always for taking the time to report this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application
Projects
None yet
Development

No branches or pull requests

3 participants