Repository: flutter
Issue: [google_maps_flutter] iOS native crash when map is offscreen
Labels: c: regression,c: crash,platform-ios,p: maps,package,has reproducible steps,P2,c: fatal crash,found in release: 2.10,found in release: 2.13,team-ios,triaged-ios

A crash was noted on the original PR: https://github.com/flutter/plugins/pull/2607#issuecomment-614882404

I've managed to reproduce the issue with this example: https://github.com/greensopinion/google_maps_flutter_crash

Steps to reproduce: https://github.com/greensopinion/google_maps_flutter_crash#crash-reproduction-steps

1. Run the app (if it was already running, be sure to restart)
2. Without scrolling, press the Snapshot button
3. Scroll down until the map would appear
4. Observe that the app crashes with a native stack trace 

Stack trace:

```
2021-05-03 07:06:36.715915-0700 Runner[4079:9685150] *** Assertion failure in -[FlutterStandardTypedData initWithData:type:], FlutterStandardCodec.mm:175
2021-05-03 07:06:36.723285-0700 Runner[4079:9685150] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Data cannot be nil'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff20421af6 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2042191f +[NSException raise:format:] + 0
	3   Foundation                          0x00007fff2077156a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   Flutter                             0x0000000106d2efba -[FlutterStandardTypedData initWithData:type:] + 264
	5   Flutter                             0x0000000106d2eea6 +[FlutterStandardTypedData typedDataWithData:type:] + 47
	6   Runner                              0x00000001059823dd -[FLTGoogleMapController onMethodCall:result:] + 4349
	7   Runner                              0x0000000105980ec5 __75-[FLTGoogleMapController initWithFrame:viewIdentifier:arguments:registrar:]_block_invoke + 165
	8   Flutter                             0x0000000106d2cfca __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
	9   Flutter                             0x00000001064e51fa _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166
	10  Flutter                             0x00000001064ea40a _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38
	11  Flutter                             0x0000000106877ab9 _ZNSt3__110__function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_36NS_9allocatorIS8_EEFvvEEclEv + 83
	12  Flutter                             0x00000001067fb69a _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 160
	13  Flutter                             0x00000001068000e6 _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
	14  CoreFoundation                      0x00007fff20390c57 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	15  CoreFoundation                      0x00007fff2039072a __CFRunLoopDoTimer + 926
	16  CoreFoundation                      0x00007fff2038fcdd __CFRunLoopDoTimers + 265
	17  CoreFoundation                      0x00007fff2038a35e __CFRunLoopRun + 1949
	18  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567
	19  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139
	20  UIKitCore                           0x00007fff24696cf7 -[UIApplication _run] + 912
	21  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101
	22  Runner                              0x0000000105511c3b main + 75
	23  libdyld.dylib                       0x00007fff2025a3e9 start + 1
```

Flutter details:

```
maps_example % flutter doctor -v
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-CA)
    • Flutter version 2.0.6 at /Users/dgreen/development/flutter
    • Framework revision 1d9032c7e1 (4 days ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dgreen/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2021.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.55.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (3 available)
    • iPhone 7 (mobile)          • 01E94DF4-BC80-4FEC-B409-5395910A1CA3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • iPhone 12 Pro Max (mobile) • 35B6FB68-0548-4CF2-AFDC-F5BCB529BC17 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 90.0.4430.93

• No issues found!
```