Skip to content

Commit

Permalink
Merge pull request #18 from Maksimka101/fix/combine-initialization-er…
Browse files Browse the repository at this point in the history
…rors

Fix: Combine initialization
  • Loading branch information
Maksimka101 committed Aug 24, 2023
2 parents c213c16 + c9caf3e commit dcd7d09
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.5.5
- Fix the `BackgroundIsolateBinaryMessenger` initialization.

## 0.5.4
- Upgrade to the flutter 3.13.0.

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
13 changes: 8 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -171,10 +171,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -185,6 +187,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -272,7 +275,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -350,7 +353,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -399,7 +402,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> _createAssetsIsolate() async {
final isolate = await Combine().spawn<String>(
final isolate = await Combine().spawn(
(context) {
final messenger = context.messenger;

Expand Down Expand Up @@ -170,7 +170,7 @@ class _MyHomePageState extends State<MyHomePage> {
title: const Text("Error from calculate fibonacci worker"),
subtitle: Text(_calculateFibonacciError.toString()),
),
]
],
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 9 additions & 9 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
combine:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.5.4"
version: "0.5.5"
cupertino_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -264,18 +264,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
Expand All @@ -296,10 +296,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
vector_math:
dependency: transitive
description:
Expand Down
9 changes: 1 addition & 8 deletions lib/src/bindings/isolate_bindings/isolate_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ import 'package:flutter/services.dart';

part 'absent_scheduler_binding.dart';
part 'mock_binary_messenger_service_binding.dart';
part 'mock_restoration_manager.dart';

class IsolateBinding extends BindingBase
with
_AbsentSchedulerBinding,
ServicesBinding,
_MockBinaryMessengerServiceBinding {
@override
ui.PlatformDispatcher get platformDispatcher {
throw UnimplementedError();
}

}
_MockBinaryMessengerServiceBinding {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mixin _MockBinaryMessengerServiceBinding on ServicesBinding {

@override
RestorationManager createRestorationManager() {
return _MockRestorationManager();
throw IsolateBindingInitializationFinished();
}
}

class IsolateBindingInitializationFinished {}

This file was deleted.

12 changes: 6 additions & 6 deletions lib/src/isolate_factory/native_isolate_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ class NativeIsolateFactory extends IsolateFactory {
}

static void _runInIsolate<T>(_IsolateSetup<T> setup) {
final receivePort = ReceivePort();
final isolateMessenger = NativeInternalIsolateMessenger(
setup.sendPort,
receivePort.asBroadcastStream().cast<Object?>(),
);
final isolateToken = setup.isolateToken;
if (isolateToken != null) {
_lastUsedIsolateToken = isolateToken;
BackgroundIsolateBinaryMessenger.ensureInitialized(isolateToken);
}
final receivePort = ReceivePort();
final isolateMessenger = NativeInternalIsolateMessenger(
setup.sendPort,
receivePort.asBroadcastStream().cast<Object?>(),
);
IsolatedBinaryMessengerMiddleware(isolateMessenger).initialize();
try {
IsolateBinding();
} catch (_) {} // Isolate binding should throw exception to skip unnecessary initialization.
} on IsolateBindingInitializationFinished catch (_) {} // Isolate binding will throw an exception to skip unnecessary initialization.

final isolateContext = IsolateContext(
argument: setup.argument,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: combine
description: A Flutter package which allows you to work with
MethodChannels in Isolate and provides simplified Isolate and Thread Pool API.
version: 0.5.4
version: 0.5.5
homepage: https://github.com/Maksimka101/combine
repository: https://github.com/Maksimka101/combine

Expand Down

0 comments on commit dcd7d09

Please sign in to comment.