fix(macos): run Skia instead of Impeller on Intel Macs

Impeller garbles text on some Intel Macs. Info.plist is shared between
the two slices of the universal app, so the x86_64 slice answers the
engine's FLTEnableImpeller lookup itself; arm64 stays on Impeller.

Support bundles now name the active renderer and CPU architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonas Acker
2026-10-31 09:09:20 +01:00
parent 551265182e
commit 849758201a
3 changed files with 47 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
import 'package:bike_control/widgets/ui/bk_icon_button.dart';
import 'dart:async';
import 'dart:ffi' show Abi;
import 'dart:io';
import 'dart:ui' as ui;
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/bluetooth/devices/bluetooth_device.dart';
@@ -90,6 +92,7 @@ Future<String> debugText({bool includeDiscovery = true}) async {
App Version: ${guard(() => '${packageInfoValue?.version}${shorebirdPatch?.number != null ? '+${shorebirdPatch!.number}' : ''}')}
Update Track: ${guard(() => IAPManager.instance.isBetaTester ? 'beta' : 'stable')}
Platform: ${Platform.operatingSystem} ${Platform.operatingSystemVersion}
Renderer: ${guard(() => ui.ImageFilter.isShaderFilterSupported ? 'Impeller' : 'Skia')} (${Abi.current()})
Target: ${guard(() => core.settings.getLastTarget()?.name ?? '-')}
Trainer App: ${guard(() => core.settings.getTrainerApp()?.name ?? '-')}
Connected Controllers: ${guard(() => describeControllers(core.connection.devices))}

View File

@@ -3,9 +3,38 @@ import FlutterMacOS
import multi_window_native
import window_manager
#if arch(x86_64)
// Impeller garbles text on some Intel Macs, so the x86_64 slice runs Skia. Info.plist
// is shared with the arm64 slice, and the engine reads FLTEnableImpeller from it
// through this lookup for every engine, including the overlay's. Remove once
// Flutter's opt-out goes away or a release fixes Impeller on Intel.
private extension Bundle {
static let useSkia: Void = {
guard
let original = class_getInstanceMethod(
Bundle.self, #selector(object(forInfoDictionaryKey:))),
let replacement = class_getInstanceMethod(
Bundle.self, #selector(skiaObject(forInfoDictionaryKey:)))
else { return }
method_exchangeImplementations(original, replacement)
}()
@objc func skiaObject(forInfoDictionaryKey key: String) -> Any? {
if key == "FLTEnableImpeller" {
return NSNumber(value: false)
}
return skiaObject(forInfoDictionaryKey: key)
}
}
#endif
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
#if arch(x86_64)
_ = Bundle.useSkia
#endif
let flutterViewController = FlutterViewController()
let windowFrame = self.frame
self.contentViewController = flutterViewController

View File

@@ -0,0 +1,15 @@
import 'dart:ffi' show Abi;
import 'package:bike_control/widgets/menu.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('the support bundle names the active renderer and CPU architecture', () async {
debugDiagnosticsGatherOverride = ({bool includeDiscovery = true}) => Future.error(StateError('not under test'));
addTearDown(() => debugDiagnosticsGatherOverride = null);
final text = await debugText(includeDiscovery: false);
expect(text, matches(RegExp('^Renderer: (Impeller|Skia) \\(${Abi.current()}\\)\$', multiLine: true)));
});
}