Commit bd45086
committed
OSX/MACOS/COCOATOUCH: Normalise MRR safety in cocoa_gl_ctx.m
Audit of the OpenGL context driver turned up three latent MRR
leaks, all on the iOS/tvOS side where the code relies on ARC's
strong-store semantics for release-on-reassignment. Every
shipping iOS build currently enables ARC, so none of these leak
in practice today; making the paths MRR-safe as well brings the
driver in line with cocoa_common.m / ui_cocoa.m (which compile
under both ARC and MRR via the RARCH_*/RELEASE macro family) and
keeps the qb/make-style non-Xcode build viable for COCOATOUCH
targets.
All three fixes use the existing RELEASE macro from
cocoa_common.h, which under ARC expands to plain `x = nil` and
under MRR to `[x release]; x = nil` - so this is a no-op under
ARC and a strict correctness improvement under MRR.
- cocoa_gl_gfx_ctx_destroy: previously only the OSX branch called
RELEASE on g_ctx / g_hw_ctx; the iOS branch dropped the +1 from
[[EAGLContext alloc] initWithAPI:...] with a raw `g_ctx = nil`.
Move the RELEASE calls unconditional (post-#endif) and add
RELEASE(glk_view) under #if defined(HAVE_COCOATOUCH) so the
GLKView created in glkitview_init does not leak across
init/destroy cycles even on clean shutdown.
- cocoa_gl_gfx_ctx_set_video_mode (both branches): add defensive
RELEASE(g_ctx) / RELEASE(g_hw_ctx) before the
[[NSOpenGLContext alloc] ...] / [[EAGLContext alloc] ...]
overwrites. The normal reinit flow has -destroy running first
so both statics are already nil here, but guarding defensively
means a future re-init-without-destroy call site cannot leak
the previous +1.
- glkitview_init: release the previous glk_view before
overwriting with [GLKView new]. The existing
[glk_view deleteDrawable] handled the GL-side cleanup but left
the Obj-C retain dangling under MRR.
cocoa_vk_ctx.m has no static Obj-C pointers and needed no
changes. MoltenVK / vulkan_context_destroy own the Vulkan
surface / device lifetime, and all CocoaView accesses there are
brief unretained reads backed by cocoa_common.m's g_instance
strong reference (see 0062608).1 parent 0062608 commit bd45086
1 file changed
Lines changed: 34 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
175 | | - | |
176 | 180 | | |
177 | 181 | | |
178 | | - | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| |||
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
188 | | - | |
189 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
190 | 203 | | |
191 | 204 | | |
192 | 205 | | |
| |||
428 | 441 | | |
429 | 442 | | |
430 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
431 | 451 | | |
432 | 452 | | |
433 | 453 | | |
434 | 454 | | |
| 455 | + | |
| 456 | + | |
435 | 457 | | |
| 458 | + | |
436 | 459 | | |
437 | 460 | | |
438 | 461 | | |
| |||
611 | 634 | | |
612 | 635 | | |
613 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
614 | 644 | | |
615 | 645 | | |
616 | 646 | | |
| |||
0 commit comments