Skip to content

Commit 64df8f0

Browse files
JoeMattclaude
andcommitted
fix: thin libretro wrapper hijacking RA cores when feature flag is off
PVCoreFactory probed `NSClassFromString("PVRetroArchCore")` to decide whether the legacy RA wrapper was available, but the actual Swift class is exposed to the ObjC runtime as `PVRetroArch.PVRetroArchCoreCore` (module-prefixed). The probe always returned nil, so `!pvRetroArchCoreExists` was always true and the thin wrapper swap fired unconditionally — even with the feature flag disabled. Probe the principleClass we were actually asked to load instead. If it resolves the legacy wrapper is in this build, and we only swap when the feature flag explicitly opts in. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7d569e5 commit 64df8f0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

PVUI/Sources/PVUIBase/Emulator/PVCoreFactory.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ public extension PVCore {
3434
ILOG("createInstance: principleClass=\(className) for \(identifier)")
3535
if className.contains("RetroArch") || className.contains("LibRetro") || className == "PVRetroArchCoreBridge" {
3636
let featureEnabled = PVFeatureFlags.shared.isEnabled(.dynamicLibretroScanner)
37-
let pvRetroArchCoreExists: Bool = NSClassFromString("PVRetroArchCore") != nil
38-
ILOG("ThinLibretro: featureEnabled=\(featureEnabled)")
37+
// The Swift class is exposed to the ObjC runtime as `PVRetroArch.PVRetroArchCoreCore`
38+
// (module-prefixed), so the previous `NSClassFromString("PVRetroArchCore")` always
39+
// returned nil and unconditionally forced the thin wrapper. Probe the actual
40+
// principleClass we were asked to load instead — if it resolves, the legacy wrapper
41+
// is available and we should only swap when the feature flag explicitly says so.
42+
let pvRetroArchCoreExists = NSClassFromString(className) != nil
43+
ILOG("ThinLibretro: featureEnabled=\(featureEnabled), legacyClassExists=\(pvRetroArchCoreExists) (probed=\(className))")
3944
if featureEnabled || !pvRetroArchCoreExists {
4045
// Force-load PVCoreBridgeRetro framework so the ObjC runtime has
4146
// PVThinLibretroCore registered. Frameworks are lazily loaded and

0 commit comments

Comments
 (0)