Bug 271765

Summary: [WPE] Add a soft limit to the amount of GPU memory BitmapTexturePool can hold
Product: WebKit Reporter: Miguel Gomez <magomez>
Component: WPE WebKitAssignee: Miguel Gomez <magomez>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Miguel Gomez
Reported 2024-03-27 08:35:39 PDT
As it works now, BitmapTexturePool can keep unused textures around for up to 3 seconds. This is a problem in some situations where there are a lot of allocations and releases of textures with different sizes that can't be reused. These textures stay in the pool consuming potentially a lot of GPU memory. In extreme cases these textures can consume the whole GPU memory on constrained devices. This situation can be easily reproducible with this page for example: <html> <head> <style> #animated { width: 100px; height: 100px; background-color: red; position: relative; animation-name: example; animation-duration: 20s; animation-iteration-count: infinite; animation-timing-function: linear; } @keyframes example { 0% {width: 100px; height: 100px;} 100% {width: 5000px; height: 5000px;} } </style> </head> <body> <div id="animated"></div> </body> </html> The div has a fast animation that makes it grow up from 100x100 to 5000x5000. Every frame of the animation requires creating a backingStore with a new size for the div, which requires allocating textures from the BitmapTexturePool for each of the tiles. These tiles have increasing sizes during the animation (for example, 20x20, then 21x21, then 22x22, until 512x512 max), so the textures used for them will also have those sizes, that can't be reused from previous steps of the animation. So with each frame of the animation we're allocating a new set of textures and keeping the old ones in the pool for 3 seconds. When running the HTML above, the pool can get to store more than 100MB of textures. We need some mechanism inside BitmapTexturePool to try to control this extreme growth.
Attachments
Miguel Gomez
Comment 1 2024-03-27 08:42:21 PDT
EWS
Comment 2 2024-04-03 07:38:02 PDT
Committed 276997@main (eff294d622ac): <https://commits.webkit.org/276997@main> Reviewed commits have been landed. Closing PR #26517 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.