Repository navigation
libobs: Count image memory, keep every slideshow slide - #2289
Conversation
4e23861 to
6dce9eb
Compare
|
Coordinator review: not queuing yet. This PR edits existing C tests. |
|
(b), please. The line it retires, The two slideshow test edits change no assertions. |
|
Thanks. The argument for (b) is reasonable, and the stub-only slideshow edits are fine. Retiring an existing C assertion is the maintainer's call, though, so I've labelled this human-review-needed and I'm holding it out of the queue until they answer. No action needed from you meanwhile. |
gs_image_file_ex_init() leaves mem_usage at 0 for every picture, so Image sources report no memory and the original Image Slide Show's 400 MiB cap never applies: every slide stays decoded. test_image_file now expects the decoded size in mem_usage: 4 MiB for a 1024x1024 PNG it writes at run time, 24 bytes for the 3x2 PNG, 16 for the still GIF and, for the animated GIF, the frame cache, every frame, the current frame and the file. The Rust mirror in obs-graphics expects the same. test_slideshow_mem_cap loads the real image-source and obs-transitions modules and makes an original slideshow of 12 generated 4096x4096 PNGs (64 MiB each decoded, so 7 reach the cap). It steps through every slide with Next and Previous, a fade, random order and a folder, and checks that each slide is shown at its size, that the slideshow is sized by the taller last picture, and that no more than 3 pictures past the cap are loaded at once. On master all 12 stay loaded; with only the counter fixed, the slideshow drops the 5 slides past the cap. Refs obs-rust#2279
gs_image_file_ex_init() passed NULL for the memory counter (since the image file API break, upstream c3046ec), so every Image source reported 0 bytes and the original Image Slide Show's 400 MiB cap never applied: all its slides stayed decoded. It now counts into image->mem_usage again, in C and in the obs-graphics port (which keeps the count aside while init resets the image, and counts nothing for a failed load). Counting again would have made the original slideshow drop every slide past the cap from its list, as it did before the break. It keeps them now: slides are loaded in order up to the cap as before; each slide past it is decoded once to size the slideshow and then loaded only while it is the current slide, the one before or after it, the one a transition is leaving or, in random order, the one picked to come next (picked a slide early so it can be loaded first). Those decode on a task queue, as in the reworked slideshow; a slide about to be shown waits for its decode, or is decoded then, and gets its texture before the transition draws it. Order, timing, random order, hotkeys and media controls do not change, and a slideshow under the cap runs exactly as before. The reworked slideshow (slideshow_v2) is unchanged. test_slideshow_mem_cap waits for the slide on screen, not only for the index, as a slide past the cap may still be decoding when the index changes, and its fade is shorter. The slideshow test stubs gain image_source_preload_image and image_source_ready_slide. docs/features.md gets a line under fixed upstream bugs. Fixes obs-rust#2279
6dce9eb to
94918ac
Compare
|
Maintainer decision (researched and approved by the coordinator under the maintainer's instruction): option (b). The retired line, |
Fixes #2279
What and why
Upstream obsproject/obs-studio#14076.
gs_image_file_ex_init()passes NULL for the memory counter (since the image-file API change in upstream c3046ec). So every Image source reports 0 bytes, and the original Image Slide Show's 400 MiBMAX_MEM_USAGEcap never applies: every slide stays decoded in memory.Counter (C and Rust, with parity).
gs_image_file_ex_init()counts intoimage->mem_usageagain, as upstream PR 14078 does. The obs-graphics port does the same. It keeps the count aside while init resets the image, and a failed load counts nothing, as the C does (its free zeroes the image). The parity test against the original C covers the counter for the real GIF fixtures.Original slideshow. With only the counter fixed, the original slideshow would drop every slide past the cap from its list, as it did before the API change. That would be a visible change for existing scenes. Measured: a 12-picture slideshow shows 7 slides. The slideshow now keeps every slide:
In list order, slides up to the cap are loaded when the list is read, as today.
Each slide past the cap is decoded once, so it still sizes the slideshow, then released. It stays in the list "on demand".
An on-demand slide is loaded only while it is one of these:
It is released once it is none of these.
Those slides decode on a task queue, as the reworked slideshow (
obs-slideshow-mk2.c.h) does.A slide about to be shown waits for its decode, or is decoded then if it was not loaded. It gets its texture before the transition draws it, so a fade has both pictures.
Order, slide timing, random order, hotkeys and media controls (next, previous, restart, stop) do not change. A slideshow under the cap runs exactly as before: no on-demand slides, no extra
rand()calls.Newer slideshows (
slideshow_v2, the reworked slideshow) are unaffected. They already load slides on demand and never read the counter. Image sources only report their memory; nothing else reads it.image-sourcegainsimage_source_ready_slide(), used by the slideshow. The slideshow test fixtures that buildobs-slideshow.c.hgain stubs for it and forimage_source_preload_image().RED → GREEN
test: Check image memory use and slideshow cap, run on master a7f12c3 (as 4e23861, before the rebase; the tests are the same). It fails on C, hybrid and libobs-c-reference:test_image_file: the counter is 0 (0 != 24for the 3x2 PNG,0 != 16for the still GIF,0 != 2576for the animated GIF, and under 4 MiB for a 1024x1024 PNG the test writes at run time, so the branch adds no image files). Same in the Rust mirror (cargo test -p obs-graphics --test obs-tests-graphics image_file: 4 failed,left: 0).test_slideshow_mem_cap(real image-source and obs-transitions modules, core video, 12 generated 4096x4096 PNGs): all 12 pictures stay loaded, 5 of them past the cap (the limit is 3). In all 4 cases.total_files 7 != 12. The slideshow drops the 5 slides past the cap.tests.d/test_slideshow_mem_cap.cmake; lint ran again on both commits:test_image_*,test_slideshow_*(withtest_slideshow_mem_cap),test_ws_image_mimeandtest_cube_lut.test_slideshow_mem_capsteps through every slide with Next and Previous, a fade, random order and a folder. Each slide is shown at its size, the slideshow keeps the taller last picture's height, and at most 3 slides past the cap are loaded at once.image_filetests including the parity test: 18/18.test_slideshow_mem_capis registered intests.d, liketest_stinger_media_duration, because it loads plugin modules. The test graph's facts and the Rust native runner have no image-source or obs-transitions module, and an unknown graph requirement failsnative_test_graph_replaces_legacy_utility_definitions. It takes about 105 s under llvmpipe, so it has a 300 s timeout.--test-diff origin/masterok,--lane lintok (on RED and head),--lane crossok.Checklist
masterdocs/features.mdis added (Fixed upstream bugs, Sources and filters)-W..., ratchets): not applicable