Post

Replies

Boosts

Views

Activity

RFB Protocol Security for VNC Client Implementation
I’m exploring the RFB protocol used by VNC connections on macOS. In the initial part of the handshake, as described in the spec - https://tools.ietf.org/html/rfc6143#section-7.2, the server returns a list of security types it supports. Connecting to my iMac running macOS 10.15.6, I get the following list: 30, 33, 36, 35. Looking at the IANA registrations for this protocol, 30-35 are assigned to Apple, and 36 is “Unassigned.” Are there any publicly-available resources to understand the security implementation of the built-in VNC server on macOS? I see a blog post about it from 2011 (I can’t add the link here for some reason), but nothing newer and I suspect the authentication methods have improved since then.
0
0
895
Jul ’20
Xcode 11.4 triggers “ThreadSanitizer CHECK failed” but doesn’t hit breakpoints
In my current iOS project, if I run with Xcode’s thread sanitizer enabled, sometimes I’ll get this in the console output and the app will halt:FATAL: ThreadSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clang_compiler_rt/clang-1103.0.32.29/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc:166 "((kBlockMagic)) == ((((u64*)addr)[0]))" (0x6a6cb03abcebc041, 0x0)This doesn’t hit the Thread Sanitizer runtime breakpoint, the “All Runtime Issues” breakpoint, the “All Exceptions” breakpoint, or the “Swift Error” breakpoint. My only fix so far has been to recompile with the Thread Sanitizer disabled. Anyone else seeing this?
7
0
2.3k
Apr ’20
ASWebAuthenticationSession, watchOS, and Cookies
I have an app that uses the Slack API, and I’m trying to use ASWebAuthenticationSession on watchOS 6.2 to allow for login on watchOS. I was able to display the login form and enter my username and password, then I saw this displayed:Unable to set cookie You need to enable cookies to sign in.Is this something Slack needs to account for, or is there a way for my ASWebAuthenticationSession on watchOS to enable cookies?
0
1
842
Feb ’20
UIWindow Keyboard Notifications for Hosted Content
I’m using the standard UIResponder keyboard notifications to observe when the keyboard appears and adjust the content inset of a scroll view so that its content is visible when scrolled all the way down. This works fine, same as it always has. However, this app is a Message app extension, so the window of my view controller is not the same size as the main UIScreen. The keyboard notification coordinates are in terms of the main screen, but the frames of all of my views are in terms of the window. The window is pinned to the bottom of the display, but its frame starts at 0, 0. Is there a way for me to programatically determine the position of this UIWindow in the UIScreen frame? Here’s the code I’m using:@objc func adjustKeyboard(for notification: Notification) { guard let scrollView = scrollView, let superview = scrollView.superview, let window = scrollView.window, let userInfo = notification.userInfo, let frameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return } let frame = frameValue.cgRectValue let coordinateSpace = UIScreen.main.fixedCoordinateSpace let frameInSuperview = superview.convert(frame, from: coordinateSpace) // The window is at the bottom of the screen but its frame needs to be // adjusted for that difference let offset = scrollView.frame.maxY - frameInSuperview.minY + (coordinateSpace.bounds.height - window.frame.height) animate(alongsideKeyboardNotification: notification, animations: { print("Intersection height: \(offset)") scrollView.contentInset.bottom = offset scrollView.verticalScrollIndicatorInsets.bottom = offset }) } func animate(alongsideKeyboardNotification notification: Notification, animations: @escaping () -> Void, completion: ((Bool) -> Void)? = nil) { let durationKey = UIResponder.keyboardAnimationDurationUserInfoKey let curveKey = UIResponder.keyboardAnimationCurveUserInfoKey guard let userInfo = notification.userInfo, let duration = (userInfo[durationKey] as? NSNumber)?.doubleValue, let curveValue = (userInfo[curveKey] as? NSNumber)?.intValue, let curve = UIView.AnimationCurve(rawValue: curveValue) else { animations() return } UIView.animate(withDuration: duration, delay: 0, options: curve.asOptions, animations: animations, completion: completion) } extension UIView.AnimationCurve { var asOptions: UIView.AnimationOptions { switch self { case .easeInOut: return .curveEaseInOut case .easeIn: return .curveEaseIn case .easeOut: return .curveEaseOut case .linear: return .curveLinear @unknown default: return [] } } }Ideally, I would not need line 19—which won’t work if, for instance, the window were at the top of the screen. I’d rather not hard-code it for that reason. Any ideas?
0
0
586
Jan ’20
Launching Unix tools from command-line apps
I’m trying to write a utility to help automate some things with simctl. My thought was to write a quick command-line application in Swift, using the Task API to launch things, but it appears that due to App Sandboxing (I’m on 10.15) I can’t actually launch an executable in /usr/bin:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'launch path not accessible'I tried creating an Entitlements file to disable the sandbox, but this didn’t work:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <false/> </dict> </plist>What I’m trying to write is a developer tool with no plans of distribution. Is there a way to write a Swift app that launches software like this locally, or has this been completely locked down with this iteration of macOS?
6
0
1.8k
Jan ’20
Understanding the return value of a Combine Subscriber’s receive() method
I have a Combine publisher that uses a CADisplayLink to send output (Void in this case) to a subscriber. To do that, I have this callback method:@objc private func displayLinkFired(_: CADisplayLink) { let demand = self.subscriber.receive() }I have this publisher hooked up to a SwiftUI View that uses the onReceive() modifier to update some State when the DisplayLink fires. When the subscription is initially created, its demand value is unlimited, as I would expect. But in this method, the return value of receive(), stored in demand, is .max(0). Why is it .max(0) and not, as I would expect in this case, .unlimited?
1
0
643
Jan ’20
Zombie IOSurface Objects with SwiftUI and ImageIO
I’m trying to use the new ImageIO API for animating some gifs in a SwiftUI app. I created a wrapper in Objective-C to handle the ImageIO API:// ImageFrameScheduler.h @import CoreGraphics; @import Foundation; NS_ASSUME_NONNULL_BEGIN @interface ImageFrameScheduler : NSObject @property (readonly) NSURL *imageURL; - (instancetype)initWithURL:(NSURL *)imageURL NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; - (BOOL)startWithFrameHandler:(void (^)(NSInteger, CGImageRef))handler error:(NSError * _Nullable *)error; - (void)stop; @end NS_ASSUME_NONNULL_END// ImageFrameScheduler.m #import "ImageFrameScheduler.h" @import ImageIO; @interface ImageFrameScheduler() @property (readwrite) NSURL *imageURL; @property (getter=isStopping) BOOL stopping; @end @implementation ImageFrameScheduler - (instancetype)initWithURL:(NSURL *)imageURL { self = [super init]; if (self) { _imageURL = imageURL; _stopping = NO; } return self; } - (BOOL)startWithFrameHandler:(void (^)(NSInteger, CGImageRef _Nonnull))handler error:(NSError * _Nullable *)error { __weak typeof(self) welf = self; CFURLRef urlRef = (__bridge CFURLRef)self.imageURL; OSStatus status = CGAnimateImageAtURLWithBlock(urlRef, nil, ^(size_t index, CGImageRef _Nonnull image, bool* _Nonnull stop) { if (welf == nil || welf.stopping) { *stop = true; return; } handler(index, image); }); if (status != noErr) { if (error != NULL) { *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil]; } } return status == noErr; } - (void)stop { self.stopping = YES; } @endWhen I finish loading gifs from the network, I use this in a SwiftUI Image, called from my view body’s onAppear property: private func startAnimating() { imageFrameScheduler = ImageFrameScheduler(url: cachedImageURL) do { try imageFrameScheduler?.start { (_, image) in self.image = Image(decorative: image, scale: 1) } } catch { print("Error animating image: \(error)") } }These gifs are in a List, and if I scroll quickly, I eventually get a crash on an IOSurface zombie object:*** -[IOSurface retain]: message sent to deallocated instance 0x60200004de50Is there something I’m missing in the memory management of the SwiftUI Image struct or the ImageIO framework?
2
0
1.1k
Dec ’19