Skip to content

Make the Linux viewer draw frames, read input and wait between them - #885

Merged
SimonCropp merged 4 commits into
mainfrom
fix-linux-frame-control
Sep 23, 2026
Merged

SimonCropp merged 4 commits into
mainfrom
fix-linux-frame-control

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

The bug

The Linux viewer has never shown a frame or read input.

native/CMakeLists.txt builds raylib with CUSTOMIZE_BUILD ON. raylib 6.0's cmake/ParseConfigHeader.cmake turns every #define SUPPORT_X <value> in config.h into an option that defaults to ON, including the ones config.h defines as 0. That was fixed upstream in raysan5/raylib#5844, after the 6.0 tag. CUSTOMIZE_BUILD also skips config.h's own values. So the Linux configure output lists SUPPORT_CUSTOM_FRAME_CONTROL=ON and SUPPORT_BUSY_WAIT_LOOP=ON, along with every image format raylib has.

With custom frame control on, raylib's EndDrawing skips SwapScreenBuffer, the SetTargetFPS wait and PollInputEvents. deview_present calls none of them itself. So on a real desktop:

  • the window stays blank;
  • it ignores keys, mouse and its close button;
  • the managed loop, which relies on the present to pace it, spins;
  • it owns 3493 the whole time, so it keeps accepting snapshots it can't show.

Evidence:

  • The configure log of build-native run 35812014703 shows the flags above.
  • Disassembly of both committed .so files: SwapScreenBuffer and PollInputEvents have no call sites.
  • I loaded the committed linux-x64 .so in WSL through Python ctypes, with a hidden window. A bare deview_present loop ran at 41,659 fps.

CI never noticed because the pixel snapshots go through deview_capture. That draws into a render texture and never calls EndDrawing.

This is also why #884's SUPPORT_PARTIALBUSY_WAIT_LOOP OFF produced byte-identical binaries. SUPPORT_BUSY_WAIT_LOOP was on through the same misparse, and it takes precedence.

The fix

  • Switch SUPPORT_CUSTOM_FRAME_CONTROL and SUPPORT_BUSY_WAIT_LOOP off, along with every other flag raylib 6.0's config.h defaults to 0:
    • image and font formats the viewer never asks raylib to decode (it compares BMP, GIF, ICO, JPEG, PNG and WebP);
    • GPU skinning;
    • FLAC.
  • Switch SUPPORT_SCREEN_CAPTURE off. Its F12 handler in EndDrawing writes screenshotNNN.png into the working directory, and it becomes reachable as soon as input is polled.
  • Add PixelTests.PresentWaitsForTheNextFrame. It times 60 presents on the shared hidden window and expects them to take at least 750 ms.
    • It runs where the pixel snapshots run: the Ubuntu job, under xvfb, against the renderer built from this branch's source.
    • It's skipped on macOS, whose head waits for the next frame in its event pump.

todo.md:

Checked

  • The configure output of this branch's build-native run no longer turns on custom frame control, the busy wait loop, screen capture, or any of the formats config.h defaults off.

  • PresentWaitsForTheNextFrame ran in the Ubuntu pixel step and passed: 359 passed and 1 unrelated skip out of 360.

  • The rebuilt linux-x64 .so from Rebuild native renderer binaries #886, driven the same way in WSL:

    fps CPU imports nanosleep F12 screenshot code
    committed on main 33,073 1,145% of a core no yes
    rebuilt in Rebuild native renderer binaries #886 60 16% of a core yes no

    Both need at most GLIBC_2.27 and link libGL.so.1.

Also in this PR

A second commit, "Record what checking the review's unverified items found", updates todo.md only. It covers every item the review had left unverified, checked on c37bf9e:

  • All 44 hold. Each says whether it was reproduced, verified by reading the code, or needs a Mac or Alpine to settle.
  • Fix notes. Each gives the current lines, the repro test names, and where the suggested fix was wrong or incomplete.
  • New data-loss item. An attached "Accept all in " deletes verified files whose snapshots were not written, so it moves to Data loss.

The repro tests fail by design, so they aren't here.

Before merging

Merge #886, which carries the rebuilt .so files, into this branch first. Until it's in, the native job keeps loading the old binaries and still passes, because it only checks the ABI version.

SimonCropp and others added 4 commits September 23, 2026 13:31
raylib 6.0's CMake reads every SUPPORT_ flag in config.h into an option that
defaults to ON, including the ones config.h sets to 0, and CUSTOMIZE_BUILD
skips config.h's own values. So SUPPORT_CUSTOM_FRAME_CONTROL was on, and
EndDrawing never swapped a frame onto the screen, never polled input and never
waited for the next frame: the Linux window stayed blank and ignored every key
and click while the loop spun. SUPPORT_BUSY_WAIT_LOOP was on the same way, and
would have spun through the whole of every frame's wait once there was one.

Switch both off, with every other flag config.h defaults to 0, and turn off
SUPPORT_SCREEN_CAPTURE, whose F12 handler becomes reachable once input is read.

PixelTests.PresentWaitsForTheNextFrame times sixty presents against the
renderer the Ubuntu job builds. The pixel snapshots could never have noticed:
a capture draws into a texture and never reaches EndDrawing.
Every item that was unverified, checked on c37bf9e: all of them hold, and
none was fixed by #878, #881 or #884. Each now says whether it was reproduced,
verified by reading, or needs a platform this machine lacks, with the current
lines, the repro test names, and where the suggested fix turned out wrong or
incomplete.

An attached "Accept all in <solution>" deleting verified files whose snapshots
were not written moves to Data loss. The repro tests are on a local branch,
review-repros, rather than here: each fails until its item is fixed.
Co-authored-by: SimonCropp <122666+SimonCropp@users.noreply.github.com>
@SimonCropp SimonCropp added this to the 20.5.0 milestone Sep 23, 2026
@SimonCropp
SimonCropp merged commit a6ee5ba into main Sep 23, 2026
13 checks passed
@SimonCropp
SimonCropp deleted the fix-linux-frame-control branch September 23, 2026 04:03
This was referenced Sep 23, 2026
This was referenced Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant