Skip to content

SDL_GPU backend on macOS crash (assert) when going fullscreen #8703

@jclounge

Description

@jclounge

Version/Branch of Dear ImGui:

master

Back-ends:

SDL3_GPU

Compiler, OS:

macOS

Full config/build information:

n/a

Details:

On macOS, using the SDL3_GPU backend, when making the demo app window fullscreen with the standard window fullscreen button, it causes an assert/crash when trying to set scissor extents incorrectly. This appears to be due to the ImGui_ImplSDL3_GetWindowSizeAndFramebufferScale() function getting the wrong scale values. Here is a modified version of the function that appears to fix the issue:

static void ImGui_ImplSDL3_GetWindowSizeAndFramebufferScale(SDL_Window* window, ImVec2* out_size, ImVec2* out_framebuffer_scale)
{
    int w, h;
    int display_w, display_h;
    SDL_GetWindowSize(window, &w, &h);
    if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
        w = h = 0;

    if (out_size != nullptr)
        *out_size = ImVec2((float)w, (float)h);

    // this version using SDL_GetWindowDisplayScale() seems to get the correct scale values
    float scale = SDL_GetWindowDisplayScale(window);
    if (out_framebuffer_scale != nullptr)
        *out_framebuffer_scale = (scale > 0.0f) ? ImVec2(scale, scale) : ImVec2(1.0f, 1.0f);
}

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

The example demo app: example_sdl3_sdlgpu3/main.cpp

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions