Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): Crash with EXC_BAD_ACCESS #3657

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enums:
macros:
include:
- kIOPlatformUUIDKey
- IO_OBJECT_NULL
typedefs:
include:
- CFTypeRef
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ final class ASFDeviceInfoMacOS extends ASFDeviceInfoPlatform {
Future<String?> get deviceOsReleaseVersion async => 'macOS/$_osVersion';

NSScreen? get _mainScreen {
try {
// NSScreen is not linked in Dart-only apps.
return NSScreen.getMainScreen(_native);
} on Exception {
// NSScreen is not linked in Dart-only apps.
if (!zIsFlutter) {
return null;
}
// TODO(dnys1): https://github.com/dart-lang/ffigen/issues/608
// return NSScreen.getMainScreen(_native);
return null;
}

@override
Expand All @@ -110,19 +111,28 @@ final class ASFDeviceInfoMacOS extends ASFDeviceInfoPlatform {
_mainScreen?.visibleFrame.size.width.toInt() ?? 0;

String? _ioValueFor<CFType>(String key) => using((arena) {
const serviceName = 'IOPlatformExpertDevice';
final service = _native.IOServiceGetMatchingService(
_native.kIOMasterPortDefault,
_native.IOServiceMatching(
'IOPlatformExpertDevice'.toNativeUtf8(allocator: arena).cast(),
serviceName.toNativeUtf8(allocator: arena).cast(),
),
);
logger.verbose('Found service matching $serviceName: $service');
if (service == IO_OBJECT_NULL) {
return null;
}
arena.onReleaseAll(() => _native.IOObjectRelease(service));
final data = _native.IORegistryEntryCreateCFProperty(
service,
key.toCFString(lib: _native, arena: arena).cast(),
_native.kCFAllocatorDefault,
0,
);
logger.verbose('Got data for $key: $data');
if (data == nullptr) {
return null;
}
arena.onReleaseAll(() => _native.CFRelease(data));
return switch (CFType) {
const (CFData) => data.cast<CFData>().toDartString(_native),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.