From f15e9409ae979e492799d3ba2577dcedf49cb1a6 Mon Sep 17 00:00:00 2001 From: SandiyosDev <25407129+SandiyosDev@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:12:44 -0500 Subject: [PATCH 1/4] nv12 stride check odd width --- OpenParsec/ParsecMetalRenderer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenParsec/ParsecMetalRenderer.swift b/OpenParsec/ParsecMetalRenderer.swift index 5715f321..6237a5b9 100644 --- a/OpenParsec/ParsecMetalRenderer.swift +++ b/OpenParsec/ParsecMetalRenderer.swift @@ -28,7 +28,7 @@ private let frameCallback: ParsecFrameCallback = { frame, image, opaque in extension ParsecFrame { var isWholeNV12: Bool { let w = Int(width), h = Int(height), stride = Int(fullWidth), rows = Int(fullHeight) - return format == FORMAT_NV12 && w > 0 && h > 0 && stride >= w && rows >= h && Int(size) >= stride * rows + stride * ((h + 1) / 2) + return format == FORMAT_NV12 && w > 0 && h > 0 && stride >= 2 * ((w + 1) / 2) && rows >= h && Int(size) >= stride * rows + stride * ((h + 1) / 2) } } From 0cf33857d6632bbedda098957f539c374a107cf3 Mon Sep 17 00:00:00 2001 From: SandiyosDev <25407129+SandiyosDev@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:39:07 -0500 Subject: [PATCH 2/4] check cursor img size --- OpenParsec/ParsecSDKBridge.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenParsec/ParsecSDKBridge.swift b/OpenParsec/ParsecSDKBridge.swift index ab1d0a0e..e4cd4c13 100644 --- a/OpenParsec/ParsecSDKBridge.swift +++ b/OpenParsec/ParsecSDKBridge.swift @@ -373,6 +373,10 @@ class ParsecSDKBridge: ParsecService { let size = event.cursor.size let width = event.cursor.width let height = event.cursor.height + guard width > 0, height > 0, Int(size) >= Int(width) * Int(height) * 4 else { + ParsecFree(pointer) + return + } mouseInfo.cursorWidth = Int(width) mouseInfo.cursorHeight = Int(height) @@ -388,9 +392,8 @@ class ParsecSDKBridge: ParsecService { let render: CGColorRenderingIntent = CGColorRenderingIntent.defaultIntent let rgbColorSpace = CGColorSpaceCreateDeviceRGB() let bitmapInfo: CGBitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue) - let providerRef: CGDataProvider? = CGDataProvider(data: NSData(bytes: pointer, length: Int(size))) - let cgimage: CGImage? = CGImage(width: Int(width), height: Int(height), bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: Int(width) * elmentLength, space: rgbColorSpace, bitmapInfo: bitmapInfo, provider: providerRef!, decode: nil, shouldInterpolate: true, intent: render) - if cgimage != nil { + if let providerRef = CGDataProvider(data: NSData(bytes: pointer, length: Int(size))), + let cgimage = CGImage(width: Int(width), height: Int(height), bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: Int(width) * elmentLength, space: rgbColorSpace, bitmapInfo: bitmapInfo, provider: providerRef, decode: nil, shouldInterpolate: true, intent: render) { mouseInfo.cursorImg = cgimage } ParsecFree(pointer) From 702cf3a6ac78c3936ce18869f7a2ecc1262a6ac3 Mon Sep 17 00:00:00 2001 From: SandiyosDev <25407129+SandiyosDev@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:46:52 -0500 Subject: [PATCH 3/4] keep host res till first frame --- OpenParsec/ParsecSDKBridge.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenParsec/ParsecSDKBridge.swift b/OpenParsec/ParsecSDKBridge.swift index e4cd4c13..11658ac2 100644 --- a/OpenParsec/ParsecSDKBridge.swift +++ b/OpenParsec/ParsecSDKBridge.swift @@ -212,8 +212,10 @@ class ParsecSDKBridge: ParsecService { func getStatusEx(_ pcs: inout ParsecClientStatus) -> ParsecStatus { let ans = ParsecClientGetStatus(_parsec, &pcs) - self.hostHeight = Float(pcs.decoder.0.height) - self.hostWidth = Float(pcs.decoder.0.width) + if pcs.decoder.0.width > 0 && pcs.decoder.0.height > 0 { + self.hostHeight = Float(pcs.decoder.0.height) + self.hostWidth = Float(pcs.decoder.0.width) + } // the teardown release may not have made it out, this one goes over a socket we know is live if ans == PARSEC_OK && !didReleaseOnConnect { From 5e897b42d2c16af3f469c2e6f4c4ab47413dc795 Mon Sep 17 00:00:00 2001 From: SandiyosDev <25407129+SandiyosDev@users.noreply.github.com> Date: Mon, 19 Oct 2026 21:31:18 -0500 Subject: [PATCH 4/4] ask screen on launch reconnect too --- OpenParsec/MainView.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenParsec/MainView.swift b/OpenParsec/MainView.swift index a6b5ad6e..285d522e 100644 --- a/OpenParsec/MainView.swift +++ b/OpenParsec/MainView.swift @@ -674,6 +674,11 @@ struct MainView: View { if let window = UIApplication.shared.connectedScenes.compactMap({ $0 as? UIWindowScene }).flatMap({ $0.windows }).first(where: { $0.isKeyWindow }) { let scale = window.screen.nativeScale ParsecResolution.updateClientResolution(width: Int(window.bounds.width * scale), height: Int(window.bounds.height * scale)) + } else { + // no key window yet on a launch reconnect, without this it asks the host for 3840x2160 + let screen = UIScreen.main + let scale = screen.nativeScale + ParsecResolution.updateClientResolution(width: Int(screen.bounds.width * scale), height: Int(screen.bounds.height * scale)) } pollTimer?.invalidate()