Skip to content

render: Flush GPU work periodically during cache entry processing to fix OOM error#23175

Merged
kjarosh merged 1 commit intoruffle-rs:masterfrom
Bubby4j:fix-oom-cache-flush
Mar 3, 2026
Merged

render: Flush GPU work periodically during cache entry processing to fix OOM error#23175
kjarosh merged 1 commit intoruffle-rs:masterfrom
Bubby4j:fix-oom-cache-flush

Conversation

@Bubby4j
Copy link
Contributor

@Bubby4j Bubby4j commented Mar 3, 2026

(This is my first Ruffle contribution, please review critically - this was AI generated but did fix the issue I'm seeing)

When rendering objects with extremely large dimensions whose cacheAsBitmap is skipped (in my case 6.7M × 6.7M pixel objects), their children's bitmap caches are all submitted in a single GPU frame without any intermediate flushes. This accumulates GPU resources until the device runs out of memory.

Root Cause
In submit_frame, the cache_entries loop renders all cached bitmaps sequentially without calling maybe_flush(). The existing maybe_flush() mechanism (which periodically submits GPU work to prevent OOM) was only being invoked during command rendering, not during cache entry rendering.

Fix
Call self.active_frame.maybe_flush() inside the cache_entries loop, matching the pattern already used elsewhere to bound GPU resource accumulation within a single frame.

Testing
Tested with a SWF file that previously triggered a WGPU OOM crash due to a ~6.7 million pixel object. The crash no longer occurs.

@Lord-McSweeney Lord-McSweeney added A-rendering Area: Rendering & Graphics render-wgpu Issues relating to the wgpu renderer T-perf Type: Performance Improvements llm The PR contains mostly LLM-generated code labels Mar 3, 2026
Copy link
Member

@kjarosh kjarosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, that sounds reasonable. Thank you!

@kjarosh
Copy link
Member

kjarosh commented Mar 3, 2026

I'll mark it as newsworthy in advance, but we'll have to see if we get fewer OOM reports after merging it.

@kjarosh kjarosh added newsworthy squash-on-merge Marks a PR to be squashed before merging. labels Mar 3, 2026
@kjarosh
Copy link
Member

kjarosh commented Mar 3, 2026

Just a note for the future: if this causes performance regressions, I think we should tune MAX_DRAWS_PER_FLUSH.

@kjarosh kjarosh force-pushed the fix-oom-cache-flush branch from fbe5a5e to c737370 Compare March 3, 2026 14:11
@kjarosh kjarosh force-pushed the fix-oom-cache-flush branch from c737370 to e83cc94 Compare March 3, 2026 14:27
@kjarosh kjarosh enabled auto-merge (squash) March 3, 2026 14:33
@kjarosh kjarosh merged commit 164a092 into ruffle-rs:master Mar 3, 2026
26 checks passed
@kjarosh kjarosh removed the squash-on-merge Marks a PR to be squashed before merging. label Mar 3, 2026
Hancock33 added a commit to Hancock33/batocera.piboy that referenced this pull request Mar 8, 2026
-------------------------------------------------------------------------------------
azahar.mk d49aa070fd73ea4dc0190c2483a30a22dbd41199 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------
qt: Always receive camera data from UI thread (#1812)

* Make camera functions thread-safe

* Revert redundant changes to qt_multimedia_camera.h and add comments to qt_camera_base.cpp,

------------------------------------------------------------------------------------------
dolphin-emu.mk 239c4e444c82c811eb321481aa26fe3a94d3b3c5 # Version: Commits on Mar 04, 2026
------------------------------------------------------------------------------------------
Merge pull request #14279 from jordan-woyak/nfs-hp2-speedhack

GameSettings: Add patches for Need for Speed: Hot Pursuit 2 to limit the internal frame rate.,

------------------------------------------------------------------------------------------
duckstation.mk 8d010533199b8783bc0c543479f857cd40504586 # Version: Commits on Mar 03, 2026
------------------------------------------------------------------------------------------
Achievements: Add pinning of measured achievements,

--------------------------------------------------------------------------------------
melonds.mk 303848124f765100d414398404ec7b57b83630f6 # Version: Commits on Mar 04, 2026
--------------------------------------------------------------------------------------
nix: update flake inputs and increment version number,

----------------------------------------------------
pcsx2.mk v2.7.151 # Version: Commits on Mar 03, 2026
----------------------------------------------------
- [Qt: Adjust positioning of window for fullscreen](PCSX2/pcsx2#14079)

-------------------------------------------------------------------------------------
ppsspp.mk ecb5cf036e7947ed6358b68bcead692f00425d99 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------
Merge pull request #21341 from hrydgard/more-regression-fixes

Fix crash on audio device switch in Windows,

------------------------------------------------------------------------------------
rpcs3.mk d46ddcee5d8db68d7f856c5e7015bffc651b419f # Version: Commits on Mar 04, 2026
------------------------------------------------------------------------------------
Fix mac build,

-------------------------------------------------------------------------------------------
xenia-canary.mk e576f3d9249e1ffb6bbfad1b0c7ce6438e4a9b97 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------------
[Cmake] Added directory split in Visual studio (and probably other IDEs)

Back as it was:

- src

- third_party

There is CmakePredefinedTargets, but it cannot be hidden

There is also an issue with tests as they aren't visible,

-------------------------------------------------------------------------------------------
xenia-native.mk e576f3d9249e1ffb6bbfad1b0c7ce6438e4a9b97 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------------
[Cmake] Added directory split in Visual studio (and probably other IDEs)

Back as it was:

- src

- third_party

There is CmakePredefinedTargets, but it cannot be hidden

There is also an issue with tests as they aren't visible,

-------------------------------------------------------------------------------------
ikemen.mk 69ac8664d761a0b68bf9ce83de60643fbdb39f17 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------
Merge pull request #3362 from ikemen-engine/fix

fix: character swap commands,

---------------------------------------------------------------
ruffle.mk nightly-2026-03-04 # Version: Commits on Mar 04, 2026
---------------------------------------------------------------
## What's Changed

* refactor: Convert parsing logic to use FromWStr by @SuchAFuriousDeath in ruffle-rs/ruffle#22555

* build(deps): bump actions/download-artifact from 7 to 8 by @dependabot[bot] in ruffle-rs/ruffle#23169

* build(deps): bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in ruffle-rs/ruffle#23170

* build(deps): bump the cargo-minor group with 2 updates by @dependabot[bot] in ruffle-rs/ruffle#23173

* chore: Bump minimatch in web to mitigate CVE-2026-27903 by @torokati44 in ruffle-rs/ruffle#23176

* render: Flush GPU work periodically during cache entry processing to fix OOM error by @Bubby4j in ruffle-rs/ruffle#23175

* core: Perform construction of objects on frame targeted by queued goto in SWFv9 by @Lord-McSweeney in ruffle-rs/ruffle#23148

* chore: Bump winit to 0.30.13 by @torokati44 in ruffle-rs/ruffle#23177

## New Contributors

* @Bubby4j made their first contribution in ruffle-rs/ruffle#23175

**Full Changelog**: ruffle-rs/ruffle@nightly-2026-03-03...nightly-2026-03-04,

----------------------------------------------------------------------------------------
rpi-utils.mk 216e2d3045e9343e894e6445c5ae122aa7752584 # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------------
rpieepromab: Remove unknown from version

Don't show unknown in version string. When the package is

built it doesn't have the git hash.,

-----------------------------------------------------------------------------------------
sdl3_mixer.mk a1e7e99174ea5deb254474df46d860c8db96dffe # Version: Commits on Mar 04, 2026
-----------------------------------------------------------------------------------------
Sync SDL3_mixer wiki -> header

[ci skip],

------------------------------------------------------------------------------------
box64.mk c92456a744de745268fa99778f07f60cc492cd1c # Version: Commits on Mar 04, 2026
------------------------------------------------------------------------------------
Fix segfault when BOX64_VERSION env var is set (#3613)

The BOX64_VERSION early-exit path in initialize() calls

PrintBox64Version(0) which uses PrintfFtrace(), but ftrace is

still NULL at that point (initialized to NULL globally, only set

to stderr much later in initialize()).

This causes fileno(NULL) -> SIGSEGV in PrintfFtrace().

Fix: initialize ftrace = stderr before the BOX64_VERSION check.

The later assignment in the normal flow is harmless (idempotent).

Co-authored-by: Yoinks <yoinks@users.noreply.github.com>,

-----------------------------------------------------------------------------------------
catacombgl.mk 25896a7a9711c46de70f0b1ca5495ee0aea3a03a # Version: Commits on Mar 03, 2026
-----------------------------------------------------------------------------------------
Add class test for picking up items from chest,

---------------------------------------------------------------------------------------
corsixth.mk b2c9bfea7d6f9a0e6b41b07377ea772c3f044c3c # Version: Commits on Mar 04, 2026
---------------------------------------------------------------------------------------
Accept VIPs on fax timeout (#3257),

-------------------------------------------------------------------------------------------------
shadps4-qtlauncher.mk 034d58e17f1667863d32cf38cec172a4b19b7abe # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------------------
New Crowdin updates (#260)

* New translations en_us.ts (Swedish)

* New translations en_us.ts (Portuguese, Brazilian)

* New translations en_us.ts (Croatian)

* New translations en_us.ts (Spanish)

* New translations en_us.ts (Spanish)

* New translations en_us.ts (Ukrainian),

------------------------------------------------------------
syncthing.mk v2.0.16-rc.1 # Version: Commits on Mar 03, 2026
------------------------------------------------------------
## Major changes in 2.0

- Database backend switched from LevelDB to SQLite. There is a migration on

  first launch which can be lengthy for larger setups. The new database is

  easier to understand and maintain and, hopefully, less buggy.

- The logging format has changed to use structured log entries (a message

  plus several key-value pairs). Additionally, we can now control the log

  level per package, and a new log level WARNING has been inserted between

  INFO and ERROR (which was previously known as WARNING...). The INFO level

  has become more verbose, indicating the sync actions taken by Syncthing. A

  new command line flag `--log-level` sets the default log level for all

  packages, and the `STTRACE` environment variable and GUI has been updated

  to set log levels per package. The `--verbose` and `--logflags` command

  line options have been removed and will be ignored if given.

- Deleted items are no longer kept forever in the database, instead they are

  forgotten after fifteen months. If your use case require deletes to take

  effect after more than a fifteen month delay, set the

  `--db-delete-retention-interval` command line option or corresponding

  environment variable to zero, or a longer time interval of your choosing.

- Modernised command line options parsing. Old single-dash long options are

  no longer supported, e.g. `-home` must be given as `--home`. Some options

  have been renamed, others have become subcommands. All serve options are

  now also accepted as environment variables. See  `syncthing --help` and

  `syncthing serve --help` for details.

- Rolling hash detection of shifted data is no longer supported as this

  effectively never helped. Instead, scanning and syncing is faster and more

  efficient without it.

- A \default folder\ is no longer created on first startup.

- Multiple connections are now used by default between v2 devices. The new

  default value is to use three connections: one for index metadata and two

  for data exchange.

- The following platforms unfortunately no longer get prebuilt binaries for

  download at syncthing.net and on GitHub, due to complexities related to

  cross compilation with SQLite:

  - dragonfly/amd64

  - solaris/amd64

  - linux/ppc64

  - netbsd/*

  - openbsd/386 and openbsd/arm

  - windows/arm

- The handling of conflict resolution involving deleted files has changed. A

  delete can now be the winning outcome of conflict resolution, resulting in

  the deleted file being moved to a conflict copy.

This release is also available as:

* APT repository: https://apt.syncthing.net/

* Docker image: `docker.io/syncthing/syncthing:2.0.16-rc.1` or `ghcr.io/syncthing/syncthing:2.0.16-rc.1`

  (`{docker,ghcr}.io/syncthing/syncthing:2` to follow just the major version)

## What's Changed

### Other

* chore(config, connections): use same reconnection interval for QUIC and TCP (fixes #10507) by @marbens-arch in syncthing/syncthing#10573

**Full Changelog**: syncthing/syncthing@v2.0.15...v2.0.16-rc.1,

----------------------------------------------------------------------------------------------------
sdl2-gamecontrollerdb.mk e0beee4ed92cf4360ff960c1feff17ed895b81bc # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------------------------
Wrong RG 35XX mapping (#929)

* Update RG 35XX mapping

* Remove Anbernic RG 35XX

---------

Co-authored-by: Alynne <alviscera@gmail.com>,

----------------------------------------------------------------------------------------
retroarch.mk 70d8a97b2c628702d053421b38ab1c437e6305ac # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------------
Replace some files inside dungeon# Please enter the commit message for your changes. Lines starting,

-------------------------------------------------------------------------------------
libdof.mk d31652bd7aca173906334ceedba0b677374397da # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------
docs: update readme about ftdi controllers (@superhac),

-------------------------------------------------------------------------------------
libvni.mk 771dcee0fb73a66f3f7c0cb72c614b3a6cbdf3e0 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------
robust version detection,

--------------------------------------------------------------------------------------------
vpinball-next.mk ac8500949709f4103297c7fa35f9580b415f2aaa # Version: Commits on Mar 04, 2026
--------------------------------------------------------------------------------------------
leftovers, should be NFC,

----------------------------------------------------------------------------------------
doomretro.mk 959dc3447cb9d2e0b56d9ce5d675d1c0354fcd99 # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------------
More work on crash handling,

--------------------------------------------------------------------------------------
yquake2.mk e5e98687efbe1684e2805f0efd534c206092cea7 # Version: Commits on Mar 03, 2026
--------------------------------------------------------------------------------------
Update readme,

----------------------------------------------------------------------------------
trx.mk 952d3d8a3d92a2ac0b2088a6e0c9763d2bb3806c # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------
shell/flow: fix level clear

Fixes a misguided implementation from 1ca20cde8.,

------------------------------------------------------------------------------------------
xash3d-fwgs.mk af5d190bc45f05f889cd5197bdac2e6d0edc9e4e # Version: Commits on Mar 04, 2026
------------------------------------------------------------------------------------------
engine: common: mod_bmodel: make texture name array larger so it fits both world name and miptex name,

---------------------------------------------------------------------------------------------
libretro-fbneo.mk 89fe4a4d6fc14dd623d33b9e1a264f333a8c623f # Version: Commits on Mar 04, 2026
---------------------------------------------------------------------------------------------
Merge branch 'finalburnneo-master',

-------------------------------------------------------------------------------------------------
libretro-geargrafx.mk a1426cffe127d701c17b26b2a48eb18992d3b8c9 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------------------
[librertro] Migrate to core options v2. Fix #102,

--------------------------------------------------------------------------------------------------
libretro-gearsystem.mk 749c7df6be0d2b8d0cdc6abd0f2d972a11c54868 # Version: Commits on Mar 04, 2026
--------------------------------------------------------------------------------------------------
Fix Port B TH direction check mask,

--------------------------------------------------------------------------------------------------------------
libretro-genesisplusgx-expanded.mk 721ee725482b1023d2855e7a053941fc864424a0 # Version: Commits on Mar 04, 2026
--------------------------------------------------------------------------------------------------------------
Update README.md,

----------------------------------------------------------------------------------------------
libretro-ppsspp.mk ecb5cf036e7947ed6358b68bcead692f00425d99 # Version: Commits on Mar 04, 2026
----------------------------------------------------------------------------------------------
Merge pull request #21341 from hrydgard/more-regression-fixes

Fix crash on audio device switch in Windows,

---------------------------------------------------------------------------------------------
libretro-vba-m.mk 5386b8dc7382aa1047a6c077559134ddc7d8e563 # Version: Commits on Mar 04, 2026
---------------------------------------------------------------------------------------------
build: fix some warnings on MSVC

Suppress warnings from xBRZ on both MSVC and GCC/Clang.

Suppress MSVC warnings from bison-generated code for the SDL port.

Fix usage of `snprintf()` for `_WIN32` code in ConfigManager (only used

for the SDL port.)

Signed-off-by: Rafael Kitover <rkitover@gmail.com>,

-------------------------------------------------------------------------------------------
glsl-shaders.mk c1a40ae924d4356c19485ead4645becce7bac432 # Version: Commits on Mar 04, 2026
-------------------------------------------------------------------------------------------
re-entry of old crt-consumer as \classic\ (#554)

* Add files via upload

* Add files via upload,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rendering Area: Rendering & Graphics llm The PR contains mostly LLM-generated code newsworthy render-wgpu Issues relating to the wgpu renderer T-perf Type: Performance Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants