cogentcore / core

A free and open source framework for building powerful, fast, elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the web with a single Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.75k stars 83 forks source link

Crashing in wasm in Chrome on Android when importing goldmark #780

Open kkoreilly opened 10 months ago

kkoreilly commented 10 months ago

EDIT: this issue is actually not a memory leak, but a wasm compilation / Chromium issue as described below.

Memory usage on web has increased by a factor of more than 5x since the version the Goki website is currently using. This might be caused by filesystem or resizing logic.

rcoreilly commented 10 months ago

This is happening on desktop too! we have a leak.

rcoreilly commented 10 months ago

running taskmanager and resizing it causes significant memory increase to itself.

rcoreilly commented 10 months ago

but continuously running taskmanager is very stable; as is running a large complex nnet model (boa) with lots of 3d and 2d updating happening at high frequency. it is definitely not leaking in any of the basic updating / rendering mechanisms.

my first report above was due to gide having to be killed due to excessive memory usage -- 390 GB or something crazy like that. so somewhere it seems to have something like an exponential leak.

rcoreilly commented 10 months ago

False alarm on gide: it appears to be due to an issue with go mod mode in packages with lots of go mod problems -- it is not something happening specifically within gi code. There might still be some kind of issue with taskmanager resizing while constantly updating but that may just be a lot of memory churn and not a leak. Just resizing gide continuously doesn't seem to be a problem (minor temporary memory increases).

rcoreilly commented 10 months ago

note: gide leak fixed.

kkoreilly commented 8 months ago

I can confirm that this still happens: the demo starts at 142 MB of memory usage on web, and then climbs to at least 506 MB. It seems to only climb when the tab is not open.

kkoreilly commented 8 months ago

This definitely only happens when the tab / window is not open / focused.

kkoreilly commented 6 months ago

I appear to have fixed the most severe memory leak issue in 3dcf77a, which resulted in apps crashing on mobile web due to excessive memory usage. It seems like there may still be a lower severity high memory usage issue on all platforms regarding both fonts and scrolling, and there are also still performance issues with gradient and text rendering, especially while scrolling. The font issues should be resolved when we start using go-text, and we need to look into the scrolling issues more.

kkoreilly commented 6 months ago

Just to be clear, the scrolling issue is that memory usage reliably and significantly increases when you scroll, and this increase persists as you continue to scroll. A good example of this is scrolling in the icons page in the demo. The performance issue is that the app noticeably lags when you render gradients and large blocks of text. This bad performance is particularly notable when scrolling.

kkoreilly commented 6 months ago

Actually, the excessive memory usage crash still seems to be happening on desktop occasionally.

kkoreilly commented 4 months ago

The crash on Android web is still happening, and I determined after hours of debugging that this issue is actually not a memory leak, but a bizarre wasm compilation / Chromium issue associated with goldmark (https://github.com/golang/go/issues/68156).

kkoreilly commented 4 months ago

As of a2313f0, we are now (at least temporarily) using a different markdown library, which prevents this issue from happening.