Post

Replies

Boosts

Views

Activity

[macOS 27] (Regression) IOPMPowerSource not returning a Temperature value anymore
Background Li-ion batteries permanently lose capacity with increasing temperature. Common knowledge suggests that this effect starts to become serious at 35ºC. To my knowledge, macOS does not warn the user about this situation. Even worse, macOS in default configuration is known to be extremely conservative regarding fan noise, resulting in battery temperatures of 45ºC and higher. This negligence has led to a rich market of 3rd party apps that close this gap. History Fortunately, it was possible to retrieve the current battery temperature via a call to IOPMPowerSource. This was removed in macOS 27. Now you might ask, why not query the SMC or the IOHIDService? While both ways return temperature sensor information, to my knowledge this will result in a rejection from the App Store. The Problem How do we write an App Store compliant app for macOS 27 that warns the user about her MacBook battery overheating? Code App-Store compliant code pre macOS 27 CFMutableDictionaryRef matching , properties = NULL; io_registry_entry_t entry = 0; matching = IOServiceMatching( "IOPMPowerSource" ); entry = IOServiceGetMatchingService( kIOMainPortDefault , matching ); IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 ); NSDictionary psPropertyDict = CFBridgingRelease(properties); NSNumber *temp = psPropertyDict[@"Temperature"]; Presumably Non App Store compliant code #import <IOKit/hidsystem/IOHIDEventSystemClient.h> #import <IOKit/hidsystem/IOHIDServiceClient.h> extern CFTypeRef IOHIDServiceClientCopyEvent(IOHIDServiceClientRef, int64_t, int64_t, int64_t); #define IOHIDEventTypeTemperature 0x0FLL IOHIDEventSystemClientRef client = IOHIDEventSystemClientCreate(kCFAllocatorDefault); NSArray *services = CFBridgingRelease(IOHIDEventSystemClientCopyServices(client)); for (id o in services) { IOHIDServiceClientRef service = (__bridge IOHIDServiceClientRef)o; CFTypeRef event = IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0); NSString *sensor = CFBridgingRelease(IOHIDServiceClientCopyProperty(service, CFSTR(kIOHIDProductKey))); static int64_t IOHIDEventFieldTemperatureLevel = IOHIDEventFieldBase(IOHIDEventTypeTemperature); CFTypeRef event = IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0); double value = IOHIDEventGetFloatValue(event, IOHIDEventFieldTemperatureLevel); }
1
0
120
2w
Crash in NSDictionaryController -addObject:
Consider the following code fragments: @property (readonly) NSDictionaryController *loggedConfigsController; _loggedConfigs = NSMutableDictionary.dictionary; _loggedConfigsController = [NSDictionaryController.alloc initWithContent:self.loggedConfigs]; _loggedConfigsController.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"value" ascending:YES]]; _loggedConfigsController.preservesSelection = YES; _loggedConfigsController.avoidsEmptySelection = YES; _loggedConfigsController.selectsInsertedObjects = NO; _loggedConfigsController.automaticallyRearrangesObjects = YES; - (void)logEventWithTitle:(NSString *)title ident:(p_ident_t)ident { // called from main queue and dispatch queues NSString *identString = [self identStringForIdent:ident]; NSNumber *dictIdent = self.loggedConfigs[identString]; if (dictIdent == nil) { NSDictionaryControllerKeyValuePair *c = self.loggedConfigsController.newObject; c.key = identString; c.value = title; [self.loggedConfigsController addObject:c];// crash } } Crash log: Thread 4 Crashed:: Dispatch queue: Pinger #9 0 libobjc.A.dylib 0x7ff81bb7fcc3 objc_retain + 35 1 AppKit 0x7ff81f18d831 -[NSArrayController _setObjects:] + 49 2 AppKit 0x7ff81f18e502 -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis:] + 365 Does anyone know why -addObject: fails? Any help is appreciated. Thanks in advance!
1
0
736
Mar ’23
[macOS 27] (Regression) IOPMPowerSource not returning a Temperature value anymore
Background Li-ion batteries permanently lose capacity with increasing temperature. Common knowledge suggests that this effect starts to become serious at 35ºC. To my knowledge, macOS does not warn the user about this situation. Even worse, macOS in default configuration is known to be extremely conservative regarding fan noise, resulting in battery temperatures of 45ºC and higher. This negligence has led to a rich market of 3rd party apps that close this gap. History Fortunately, it was possible to retrieve the current battery temperature via a call to IOPMPowerSource. This was removed in macOS 27. Now you might ask, why not query the SMC or the IOHIDService? While both ways return temperature sensor information, to my knowledge this will result in a rejection from the App Store. The Problem How do we write an App Store compliant app for macOS 27 that warns the user about her MacBook battery overheating? Code App-Store compliant code pre macOS 27 CFMutableDictionaryRef matching , properties = NULL; io_registry_entry_t entry = 0; matching = IOServiceMatching( "IOPMPowerSource" ); entry = IOServiceGetMatchingService( kIOMainPortDefault , matching ); IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 ); NSDictionary psPropertyDict = CFBridgingRelease(properties); NSNumber *temp = psPropertyDict[@"Temperature"]; Presumably Non App Store compliant code #import <IOKit/hidsystem/IOHIDEventSystemClient.h> #import <IOKit/hidsystem/IOHIDServiceClient.h> extern CFTypeRef IOHIDServiceClientCopyEvent(IOHIDServiceClientRef, int64_t, int64_t, int64_t); #define IOHIDEventTypeTemperature 0x0FLL IOHIDEventSystemClientRef client = IOHIDEventSystemClientCreate(kCFAllocatorDefault); NSArray *services = CFBridgingRelease(IOHIDEventSystemClientCopyServices(client)); for (id o in services) { IOHIDServiceClientRef service = (__bridge IOHIDServiceClientRef)o; CFTypeRef event = IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0); NSString *sensor = CFBridgingRelease(IOHIDServiceClientCopyProperty(service, CFSTR(kIOHIDProductKey))); static int64_t IOHIDEventFieldTemperatureLevel = IOHIDEventFieldBase(IOHIDEventTypeTemperature); CFTypeRef event = IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0); double value = IOHIDEventGetFloatValue(event, IOHIDEventFieldTemperatureLevel); }
Replies
1
Boosts
0
Views
120
Activity
2w
macos 15.4 beta 3: NSStatusNone et. al. not rendered
In the new beta, NSStatusNone et. al. are either missing or not rendered. Example screenshot is from Xcode, but other apps are also affected. Filed as FB16822441
Topic: UI Frameworks SubTopic: AppKit
Replies
3
Boosts
0
Views
751
Activity
Mar ’25
Xcode 15.1 doesn't create Objective-C Category files anymore
Create a new Project: macOS / App / Language: Objective-C Create a new Cocoa Class. Name it “Foo” Create a new Objective-C File. Name it “Bar”. Set File Type to “Category”. Set class to “Foo”. Click Next, then Create. Nothing happens. FB13465308 Yes, I'm one of those old fashioned people who still use Objective-C...
Replies
10
Boosts
8
Views
3.9k
Activity
Mar ’24
Streaming live video capture from one iPhone to another
What's the best way of capturing live video from the iPhone camera and streaming it over the network to another iPhone for display? Ideally using Apple APIs only, on iOS 12 or later.
Replies
0
Boosts
0
Views
619
Activity
Apr ’23
Crash in NSDictionaryController -addObject:
Consider the following code fragments: @property (readonly) NSDictionaryController *loggedConfigsController; _loggedConfigs = NSMutableDictionary.dictionary; _loggedConfigsController = [NSDictionaryController.alloc initWithContent:self.loggedConfigs]; _loggedConfigsController.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"value" ascending:YES]]; _loggedConfigsController.preservesSelection = YES; _loggedConfigsController.avoidsEmptySelection = YES; _loggedConfigsController.selectsInsertedObjects = NO; _loggedConfigsController.automaticallyRearrangesObjects = YES; - (void)logEventWithTitle:(NSString *)title ident:(p_ident_t)ident { // called from main queue and dispatch queues NSString *identString = [self identStringForIdent:ident]; NSNumber *dictIdent = self.loggedConfigs[identString]; if (dictIdent == nil) { NSDictionaryControllerKeyValuePair *c = self.loggedConfigsController.newObject; c.key = identString; c.value = title; [self.loggedConfigsController addObject:c];// crash } } Crash log: Thread 4 Crashed:: Dispatch queue: Pinger #9 0 libobjc.A.dylib 0x7ff81bb7fcc3 objc_retain + 35 1 AppKit 0x7ff81f18d831 -[NSArrayController _setObjects:] + 49 2 AppKit 0x7ff81f18e502 -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis:] + 365 Does anyone know why -addObject: fails? Any help is appreciated. Thanks in advance!
Replies
1
Boosts
0
Views
736
Activity
Mar ’23