From 4846a0b34230cea793f662cca8edabf762ff9af2 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 23 Oct 2025 13:41:03 +1100 Subject: [PATCH 1/2] Fix objectRetainCount on arm64 --- pkgs/ffigen/test/native_objc_test/util.dart | 2 +- pkgs/objective_c/test/autorelease_test.dart | 2 ++ pkgs/objective_c/test/util.dart | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/ffigen/test/native_objc_test/util.dart b/pkgs/ffigen/test/native_objc_test/util.dart index d9f9d64ce..2cb896640 100644 --- a/pkgs/ffigen/test/native_objc_test/util.dart +++ b/pkgs/ffigen/test/native_objc_test/util.dart @@ -98,7 +98,7 @@ int objectRetainCount(Pointer object) { // isValidObject broke due to a runtime update. // These constants are the ISA_MASK macro defined in runtime/objc-private.h. const maskX64 = 0x00007ffffffffff8; - const maskArm = 0x00000001fffffff8; + const maskArm = 0x0000000ffffffff8; final mask = Abi.current() == Abi.macosX64 ? maskX64 : maskArm; final clazz = Pointer.fromAddress(header & mask); diff --git a/pkgs/objective_c/test/autorelease_test.dart b/pkgs/objective_c/test/autorelease_test.dart index 73cfd7da4..db47cae72 100644 --- a/pkgs/objective_c/test/autorelease_test.dart +++ b/pkgs/objective_c/test/autorelease_test.dart @@ -26,6 +26,7 @@ void main() { { final object = NSObject(); pointer = object.ref.retainAndAutorelease(); + expect(objectRetainCount(pointer), greaterThan(0)); } doGC(); expect(objectRetainCount(pointer), greaterThan(0)); @@ -45,6 +46,7 @@ void main() { { final object = NSObject(); pointer = object.ref.retainAndAutorelease(); + expect(objectRetainCount(pointer), greaterThan(0)); } doGC(); expect(objectRetainCount(pointer), greaterThan(0)); diff --git a/pkgs/objective_c/test/util.dart b/pkgs/objective_c/test/util.dart index f4eb35faa..01e360541 100644 --- a/pkgs/objective_c/test/util.dart +++ b/pkgs/objective_c/test/util.dart @@ -59,7 +59,7 @@ int objectRetainCount(Pointer object) { // isValidObject broke due to a runtime update. // These constants are the ISA_MASK macro defined in runtime/objc-private.h. const maskX64 = 0x00007ffffffffff8; - const maskArm = 0x00000001fffffff8; + const maskArm = 0x0000000ffffffff8; final mask = Abi.current() == Abi.macosX64 ? maskX64 : maskArm; final clazz = Pointer.fromAddress(header & mask); From 48ee4e49f6e7410c92f0fddbcb826ce506d5ad43 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 23 Oct 2025 13:51:25 +1100 Subject: [PATCH 2/2] fix global test --- pkgs/ffigen/test/native_objc_test/global_native_test.dart | 3 +-- pkgs/ffigen/test/native_objc_test/global_test.dart | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index 0cb2727fd..5042fe0b7 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -52,8 +52,7 @@ void main() { globalObject = NSObject(); final obj1raw = globalObject!.ref.pointer; - // TODO(https://github.com/dart-lang/native/issues/1435): Fix flakiness. - // expect(objectRetainCount(obj1raw), greaterThan(0)); + expect(objectRetainCount(obj1raw), greaterThan(0)); return obj1raw; } diff --git a/pkgs/ffigen/test/native_objc_test/global_test.dart b/pkgs/ffigen/test/native_objc_test/global_test.dart index 89a5ffebb..44fc79ca3 100644 --- a/pkgs/ffigen/test/native_objc_test/global_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_test.dart @@ -54,8 +54,7 @@ void main() { lib.globalObject = NSObject(); final obj1raw = lib.globalObject!.ref.pointer; - // TODO(https://github.com/dart-lang/native/issues/1435): Fix flakiness. - // expect(objectRetainCount(obj1raw), greaterThan(0)); + expect(objectRetainCount(obj1raw), greaterThan(0)); return obj1raw; }