Skip to content

Commit 237dfa1

Browse files
authored
Better isolates (#71)
* Better isolates * fix: windows tests * fix: windows tests * chore: updated xcode assets * fix: disable cache android * fix: no impeller for ios and macos
1 parent d76b861 commit 237dfa1

File tree

17 files changed

+68
-57
lines changed

17 files changed

+68
-57
lines changed

.github/workflows/tests_android.yml

+2-24
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ jobs:
1212
runs-on: macos-13
1313
steps:
1414
- uses: actions/checkout@v3
15-
- uses: actions/cache@v3
16-
with:
17-
path: |
18-
~/.gradle/caches
19-
~/.gradle/wrapper
20-
key: gradle-android
21-
- uses: actions/cache@v3
22-
id: avd-cache
23-
with:
24-
path: |
25-
~/.android/avd/*
26-
~/.android/adb*
27-
key: avd-android
2815
- uses: actions/setup-java@v3
2916
with:
3017
distribution: 'temurin'
@@ -35,19 +22,10 @@ jobs:
3522
flutter-version: '3.x'
3623
channel: 'stable'
3724
- run: flutter pub get
38-
- if: steps.avd-cache.outputs.cache-hit != 'true'
39-
uses: reactivecircus/android-emulator-runner@v2
40-
with:
41-
api-level: 30
42-
avd-name: PhoneAPI30
43-
force-avd-creation: false
44-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
45-
disable-animations: false
46-
script: echo "Generated AVD snapshot for caching."
4725
- uses: reactivecircus/android-emulator-runner@v2
4826
with:
49-
api-level: 30
50-
avd-name: PhoneAPI30
27+
api-level: 29
28+
avd-name: PhoneAPI29
5129
force-avd-creation: false
5230
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
5331
disable-animations: true

.github/workflows/tests_ios.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
run: |
2424
flutter pub get
2525
cd example/ios && pod install
26-
- run: "cd example && flutter test --verbose integration_test/app_test.dart"
26+
- run: "cd example && flutter test --verbose --no-enable-impeller integration_test/app_test.dart"

.github/workflows/tests_macos.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ jobs:
2121
flutter config --enable-macos-desktop
2222
flutter pub get
2323
cd example/macos && pod install
24-
- run: "cd example && flutter test --verbose -d macos integration_test/app_test.dart"
24+
- run: "cd example && flutter test --verbose --no-enable-impeller -d macos integration_test/app_test.dart"
2525
- run: "cd example && flutter test --verbose test/app_test.dart"

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.8.2
2+
3+
- Updated Isolate spawn logic to close gracefully
4+
15
## 3.8.1
26

37
- Updated binaries to v1.10.3

example/ios/Flutter/AppFrameworkInfo.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>11.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '11.0'
2+
# platform :ios, '12.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ EXTERNAL SOURCES:
1919
:path: ".symlinks/plugins/openpgp/ios"
2020

2121
SPEC CHECKSUMS:
22-
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
23-
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
22+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
23+
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
2424
openpgp: 8925c86ba4a2663e345e3e6e133d8c4e6f6754a3
2525

26-
PODFILE CHECKSUM: 663715e941f9adb426e33bf9376914006f9ea95b
26+
PODFILE CHECKSUM: 1a782344d33c12ced0182eeab11e8668d253eb48
2727

28-
COCOAPODS: 1.11.3
28+
COCOAPODS: 1.14.3

example/ios/Runner.xcodeproj/project.pbxproj

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -158,7 +158,7 @@
158158
97C146E61CF9000F007C117D /* Project object */ = {
159159
isa = PBXProject;
160160
attributes = {
161-
LastUpgradeCheck = 1300;
161+
LastUpgradeCheck = 1510;
162162
ORGANIZATIONNAME = "";
163163
TargetAttributes = {
164164
97C146ED1CF9000F007C117D = {
@@ -202,10 +202,12 @@
202202
/* Begin PBXShellScriptBuildPhase section */
203203
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
204204
isa = PBXShellScriptBuildPhase;
205+
alwaysOutOfDate = 1;
205206
buildActionMask = 2147483647;
206207
files = (
207208
);
208209
inputPaths = (
210+
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
209211
);
210212
name = "Thin Binary";
211213
outputPaths = (
@@ -238,6 +240,7 @@
238240
};
239241
9740EEB61CF901F6004384FC /* Run Script */ = {
240242
isa = PBXShellScriptBuildPhase;
243+
alwaysOutOfDate = 1;
241244
buildActionMask = 2147483647;
242245
files = (
243246
);
@@ -325,7 +328,7 @@
325328
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
326329
GCC_WARN_UNUSED_FUNCTION = YES;
327330
GCC_WARN_UNUSED_VARIABLE = YES;
328-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
331+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
329332
MTL_ENABLE_DEBUG_INFO = NO;
330333
SDKROOT = iphoneos;
331334
SUPPORTED_PLATFORMS = iphoneos;
@@ -411,7 +414,7 @@
411414
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
412415
GCC_WARN_UNUSED_FUNCTION = YES;
413416
GCC_WARN_UNUSED_VARIABLE = YES;
414-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
417+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
415418
MTL_ENABLE_DEBUG_INFO = YES;
416419
ONLY_ACTIVE_ARCH = YES;
417420
SDKROOT = iphoneos;
@@ -460,7 +463,7 @@
460463
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
461464
GCC_WARN_UNUSED_FUNCTION = YES;
462465
GCC_WARN_UNUSED_VARIABLE = YES;
463-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
466+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
464467
MTL_ENABLE_DEBUG_INFO = NO;
465468
SDKROOT = iphoneos;
466469
SUPPORTED_PLATFORMS = iphoneos;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/ios/Runner/Info.plist

+2
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
<false/>
4444
<key>CADisableMinimumFrameDurationOnPhone</key>
4545
<true/>
46+
<key>UIApplicationSupportsIndirectInputEvents</key>
47+
<true/>
4648
</dict>
4749
</plist>

example/macos/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ SPEC CHECKSUMS:
1919

2020
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
2121

22-
COCOAPODS: 1.12.1
22+
COCOAPODS: 1.14.3

example/macos/Runner.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
isa = PBXProject;
204204
attributes = {
205205
LastSwiftUpdateCheck = 0920;
206-
LastUpgradeCheck = 1300;
206+
LastUpgradeCheck = 1510;
207207
ORGANIZATIONNAME = "The Flutter Authors";
208208
TargetAttributes = {
209209
33CC10EC2044A3C60003C045 = {

example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ packages:
293293
path: ".."
294294
relative: true
295295
source: path
296-
version: "3.8.1"
296+
version: "3.8.2"
297297
package_config:
298298
dependency: transitive
299299
description:

lib/bridge/binding.dart

+33-14
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,40 @@ class Binding {
2727
_library = openLib();
2828
}
2929

30-
static callBridge(IsolateArguments args) async {
30+
static void callBridge(IsolateArguments args) async {
3131
var result = await Binding().call(args.name, args.payload);
3232
args.port.send(result);
3333
}
3434

3535
Future<Uint8List> callAsync(String name, Uint8List payload) async {
36-
final port = ReceivePort();
36+
final port = ReceivePort('${_libraryName}_port');
3737
final args = IsolateArguments(name, payload, port.sendPort);
38+
final completer = new Completer<Uint8List>();
39+
40+
final isolate = await Isolate.spawn(
41+
callBridge,
42+
args,
43+
errorsAreFatal: false,
44+
debugName: '${_libraryName}_isolate',
45+
onError: port.sendPort,
46+
);
47+
48+
port.listen(
49+
(message) async {
50+
if (message is Uint8List) {
51+
completer.complete(message);
52+
} else if (message is List) {
53+
completer.completeError(message.firstOrNull ?? "internal error");
54+
} else {
55+
completer.completeError(message ?? "spawn error");
56+
}
57+
port.close();
58+
},
59+
onDone: () {
60+
isolate.kill(priority: Isolate.beforeNextEvent);
61+
},
62+
);
3863

39-
final isolate = await Isolate.spawn(callBridge, args);
40-
41-
Completer<Uint8List> completer = new Completer();
42-
43-
port.listen((message) async {
44-
completer.complete(message);
45-
port.close();
46-
isolate.kill();
47-
});
4864
return completer.future;
4965
}
5066

@@ -66,7 +82,7 @@ class Binding {
6682
final result = callable(namePointer, payloadPointer, payload.length);
6783

6884
malloc.free(namePointer);
69-
malloc.free(payloadPointer);
85+
malloc.free(pointer);
7086

7187
handleError(result.ref.error, result);
7288

@@ -189,8 +205,11 @@ class Binding {
189205

190206
if (Platform.isWindows) {
191207
if (isFlutterTest) {
192-
var ffiFile = Path.canonicalize(
193-
Path.join(r'build\windows\runner\Debug', '$_libraryName.dll'));
208+
var arch =
209+
Platform.resolvedExecutable.contains("x64") ? "x64" : "arm64";
210+
211+
var ffiFile = Path.canonicalize(Path.join(
212+
r'build\windows', arch, r'runner\Debug', '$_libraryName.dll'));
194213
validateTestFFIFile(ffiFile);
195214
return ffi.DynamicLibrary.open(ffiFile);
196215
}

lib/openpgp.dart

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class OpenPGPException implements Exception {
1010
String cause;
1111

1212
OpenPGPException(this.cause);
13+
14+
@override
15+
String toString() {
16+
return 'OpenPGPException: $cause';
17+
}
1318
}
1419

1520
enum Hash { SHA256, SHA224, SHA384, SHA512 }

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openpgp
22
description: library for use OpenPGP with support for android and ios, macOS, linux, windows and web
3-
version: 3.8.1
3+
version: 3.8.2
44
homepage: https://github.com/jerson/flutter-openpgp
55

66
environment:

0 commit comments

Comments
 (0)