Closed s0hey1 closed 5 months ago
We don't even need a large file to reproduce this. Just gg and Shift+g increases memory usage.
Is anyone else still able to reproduce this? I tried it on my Windows 11 machine, and there does not seem to be a memory leak for me. Perhaps the issue has been resolved upstream?
@fredizzimo I can still reproduce this issue with latest build from source as mentioned above.
Memory leak is very specific to these cursor vfx "railgun" or "torpedo". I tested with railgun alone.
We don't even need a large file to reproduce this. Just gg and Shift+g increases memory usage.
cht1KMwkEl.mp4
I was able to repeat it now, or at least almost.
But it's quite strange. I tried it manually, the memory actually went slightly down, when repeating around 10 times.
Then I recorded a macro, and repeated 100 times, the memory jumped around a bit, growing and then getting down again, but eventually it ended up at around 200MB, from 60MB when I started.
I tried manually again, after that, but the memory usage remained stable.
Then I tried repeating the macro 1000 times, for a long time it stayed stable at around 300, then jumped up, stayed reasonably stable, jumped up and so on. But I closed it at around 700MB, after it had been running for quite a while. It seems to get exponentially slower, since 100 times did not take long, but 1000 seems to take quite a while. So I guess there's some data structure that grows and makes things slower in addition to leaking memory
From these tests, my conclusion is that the problem is related to timing, perhaps a threading race condition.
@fredizzimo I am not sure but i can reproduce simply within ten steps just with gg and shift+g actions. NOTE: I use g.neovide_cursor_vfx_particle_density=25, which is higher than default.
Screen recording for reference.
Yes, I'm definitely not able to reproduce it that easily. I may be able to get to to increase very slightly in debug mode and spamming the keys, but that's just by a few megabytes at most.
I don't think it's an operating system issue, since you are on Windows, the original @s0hey1 seems to be on linux, judging from the callstack, and I'm on Windows 11. I also tried it through WSLg, and wasn't able to repeat it there either. And I tried both the release and debug version.
I do notice something strange in the original call stack though. It seems to load a font, and I don't think that should happen unless you actually change the font, or when you encounter a new character so that the fallback font is used.
I don't have time to test it right now, but perhaps you could add some logging around that to verify?
I managed to find time to do a quick test with the fonts.
Calling :set guifont= causes a memory leak of similar size per call. I don't know why the cursor effect would load any font though
I tested some more with the fonts, and the :set guifont
only seem to leak memory when specifying a non-nerd font based font, or very likely more specifically a font that's lacking some glyphs on the screen. Manually adding a fallback font is enough to make it not leak memory.
Anyway, that sounds like it should be a quite easy fix. But I still haven't managed to properly reproduce the cursor effect memory leak. @dineshKumar777 or someone else, could you provide the log file too? Maybe there's something in there that gives a clue of what's happening.
@fredizzimo neovide_rCURRENT.log
I checked the log, and it does not seem to load any fonts, so that might be a different memory leak.
And comparing them to mine, I didn't see anything obvious, but there might be a clue TRACE [neovide::editor] viewport event received before window initialized
. There's one of those for each of the G
and gg
. My log file also has some of the same messages, but not during scrolling.
@Kethku any idea or suggestions!!!
Not sure! I'll have to look into it tomorrow. It's very late here.
@dineshKumar777, since that's a multigrid event, could you try without multigrid, to see if it still leaks memory? But it's not as simple as multi-grid causing it, since I also have it enabled. Also more likely than not, the log message is not releated to the memory leak, but it's probably worth a shot.
@fredizzimo actually till now I didn't use multigrid.
Yes, sorry for the confusion, it seems like neovim sends that event even if you don't have multi-grid enabled although the documentation says it's multigrid specific here https://neovim.io/doc/user/ui.html.
I tested without multigrid myself, and I get the same errors, but no memory leaks, so the error is unrelated like I suspected.
It seems no matter what I do, I can't reproduce it here on my end. But after looking at the code I agree with @s0hey1, it looks like it's a bug inside skia
and draw_oval
. It should be easy enough to verify by changing this
https://github.com/neovide/neovide/blob/main/src/renderer/cursor_renderer/cursor_vfx.rs#L355
to draw_rect
instead of draw_oval
. Can you test that @dineshKumar777?
Can you also verify that you have the same version of skia as I have in the Cargo.lock
file
name = "skia-bindings"
version = "0.42.1"
@fredizzimo having same skiabinding version which you mentioned.
It seems draw_oval is the issue. Changing to draw_rect doesnt cause memory leak.
This is also something that I experience (Windows 11). I can't seem to reproduce it consistently, but I did manage to get neovide to crash shortly after starting while running --log
. Also, fwiw, use pixiedust
with a density of 25.0
.
Ok, good.
There are a few newer versions of skia, which you could try by editing the Cargo.toml
file.
https://github.com/rust-skia/rust-skia/releases.
Also you could check 'target\release\build\skia-bindings-2a29641b9acc3126\output', to see that the exact same version of the native skia
is used
Mine shows
**cargo:rerun-if-env-changed=SKIA_DEBUG
cargo:rerun-if-env-changed=SKIA_SOURCE_DIR
cargo:rerun-if-env-changed=FORCE_SKIA_BUILD
cargo:rerun-if-env-changed=FORCE_SKIA_BINARIES_DOWNLOAD
TRYING TO DOWNLOAD AND INSTALL SKIA BINARIES: 0.42.1/8b53a6e3e746b7456997-x86_64-pc-windows-msvc-gl
cargo:rerun-if-env-changed=SKIA_BINARIES_URL
FROM: https://github.com/rust-skia/skia-binaries/releases/download/0.42.1/skia-binaries-8b53a6e3e746b7456997-x86_64-pc-windows-msvc-gl.tar.gz
UNPACKING ARCHIVE INTO: C:\proj\neovide\target\debug\build\skia-bindings-ce6a25a6ec4782eb\out\skia
INSTALLING BINDINGS
DOWNLOAD AND INSTALL SUCCEEDED
cargo:rustc-link-search=C:\proj\neovide\target\debug\build\skia-bindings-ce6a25a6ec4782eb\out\skia
cargo:rustc-link-lib=skia
cargo:rustc-link-lib=skia-bindings
cargo:rustc-link-lib=usp10
cargo:rustc-link-lib=ole32
cargo:rustc-link-lib=user32
cargo:rustc-link-lib=gdi32
cargo:rustc-link-lib=fontsub
cargo:rustc-link-lib=opengl32**
@fredizzimo my output is same as yours. Issue is reproducible in latest 0.45.1 skia too.
That's bad news :(
What graphics card do you have? I saw that skia takes slightly different code paths depending on the graphics card. I have an RTX 3060 here.
@fredizzimo I am using in laptop which have intel integrated graphics
Card name: Intel(R) UHD Graphics
Manufacturer: Intel Corporation
Chip type: Intel(R) UHD Graphics Family
DAC type: Internal
Device Type: Full Device (POST)
Device Key: Enum\PCI\VEN_8086&DEV_9B41&SUBSYS_507A17AA&REV_02
Device Status: 0180200A [DN_DRIVER_LOADED|DN_STARTED|DN_DISABLEABLE|DN_NT_ENUMERATOR|DN_NT_DRIVER]
Device Problem Code: No Problem Driver Problem Code: Unknown Display Memory: 8224 MB Dedicated Memory: 128 MB Shared Memory: 8096 MB Current Mode: 1920 x 1080 (32 bit) (59Hz)
That could be the difference then. But I guess we need more testers with different hardware.
After some thought, I think the best way forward with this, is to make a minimal example program, which doesn't do anything else than drawing ovals using skia, to see if the issue occurs with that as well. I won't do that myself, since I rather concentrate on other things, but someone with good Rust knowledge can probably do it in an hour or so.
If that example has problems it could be sent upstream, and hopefully fixed there.
I can throw something like this together pretty quickly sometime soon. Thanks for the in depth investigation
Yeah experiencing same problem on latest master still. I noted it mostly has to do with the cursor movement. EG in normal mode: Shitft-G // to go to top : //to enter command mode Esc //to exit command mode
Repeat and memory keeps growing. Windows 10
We still need an example program if someone is interested in doing that. Perhaps it even happens here https://fiddle.skia.org/?
After that we should determine which hardware it occurs on, and send a bug report to https://issues.skia.org/issues?q=status:open
It looks like the issue is restricted to the integrated intel GPUs. So, I suggest that anyone with the problem try to update their drivers and see if that fixes the issue.
Updating the graphics card currently cannot solve the problem. It seems that we can only wait until later.
Intel ARC A770 also has this problem. It seems that as long as it is Intel, there is a problem
@MOldtime, can you try to create a fiddle in https://fiddle.skia.org that does some animation using a lot of draw_oval
? And see if you see a memory leak there too? If that's the case we have something to report to skia.
If not then we might have to create an example using the raw c++ version of skia.
But I think we have tracked it down to draw_oval
at this point already.
It's possible that it does not happen though, since the browser version of skia is using Angle, which wraps opengl inside Direct3D, and the bug might be in just the Windows opengl implementation.
But we might move to Direct3D on Windows for Neovide, so that might also fix it.
@MOldtime, can you try to create a fiddle in https://fiddle.skia.org that does some animation using a lot of
draw_oval
? And see if you see a memory leak there too? If that's the case we have something to report to skia.If not then we might have to create an example using the raw c++ version of skia.
But I think we have tracked it down to
draw_oval
at this point already.
I am not familiar with SKIA, I donβt know if it is effective. It seems that the memory has not changed much Firefox browser used
void draw(SkCanvas* canvas) {
for (int i = 0; i < 100000; i++) {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(10);
canvas->drawLine(20, 20, 100, 100, p);
}
}
I think it needs some kind of animation, which can be enabled in the options, with a canvas clear for each frame.
But I don't know exactly how that should be done, and how you wait for the new frame. I can try it later at some point if you don't figure out how.
I tried it and made animations. I needed to introduce head files, but I donβt know the path of the file. I canβt find the file
Thanks for the repair, this branch solved the problem Test equipment: intel Arc a770 https://github.com/neovide/neovide/pull/2215
Came here as a new Neovide user investigating memory leaks. Currently looking at 6.1GB on a Nvidia 3080 Ti Laptop π’ Open help, ctrl-F and B to scroll up and down a few times, now 7.1GB π± (the spike on right in this image)
I must admit I'm mainly using Neovide cuz I fell in love with Railgun effect π (so cool) Using Railgun (default settings). Disabling stops the leak. Nvidia driver 551.61. External monitor (where Neovide running) 2560x1600. Win 11. Intel 12'th gen CPU. Asus laptop.
Will @fredizzimo 's #2215 PR likely help? If so, any update on when it might land? (wondering if I should invest in trying to build locally?) If not, LMK other info I can provide to help diagnose! Thx
@Arakade, I don't think there should be a memory leak with your graphics card, so it likely won't help, although I might be wrong. But for older graphics card it should.
But are you checking the memory usage of just Neovide or the whole process tree of Neovide? Because Neovim, well actually the language servers can easily use several GB of memory.
@Arakade, I don't think there should be a memory leak with your graphics card, so it likely won't help, although I might be wrong. But for older graphics card it should.
Oh. boo.
Because Neovim, well actually the language servers can easily use several GB of memory.
...from paging up and down with railgun enabled vs it being fine without it enabled? Figured that was more of a front-end thing?
But are you checking the memory usage of just Neovide or the whole process tree of Neovide?
I'm using Process Explorer which I'm pretty sure measures the selected process (not sub processes). Regardless am I right thinking I should be able to isolate them by running a NeoVim server and directing Neovide to attach to it then measuring the latter only? I'll try that in a bit. (presume won't make a difference whether TCP / Win pipe, right?)
I just tried building your fork. Getting compile errors but quite likely some naive fault on my side. Maybe you can spot my mistake? I followed instructions here. Wasn't sure what I should do for (4) in that list so could believe graphics libraries might be out of date. (might be good to update to provide pointers for noobs like me π)
Admin console:
choco install cmake --installargs '"ADD_CMAKE_TO_PATH=System"' -y
choco install llvm -y
User console:
rustup update
cargo install --git https://github.com/fredizzimo/neovide.git
Attached build log. neovide-build-01.log Any ideas?
error[E0432]: unresolved import `tokio_util::compat`
--> src\bridge\create.rs:17:17
|
17 | use tokio_util::compat::TokioAsyncReadCompatExt;
| ^^^^^^ could not find `compat` in `tokio_util`
p.s. Thanks so much for taking the time to reply before! π
Definitely front-end and definitely railgun.
Ran with separate process per the instructions. Graphing memory on Neovide only, paging up and down with ctrl-F and B. First flatish line is with railgun disabled. The steep slope is where I enabled it.
HTH
@Arakade, you need to specify the branch when installing too, so
cargo install --git https://github.com/fredizzimo/neovide.git --branch 'fsundvik/d3d'
@Arakade, you need to specify the branch when installing too, so
cargo install --git https://github.com/fredizzimo/neovide.git --branch 'fsundvik/d3d'
Ahha, yep, that'd make sense. Aaaaannnd, it builds aaaaannnnnnd, it fixes it! π (well either this does or some factor I'm not controlling for -- I haven't built main branch to be 100% certain but assuming dependencies are controlled for, it's a good bet.)
Yes, the usual test:
The orange arrow is where I enabled railgun and continued my insane paging up and down. (the first plateau is start, next is after opening help cursor
(my usual test file for some reason).
So I'd say the sooner this gets merged the better! Thx for your help. I'll be using my own-built version of your fork for now π
Describe the bug when i activate cursor vfx the "railgun" or "torpedo" , memory usage is constantly growing and eventually crash neovide, i think skia drawOval has memory leak and cause heap fragmentation. the drawRect has not this problem.
To Reproduce scroll up and down a large file while the cursor vfx is active
Desktop (please complete the following information):
Additional context stack backtrace:
or