Increased "White Flash" in newest updates???
-
@TMNTturtlguy I suppose a good way to troubleshoot is to ask these new cases:
- what ES were they on before the update;
- did they change theme recently;
I'll be fair, though. My bet (just gut feeling, not an educated guess) is that most of these complaints are either people who are just now installing RetroPie for the first time, or were in an older ES version prior to the WSOD fix and have now installed the build with the fix. The latter case will explain whereas prior to the update their entire theme was loaded into memory and luckily it fit, and now with the VRAM limit it doesn't. A way to mitigate that is, for those cases only, definitely to increase VRAM significantly, as they will never (hopefully) hit the limit. If it turns fully white with the glget errors, that's when we need to decrease it in order to force the textures to onload and recycle.
I might look into seeing if there's a smarter way to cache textures, but my understanding is that it won't. A texture, I think, is stored as an in memory bitmap. So, rough calculations, if that is indeed the case, a single 720p background image could be taking up something like
1280 * 720 pixels * 4 color values (RGBA) * 32-bit color depth (4 bytes) = 14MB of GPU memory1280 * 720 pixels * 4 bytes (32-bit color depth - RGBA) = 3.7MB of GPU memory
Now, add to that the logos, the gamelist view, any other system-related artwork and you can see this easily scaling up.
Of course, this may have some optimizations in the pipeline (16 bit color depth may halve it, if it's not transparent (24-bit) it may be reduced to 75%, etc...). It can be worse and be stored at full rendering resolution as well, which would mean 1920 * 1080... I don't know, will need to read up on that and investigate further. But it'll all depend on the underlying data structures and SDL GL capabilities.
So yeah, this is kind of what we're up against. Hope this clarifies.
I might try to create a build with a few profiling features just to output logs of all the memory usage by the textures, for each texture. Maybe that can inform theme decisions. But I think one key aspect is that, as far as actual runtime memory goes, resolution seems to be the key factor - not file format, nor color depth (unfortunately).
Edit: fixed the formula I pasted - was double counting the color depth. Also, checked in code that all non-svg images are loaded as 32-bit images, and that svgs go through a different pipeline which, at this stage, I don't know if it's more or less efficient than the other one.
-
Just a small update here, @TMNTturtlguy .
I spent a considerable amount of my free time the past few days looking into the whole texture management and memory consumption issues. I put together a few attempts at a profiling build (i.e. a build that provided logs on the texture loading, memory used, etc) but the results weren't really satisfactory given the extremely limited available resources to debug and get information from the Pi's GPU. The only way available that I was able to gather is via
sudo vcdbg reloc
, which unfortunately is one of the very few closed source components of the Pi software, so there's that.I'll keep digging into this a bit more, though I suspect I won't get a lot farther in this in the short term, so I'll need to balance this with investing time in other ES developments that may be more relevant to the wider community (specifically bringing over OMX support as an option, and screensaver to the main branch).
If you want to get a bit more insights into this yourself - or at least see what may be happening - I'd recommend installing the script at
https://github.com/MilhouseVH/bcmstat
and running it as./bcmstat.sh Dd2
(the "2" standing for the refresh period in seconds - you can change the number) in a SSH session, while you have ES running.Also, running
sudo vcdbg reloc
will display the loaded textures and memory taken, though unfortunately in a somewhat useless manner for us as we don't know which texture block actually corresponds to in our themes. Still, interesting for a one off exploration thingie.Anyways, that's where we're at, and likely where we'll be heading shortly in the coming days. If nothing comes out of it, I'll move on for now. Overall, I think your time is best spent with your theme rather than trying to troubleshoot this for now :D
Hope you're doing well and have a great weekend!
-
@pjft WOW! thanks for the information and spending all that time looking into this! I really appreciate it and the follow through. I am going to bookmark this to come back to after I finish my upcoming theme update release. I am always interested in trying to track things and see if I can make sense of how my changes affect the overall performance.
Per our previous dialogue above, ES runs with a ton of systems loaded. With my newest updates I have been testing the systems and I have had 22 systems all loaded and scrolling without getting any errors or white screens, just the flashing. To me this is excellent. To have a theme as robust as mine and 22 themes scrolling smoothly is great, especially when I plan to run 12-16 systems.
Hope you have a great weekend as well. The family and I are heading out of town for a few days so I will be without my pi :( but at least i will have forum access to feed my addiction.
-
@TMNTturtlguy Haha - well done! I believe you mentioned you had been traveling for work - hope it all went well, and enjoy your time with the family, which is always precious.
For the sake of your fun, here are some excerpts of:
- Logs from the bcmstat.sh GPU stats tool during one ES session as well.
- The logs for a ES session and navigating the system view - they're somewhat superficial, though it's hard to get better granularity at the moment, I need to understand the code better. I also removed several logs from parts of the code where I thought they'd be using up GPU memory but weren't in the end. Still, I may be missing quite a few as well, so we'll see where this takes us. You'll see some floating - in particular when releasingVRAM - as that's the code from the Texture Manager to prevent the WSOD. I have my VRAM limit set to 70MB. I assume if I increase it significantly, we'll see this going down until it hits zero.
- A sample from the vcdbg tool.
As I said, nothing particularly helpful without context, though it allowed me to observe a few interesting things in regards to the texture memory management - namely which ones are released and when. It seems ES currently tries to always buffer the system to the right and to the left of the currently selected one, in the SystemView, likely to avoid the white screens. So I'll need to see if the white screens are related to low memory, which in turn leads to slowdown in loading caused perhaps by the VRAM release process or some texture management things that take place.
So yeah, it's been useful, though still unclear whether anything tangible will come out of this from my end.
-
@TMNTturtlguy Ok, I'm onto something in regards to memory consumption, from observing the logs and thinking about it.
Putting it simply: get rid of the border SVGs and integrate them in the background PNGs.
Putting it in more detail:
- Each of your background images takes up 6MB in memory.
- Each of the SVGs you load take up 13MB.
So, for each new system you load, it takes up the absurd amount of 19-20MB - only in the system view!
I tried to edit the theme to load the SVG border from the same path (rather than from each of the individual system folders) but ES isn't especially smart, and will create different textures in memory for each of the systems, even if it's the exact same file. So that didn't work.
I'll try to look into that code and see if I can key the textures by path (which would make some sense...), and that could certainly hope quite a bit with redundancy and such.
Until that's available, though, (or, if it does not affect your theme's aspect in any way) my recommendation is to get rid of the border svgs.
You can perform a very simple test by renaming the border and menu SVG files to a different name, temporarily, and then just loading ES and browsing through the theme. You'll see the difference it'll make.
I'm happy with this outcome/discovery, as at least it gives me some path forward (i.e. attempt to not load duplicates of the exact same textures). Whether that a) is possible, b) solves it, and c) does not bring new problems with it remains to be seen, but fingers crossed.
Have a great family weekend now, though, don't think too much about this :)
-
Ok, and asides from the memory thing, I will add an option to not show white screens.
They show because we're loading textures in separate threads, and as they're heavy to render they'll sometimes choke the GPU and take slightly longer to load. I'll add an option to not load images in separate threads, should the user choose to.
In reality, that'll probably be the preferred option, though it might not feel as smooth to navigate in heavier themes.
-
@TMNTturtlguy from what @pift mentioned, it seems your theme + systems have been draining you of the mb that you have. I'm pretty sure that it's not just the theme and systems that drain but also all the box arts as well (boxarts can be very large and slow down scrolling and such). As a means of attempting to fix that sort of issue could probably be done in a few ways. You could replace svgs to png if that would shrink size (not sure haven;t tested) then compress the pngs afterwards using "pngoptimizer". Id assuming you have also tested with raising the gpu_mem=, but figured id mention the obvious anyways. This could help with reducing the entire theme as well as any box art that may not have been resized.
-
@Omnija thanks, the .png files are already heavily compressed as is, any further compression and we loose quality and the dithering of the images is increased. As for box art, that will depend on what each individual has on there system, my theme cannot control that.
-
@Omnija Thanks.
Just to clarify, the image size on the HD does not have any reflection in the actual GPU memory usage, but rather its size/resolution. Indeed merging the backgrounds with the SVGs could help.
In other news, I've submitted a PR to mitigate this.
Let's see. It's not really fixed per se, but I'm adding two options for users with heavier themes to exchange smooth navigation for little to no white screens. Well, except for VRAM related ones :)
@TMNTturtlguy - as usual, you may find it in my repository as well.
Best.
-
@pjft if we select this option will we just get a blank(black) screen while the next image loads?
Edit: and I am gone for the weekend! Shoot! I will be testing this late Sunday night for sure! Thanks for your hard work!
-
@TMNTturtlguy It depends on the transition you have. If using "Fade", then yes, it'll just stay in the black screen for slightly longer.
If using slide, it may have a slight stutter.
I strongly recommend merging the SVG frames with the background PNGs, though. After you test your theme without the SVGs (by renaming them), you'll see the huge difference. Seriously.
Enjoy the weekend.
-
@pjft the problem is the theme backgrounds will no longer look nice and will not adjust to larger screen sizes. The .svg allows the line work to resize to large HDTV screens and 4K resolutions while staying crisp. The line work as a .png will be very jagged at all angles lines. If you look at the video view game selection view and the angles lines by the box art closely, you will see the jaggy effect on a larger screen. Those are short lines so they are not supper noticeable and I chose to merge the line work. One option would be to create a separate .png with the black lines, but that file size will need to be larger so that when upscale it stays clear. Any idea how using a secon .png would affect it?
-
@TMNTturtlguy I suspect that'll be a non-factor for the Pi, as its max output resolution is 1920x1080 via the HDMI port. However, for PC that may certainly be a factor.
As I mentioned, a second image will take up as much memory as its resolution - refer to my earlier post with the formula.
If you want to, my best recommendation would be to make a Pi theme with the backgrounds merged, and - if you then feel, after testing at higher resolution, that it loses a lot - an HD version where you'd have the separate SVG files. It's a bigger burden for maintenance, though, so I wouldn't take that decision lightly. That being said, if you still have everything in Photoshop format, together with the borders, maybe you can just batch process all and generate both versions easily though?
Anyway, you'll be able to judge by yourself later, but the Pi is an impressive, yet severely constrained device in terms of hardware, let's not forget :)
We can't have our Pie and eat it too. (Bad pun intended).
And I'll take a moment and say, after so much time going through the code, what an amazing job @fieldofcows did with the texture manager. Really, asides from not failing gracefully if it does run out of memory, it is truly an excellent, fantastic piece of work.
-
@pjft as always your knowledge and service is absolutely wonderful and so very much appreciated. I have re-read your posts and have a few questions, or confirmations. Per your formula you suggest that 720x1280 should take up 4mb. My backgrounds are all 720x1280, but your testing shows the .png is using 6mb. Where are the extra 2mb coming from? The system logos?
Also, from what I now understand, the file size does not matter? Would a 512kb .png perform the same as a 5mb .png if both are 720x1280? Not that I want my files that large but just asking. @Nismo has previously indicated that as the file sizes increase the amount of memory increases. Under 512 uses 256mb and above uses 1024 I think? Can't remember the exacts and I am on my phone now!
Edit: found the great posts from @Nismo which related to everything @pjft is talking about and also references @fieldofcows work as well. Yes, I know.....@Nismo suggested the .svg are bad as well! 10 days ago!!! But it looks so much better! As @pjft suggested, I want to eat my pie too! Here is the link to the post link to Nismo post
I will try to merge and see what happens. If I merge the black lines over the already compressed background and flatten, it might be ok.
-
@pjft Ok, so i don't have my pi with me, but i do have my computer and photoshop. Family went to bed and i have spent a few hours trying different ways to get the black boarder to appear clean and crisp and still compress down below 512kb. I think I have done it, but I can't test it from here. If you have time this weekend. I have uploaded a few of the backgrounds i have created. If you would copy these into the theme and name them comic in their corresponding folders. Also rename the .svg file so it does not show up anymore.
If you would want to, you could put these into the theme and then scroll back and forth between these and the other systems that would still have the .svg and let me know what you think? You have a great eye and a great screen to see little details, so I am confident in your opinion. If you don't have time to test, that is ok as well. You have pushed me to keep improving so I will definitely test on Sunday evening. Thank you - Link to github test backgrounds: TempThemeBackground
-
@TMNTturtlguy Thanks.
I tested them, and effectively they look more jagged than ideal.
I tested creating 1080p images, and they looked crisper, but the navigation appears to have become as bad as like the version with SVGs. It appears the bottleneck is not as much the memory (even though it does affect performance when we need to start unloading and loading them from memory), but rendering speed.
I got logs from them, but haven't really spent time looking at them in detail. Here's the link, just for curious people:
I suspect that, if the PR I submitted goes through, you may be able just to keep the theme as is for the time being, and then we'll see if it does need to be optimized further or not. I'd still recommend getting all the individual system themes to point to the shared SVG for the borders, though, in order to save memory (i.e. in individual systems, instead of pointing to
./art/border_4-3Outline.svg
point to./../art/border_4-3Outline.svg
.Other than that, you do want the theme to look crisp so let's not worry about that for now :)
I'm uploading the themes I used for testing - a full 1080p-noSVG version, a full 720p-noSVG version, and your regular SVG one, pointing to the same SVG border files (I think). You can test these 3, just for a feel, both with the current ES you have, as well as with the one from my repository if you want to update. There'll be two options in the "Other Settings" menu - you'll want to turn off Multithreaded images, to get rid of the white screens, and then test the 4 themes to see the difference.
If you choose to select the "Re-Use SVG images" (I think that's the name), you may need to re-load ES/the theme, so that it only loads one copy in memory.
That's it!
Have a great weekend, and do enjoy your time off - it's precious as well. Plenty of time for tinkering when you're back :)
-
@TMNTturtlguy actually, just made a new change that solves the white screen problem for good.
I won't describe what it was, as it would almost sound like a punchline for comedic effect, but update from my repository and try it out before changing any other options.
-
@pjft really! Now I am super excited! Thanks for all the hard work and testing. Disappointing the new backgrounds are still jagged but I expected that. Those angled lines are just to hard to render.
Again, so excited to test the new update! Thanks and you need to take some time off for the family as well!
-
@TMNTturtlguy thanks. I ended up putting up a set of videos of the changes, using TronkyFran, for the PR.
Apologies for any baby sounds in the background. :)
Hopefully can give you an idea of what to expect. Unfortunately the theme does not have all my systems (or did not when I got it) so that's why done screens are just fully white/black.
Enjoy your weekend!
-
@pjft reminds me I need to update the theme with a few more systems... I'll try and do that today
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.