MacOS: fix render issue in obs-32 branch - #742
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets macOS OpenGL rendering by keeping the created IOSurfaceRef alive (instead of releasing it immediately) so IOSurfaceLookup-based consumers don’t see NULL, and by tightening present/readback behavior to avoid benign GL errors.
Changes:
- Persist and manage the lifetime of the created
IOSurfaceRef(store on swapchain/windowinfo; release on teardown). - Adjust swapchain/present readiness logic and add optional debug IOSurface dumping support.
- Remove UniformTypeIdentifiers dependency in the IOSurface debug helper (use
"public.png"UTI string).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| libobs-opengl/IOSurfaceHelper.m | Removes UTType dependency and updates PNG type usage for debug image export. |
| libobs-opengl/gl-cocoa.m | Stores/releases IOSurfaceRef, updates swapchain load/present readiness, and changes IOSurface readback path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
202f758 to
6829842
Compare
6829842 to
23b8db3
Compare
23b8db3 to
0290cc6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
libobs-opengl/gl-cocoa.m:723
- If
IOSurfaceCreatefails, this function still returnsswap->wi->surfaceID, which may be a stale, non-zero ID from a previous successful call. That makes failure indistinguishable from success for callers. Return 0 on failure and only updateswap->wi->surfaceIDwhen a new surface was actually created.
IOSurfaceRef surfaceRef = IOSurfaceCreate((CFDictionaryRef) surfaceAttributes);
if (surfaceRef) {
swap->wi->surfaceID = IOSurfaceGetID(surfaceRef);
if (swap->wi->surfaceRef) {
CFRelease(swap->wi->surfaceRef);
swap->wi->surfaceRef = NULL;
}
swap->wi->surfaceRef = surfaceRef;
} else {
blog(LOG_ERROR, "create_iosurface IOSurfaceCreate failed");
}
[surfaceAttributes release];
return swap->wi->surfaceID;
}
0290cc6 to
576f749
Compare
6a8c9aa to
31e4abf
Compare
* Fix issue in Obs-32 branch where create_iosurface uses kIOSurfaceIsGlobal: YES but then immediately called CFRelease causing IOSurfaceLookup in both write_iosurface and node-window-rendering to return NULL. * Fix pre-existing issue while we are in here where we'd have glClear errors being sent to the logs (we still rendered, but it polluted the logs and wasn't good practice). Add checks for 0x0 sized buffer etc. * Add optional DEBUG_WRITE_IOSURFACE code path which will dump the IOSurface contents which can be helpful determining if backend is properly rendering (because if we have pixels, then problem is upstream in NWR/Desktop).
31e4abf to
3554119
Compare
| } | ||
| swap->wi->surfaceRef = surfaceRef; | ||
| } else { | ||
| swap->wi->surfaceID = 0; |
There was a problem hiding this comment.
When IOSurfaceCreate fails, this clears surfaceID but leaves the previous surfaceRef alive. Since write_iosurface now gates on surfaceRef, a failed create or 0x0 resize can still keep writing into the stale IOSurface even though callers see ID 0. Please release/null surfaceRef here too, and ideally explicitly return early for width == 0 || height == 0.
Description
create_iosurfaceuseskIOSurfaceIsGlobal: YESbut then immediately calledCFReleasecausingIOSurfaceLookupin bothwrite_iosurfaceandnode-window-renderingto returnNULL.glClearerrors being sent to the logs. Add checks for 0x0 sized buffer.DEBUG_WRITE_IOSURFACEcode path which will dump theIOSurfacecontents into a .png file which can be helpful determining if backend is properly rendering (because if we have pixels, then problem is upstream in NWR/Desktop).Motivation and Context
Depends on this PR: #734. Fix rendering issue for macOS in obs-32 branch
How Has This Been Tested?
Verified I see images rendered during dual output etc on Streamlabs Desktop in
obs_merge_32.1.1locallyTypes of changes
Checklist: