Skip to content

Commit 45132a7

Browse files
authored
Fix disposal crash (#617)
* Prevent resource disposal from throwing exceptions * Fix the order of map widget disposal * Add changelog entry * Synchronously dispose map widget and its dependencies * Fix iOS signing * Update fastlane version
1 parent 74e8a66 commit 45132a7

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ jobs:
121121
122122
popd # to repo root
123123
124+
bundle install
124125
bundle exec fastlane build_examples_tests
125126
- persist_to_workspace:
126127
root: << parameters.workspace-path >>

.fastlane/Fastfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ platform :ios do
1414
team_id: "GJZR2MEM28", # Developer Portal Team ID,
1515
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.maps.FlutterMapsExample"],
1616
targets: ["Runner"],
17-
code_sign_identity: "Apple Development: Machiney McMachineface",
17+
code_sign_identity: "Apple Development: Created via API",
1818
)
1919
update_code_signing_settings(
2020
use_automatic_signing: false,
2121
path: "example/ios/Runner.xcodeproj",
2222
team_id: "GJZR2MEM28", # Developer Portal Team ID,
2323
profile_name: lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]["com.mapbox.maps.FlutterRunnerTests"],
2424
targets: ["RunnerTests"],
25-
code_sign_identity: "Apple Development: Machiney McMachineface",
25+
code_sign_identity: "Apple Development: Created via API",
2626
)
2727
# build tests archive in the `output_directory` to launch on firebase
2828
run_tests(

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Support local assets for 3D puck and `ModelLayer`. To use a local assets, please specify it with `asset://` scheme in the uri.
44
* Fix map view crashing upon host activity destruction when using a cached Flutter engine.
5+
* Fix a rare crash happening when map widget is being disposed.
56

67
### 2.1.0
78

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
gem "fastlane"
3+
gem "fastlane", "~> 2.221.1"
44

55
plugins_path = File.join(File.dirname(__FILE__), '.fastlane', 'Pluginfile')
66
eval_gemfile(plugins_path) if File.exist?(plugins_path)

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
423423
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
424424
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
425-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
425+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
426426
CODE_SIGN_STYLE = Manual;
427427
CURRENT_PROJECT_VERSION = 1;
428428
DEVELOPMENT_TEAM = GJZR2MEM28;
@@ -456,7 +456,7 @@
456456
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
457457
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
458458
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
459-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
459+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
460460
CODE_SIGN_STYLE = Manual;
461461
CURRENT_PROJECT_VERSION = 1;
462462
DEVELOPMENT_TEAM = GJZR2MEM28;
@@ -489,7 +489,7 @@
489489
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
490490
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
491491
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
492-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
492+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
493493
CODE_SIGN_STYLE = Manual;
494494
CURRENT_PROJECT_VERSION = 1;
495495
DEVELOPMENT_TEAM = GJZR2MEM28;
@@ -566,7 +566,7 @@
566566
buildSettings = {
567567
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
568568
CLANG_ENABLE_MODULES = YES;
569-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
569+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
570570
CODE_SIGN_STYLE = Manual;
571571
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
572572
DEVELOPMENT_TEAM = GJZR2MEM28;
@@ -697,7 +697,7 @@
697697
buildSettings = {
698698
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
699699
CLANG_ENABLE_MODULES = YES;
700-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
700+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
701701
CODE_SIGN_STYLE = Manual;
702702
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
703703
DEVELOPMENT_TEAM = GJZR2MEM28;
@@ -723,7 +723,7 @@
723723
buildSettings = {
724724
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
725725
CLANG_ENABLE_MODULES = YES;
726-
CODE_SIGN_IDENTITY = "Apple Development: Machiney McMachineface";
726+
CODE_SIGN_IDENTITY = "Apple Development: Created via API";
727727
CODE_SIGN_STYLE = Manual;
728728
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
729729
DEVELOPMENT_TEAM = GJZR2MEM28;

lib/src/map_widget.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ class MapWidget extends StatefulWidget {
168168
}
169169

170170
class _MapWidgetState extends State<MapWidget> {
171-
final Completer<MapboxMap> _controller = Completer<MapboxMap>();
172-
173171
late final _MapboxMapsPlatform _mapboxMapsPlatform =
174172
_MapboxMapsPlatform(binaryMessenger: _binaryMessenger);
175173
final int _suffix = _suffixesRegistry.getSuffix();
@@ -204,14 +202,12 @@ class _MapWidgetState extends State<MapWidget> {
204202
}
205203

206204
@override
207-
void dispose() async {
208-
super.dispose();
209-
if (_controller.isCompleted) {
210-
final controller = await _controller.future;
211-
controller.dispose();
212-
}
205+
void dispose() {
206+
mapboxMap?.dispose();
213207
_suffixesRegistry.releaseSuffix(_suffix);
214208
_events.dispose();
209+
210+
super.dispose();
215211
}
216212

217213
@override
@@ -247,7 +243,6 @@ class _MapWidgetState extends State<MapWidget> {
247243
onMapLongTapListener: widget.onLongTapListener,
248244
onMapScrollListener: widget.onScrollListener,
249245
);
250-
_controller.complete(controller);
251246
if (widget.onMapCreated != null) {
252247
widget.onMapCreated!(controller);
253248
}

lib/src/mapbox_maps_platform.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ class _MapboxMapsPlatform {
9999
}
100100

101101
void dispose() async {
102-
await _channel.invokeMethod('platform#releaseMethodChannels');
102+
try {
103+
await _channel.invokeMethod('platform#releaseMethodChannels');
104+
} catch (e) {
105+
print("Error releasing method channels: $e");
106+
}
103107

104108
_channel.setMethodCallHandler(null);
105109
}

0 commit comments

Comments
 (0)