Skip to content

bug: libobs: an image too large for a texture is fully decoded before it fails, using GBs and freezing OBS (upstream #3427) #1473

Closed

Description

@rdoupe

Upstream bug: obsproject/obs-studio#3427, "Loading large PNG images temporarily consumes large amounts of RAM and causes OBS to be non-responsive", reported by micolous in September 2020 after it hit a live event. A second user (devjack) hit it with last-minute third-party graphics, and 3 more upvoted. Maintainers agreed that a size check is reasonable but noted that the limit differs between devices. It was closed as stale in October 2024. Still present in this fork.

Location

  • libobs/graphics/graphics-ffmpeg.c.h, ffmpeg_image_init(): avformat_find_stream_info() decodes the whole picture just to learn its size and pixel format, with no size check. ffmpeg_image_decode() then decodes it a second time, and ffmpeg_image_reformat_frame() makes more full-size copies (swscale output, then the RGBA buffer).
  • No code compares the picture's size with the graphics device's texture size limit. The first check is device_texture_create() (GL: glTexImage2D returns GL_INVALID_VALUE; D3D11: E_INVALIDARG), after all the decoding is done.

Class

Resource exhaustion and stall. The thread that loads the image blocks for seconds while memory peaks at about three full-size copies. For an Image source added or changed from the UI or obs-websocket, that thread is the UI thread. Then the image fails to load anyway.

How it is reached

Any Image source, Image Slide Show, mask/LUT filter or luma wipe given a picture wider or taller than the GPU's texture size limit (16384 on Direct3D 11, Metal and most OpenGL drivers). For example, a 1920x1080 mm overlay exported at 300 PPI (22677x12756), or a 20480x11520 PNG.

Reproduced in the current release

Headless (private Xvfb, private D-Bus, fresh HOME), OpenGL (llvmpipe, texture size limit 16384). Image source added with obs-websocket CreateInput, peak RSS read from VmHWM.

Build Case Result
v0.1.0-beta.20261018 AppImage 20480x11520 PNG (5 MB file) CreateInput blocks 9.3 s, peak RSS +2484 MiB, then device_texture_create (GL) failed
v0.1.0-beta.20261018 AppImage 640x360 PNG loads, 0.05 s
master 2d19461 (cmocka) 16385x8192 PNG through gs_image_file_ex_init() not loaded after 0.74 s, peak RSS +1420 MiB, no log line naming the size or the limit

Fix

gs_create() records the device's texture size limit: GL_MAX_TEXTURE_SIZE from the OpenGL module through a new optional device export, and the API limit of 16384 for Direct3D 11 and Metal. The image decoder checks the picture's size as soon as its header is read (in the decoder's get_buffer2 callback, before any pixels are decoded) and gives up with a log line that gives the size and the limit. For a single-stream picture, where the demuxer already names the codec, it skips avformat_find_stream_info(), which decoded the whole picture once more just to learn its size. Pictures within the limit load exactly as before (byte-identical output across 17 format/pixel-format cases). With no graphics device, there is no check. PR follows.

Activity

  1. rdoupe commented on Oct 20, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: fix ready (RED and GREEN done locally), PR follows today.

  2. added
    claimed
    on Oct 20, 2026
  3. rdoupe commented on Oct 20, 2026

    @rdoupe
    CollaboratorAuthor

    @micolous you reported this in obsproject/obs-studio#3427: an image too large for a texture was fully decoded before OBS gave up on it. That's fixed here in obs-rust by #1474, merged today with a regression test.

    OBS now knows the graphics device's texture size limit and checks the picture's size as soon as its header is read, before any pixels are decoded. An oversized image fails at once, with a log line that names its size and the limit. Images within the limit load as before.

    Tested headless with a 20480x11520 PNG as an Image source (OpenGL, limit 16384). On 0.1.0-beta.20261018 OBS blocked for 9.3 s and used about 2.5 GB before the texture failed. With the fix it fails in 0.01 s, using about 4 MB.

    It will be in the next obs-rust daily release after 0.1.0-beta.20261018: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's obs-studio-rust-git in the AUR). obs-rust is an AI-assisted fork of OBS, based on current OBS master, with extra bug fixes like this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions