Error saving screenshots on macOS
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 14.1k
- Forks
- 2.2k
- Avg merge
- 7h 35m
- Merged PRs (30d)
- 51
Description
Description
On a macOS (15.0.1, arm64), building from Xcode, I am getting an error (on screen) whenever trying to save screenshots.
Expected behavior
Expected the screenshot to be saved to a PNG file successfully.
Actual behavior
I occasionally get an error and the screenshot isn't saved.
Steps to reproduce the bug
- Open Retroarch
- Open a GBA rom
- Open mGBA
- Click Command -> Take Screenshot
- See the error pop up
Bisect Results
I don't know what this means, but I was messing with the code anyway, so here's what I found.
While investigating the error I added a few printf's to debug it, and after that a few screenshots were successfully saved in weirdly named directories:
'/Users/vini/Library/Containers/com.libretro.dist.RetroArch/Data/`64o/Pokemon - LeafGreen Version (USA, Europe) (Rev 1)-241115-151226.png'
'/Users/vini/Library/Containers/com.libretro.dist.RetroArch/Data/`v]o/Pokemon - LeafGreen Version (USA, Europe) (Rev 1)-241115-150716.png'
'/Users/vini/Library/Containers/com.libretro.dist.RetroArch/Data/`vqo/Pokemon - LeafGreen Version (USA, Europe) (Rev 1)-241115-150345.png'
Looking at the code, what seems to be happening is:
screenshot_dumpgets called (line 255) with the following arguments:- screenshot_dir: ""
- name_base: /Applications/_Games/Pokemon - LeafGreen Version (USA, Europe) (Rev 1)
- savestate: 0
- has_valid_framebuffer: 0
- fullpath: 0
- use_thread: 1
new_screenshot_diris declared (line 318) but never initialized (so it contains memory trash, I suppose?)settings->bools.auto_screenshot_filenameistrue, so we calculate a newstate->shotname(e.g.Pokemon - LeafGreen Version (USA, Europe) (Rev 1)-241115-151226.png).- We check if
new_screenshot_diris empty in line 377 but it's not (it contains memory trash), andsettings->bools.screenshots_in_content_dirisfalse, so it still hasn't been initialized. - We create a pathname (line 382) with an uninitialized string but a valid filename, and it only works occasionally (when the uninitialized string happens to be a valid directory name?).
A lot of these are educated guesses, but I thought it'd be better to write it up and maybe help someone actually fix it.
Version/Commit
Commit hash b0da8b15794afbb6df6ae30ede16b1a7423c60e8
Environment information
- OS: macOS (15.0.1, arm64)
- Compiler: Xcode
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in tasks/task_screenshot.c at the screenshot_dump declaration around line 255 and the new_screenshot_dir declaration around line 318. Trace its use in the path construction around lines 377-382, then reproduce the macOS screenshot flow from the listed steps. Done means screenshots save successfully to the expected PNG location without malformed directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100