Skip to content

Release iOS build: VM snapshot must be valid #24641

@marnberg

Description

@marnberg

Our iOS application starts with a white screen on initial launch and is stuck in that state until you kill and relaunch the application, After that the application runs normally. There are many other report on this that have been closed so I wanted to include foolproof steps to reproduce this from a blank template application. This issue is not related to any specific package but manifests itself when installing any new package and build in release mode.

Steps to Reproduce

1: $>flutter create flutter_vm_crash
2: $>cd flutter_vm_crash
3: $>open ios/Runner.xcworkspace/
4: in Xcode > Set Bundle Identifier and Signing Team
5: plug in iPhone
6: flutter run --release; app starts up normally
7: in Xcode > clean project > run app from xcode; app still runs normally
8: $>open pubspec.yaml > add an additional dependency, I added device_info package

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

  device_info: ^0.3.0`

9: $>flutter packages get
10: $>flutter run --release; app starts up normally
11: in Xcode > clean project > run app from xcode
12: White screen appears with VM snapshot must be valid. log
13: in Xcode > Re run the application, app starts up normally
14: repeat step 11: > clean project > run app from xcode and white screen appears again

Logs

Runner[39545:15296040] [VERBOSE-2:dart_vm.cc(259)] VM snapshot must be valid.
Runner[39545:15296040] [VERBOSE-3:shell.cc(212)] Check failed: vm. Must be able to initialize the VM.

flutter analyze

Analyzing flutter_vm_crash...                                    
No issues found! (ran in 4.7s)
flutter doctor -v
[✓] Flutter (Channel beta, v0.11.8, on Mac OS X 10.13.6 17G65, locale en-US)
    • Flutter version 0.11.8 at /Users/martin/Documents/Repos/flutter
    • Framework revision f5b02e3c05 (34 hours ago), 2018-11-20 07:49:29 -0800
    • Engine revision 1baf081343
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at /Users/martin/Library/Android/sdk
    • Android NDK at /Users/martin/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 27.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_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 25.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.28.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.20.0

[✓] Connected device (1 available)
    • mydevice • number • ios • iOS 11.3

• No issues found!

Activity

added
c: crashStack traces logged to the console
platform-iosiOS applications specifically
toolAffects the "flutter" command-line tool. See also t: labels.
on Nov 22, 2018
huuang

huuang commented on Nov 27, 2018

@huuang

I have the same problem, why is this problem so hard to solve?

added this to the Goals milestone on Nov 27, 2018
zoechi

zoechi commented on Nov 27, 2018

@zoechi
Contributor
marnberg

marnberg commented on Nov 27, 2018

@marnberg
Author

Related to this similar crash
#24479

marnberg

marnberg commented on Nov 27, 2018

@marnberg
Author

Also related to
#24427

marnberg

marnberg commented on Nov 27, 2018

@marnberg
Author

This is blocker for us to release our application to the app store on iOS

tvolkert

tvolkert commented on Nov 29, 2018

@tvolkert
Contributor

The issue is that Xcode is trying to run a debug build, but there are leftover artifacts from the CLI release build (even when you clean, since Xcode doesn't clean CLI's build directory).

You can get around this in Xcode by changing to the "Release" Build Configuration. In Xcode, go to Product > Scheme > Edit Scheme, then edit the "Run" scheme -- change the "Build Configuration" to "Release". Then when you run in Xcode, you'll be running in Flutter's release mode, and your build artifacts will play nicely with one another.

tvolkert

tvolkert commented on Nov 30, 2018

@tvolkert
Contributor

The underlying issue is that when you run flutter run --(debug|release) at the command-line, the Flutter tool edits some Xcode project properties to match your desired build, but it unintelligently edits all configurations to match.

For example, if you run flutter run --release, then inspect the Pods-Runner-frameworks.sh script, you'll see that all configurations are set to use Flutter's prebuilt release binary:

if [[ "$CONFIGURATION" == "Debug" ]]; then
  install_framework "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework"
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
  install_framework "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework"
fi
if [[ "$CONFIGURATION" == "Profile" ]]; then
  install_framework "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework"
fi

Meanwhile, Flutter's xcode_backend.sh is smart enough to [correctly] respect the build mode via the $CONFIGURATION environment variable (set by Xcode when it invokes the script). So when running in the debug configuration (default) after having run flutter run --release, apps get built in a hybrid state, which causes the error.

The fix should be that Flutter sets up the different Xcode build configurations correctly.

In the meantime, a workaround for this issue is to ensure that when running via Xcode, you always use the run configuration that matches your last CLI invocation.

marnberg

marnberg commented on Nov 30, 2018

@marnberg
Author

Thanks Todd, I was able to verify that your fix worked for the steps I provided. We are still seeing the behavior in release build but it may be another issue. The app hangs on first install then works if killed and relaunched. The only thing I get in terms of logs from the release build is

default	13:31:21.300529 -0800	Runner	TIC Enabling TLS [3:0x1c41747c0]
default	13:31:21.301211 -0800	Runner	TIC TCP Conn Start [3:0x1c41747c0]
default	13:31:21.302102 -0800	Runner	Task <FC4FFF5A-4D39-4BA8-8CB8-B2574FF135E0>.<1> setting up Connection 3
default	13:31:21.302833 -0800	Runner	[4 <private> <private>] start
default	13:31:21.329423 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 1, Pending(0)
default	13:31:21.357804 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 2, Pending(0)
default	13:31:21.359310 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 11, Pending(0)
default	13:31:21.360843 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 12, Pending(0)
default	13:31:21.361445 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 14, Pending(0)
default	13:31:21.369854 -0800	Runner	System Trust Evaluation yielded status(0)
default	13:31:21.377815 -0800	Runner	TIC TLS Trust Result [3:0x1c41747c0]: 0
default	13:31:21.397235 -0800	Runner	TIC TLS Event [3:0x1c41747c0]: 20, Pending(0)
default	13:31:21.397810 -0800	Runner	TIC TCP Conn Connected [3:0x1c41747c0]: Err(16)
default	13:31:21.398798 -0800	Runner	TIC TCP Conn Event [3:0x1c41747c0]: 1
default	13:31:21.399362 -0800	Runner	TIC TCP Conn Event [3:0x1c41747c0]: 8
default	13:31:21.399937 -0800	Runner	TIC TLS Handshake Complete [3:0x1c41747c0]
default	13:31:21.401160 -0800	Runner	Task <FC4FFF5A-4D39-4BA8-8CB8-B2574FF135E0>.<1> now using Connection 3
default	13:31:21.401816 -0800	Runner	Task <FC4FFF5A-4D39-4BA8-8CB8-B2574FF135E0>.<1> sent request, body S
default	13:31:21.717838 -0800	CommCenter	QMI: Svc=0x03(NAS) Ind MsgId=0x0051 Bin=['01 1F 00 80 03 02 04 AB 0F 51 00 13 00 14 06 00 B4 F2 98 FF 00 00 A2 01 00 32 A4 03 00 01 64 00']
default	13:31:21.740921 -0800	Runner	Task <FC4FFF5A-4D39-4BA8-8CB8-B2574FF135E0>.<1> received response, status 200 content K
default	13:31:21.742924 -0800	Runner	Task <FC4FFF5A-4D39-4BA8-8CB8-B2574FF135E0>.<1> response ended
default	13:31:21.763619 -0800	securityd	inserted <genp,rowid=42143,cdat=2018-11-30 21:31:21 +0000,mdat=2018-11-30 21:31:21 +0000,desc=null,icmt=null,crtr=null,type=null,scrp=null,labl=null,alis=null,invi=null,nega=null,cusi=null,prot=null,acct=io.afero.Tokui.dev,svce=689246215206:*,gena=com.google.iid-tokens,data=0a7e:070000000A8C0A0A...|ccde0e4c27f519ad,agrp=YVKN778Q2B.io.afero.Tokui.dev,pdmn=dku,sync=0,tomb=0,sha1=5173180304A9F340D5B542410E826704365C68B8,vwht=null,tkid=null,v_Data=<?>,v_pk=978C4BB76584653212C82AE3301FB57A621EC8E7,accc=null,u_Tomb=null,musr=,UUID=8D6E173C-3B6A-4E76-99E1-0E013528573E,sysb=null,pcss=null,pcsk=null,pcsi=null,persistref=>
default	13:31:21.764867 -0800	securityd	TWHsSlhR5gt2wnqGEEYEnm4gGe: will-commit api 1 changes, txn=<SecDbConnection rw open>, 0x1014b8430
default	13:31:22.019299 -0800	lockdownd	handle_get_value: <private>
default	13:31:22.021024 -0800	lockdownd	handle_get_value: <private>
default	13:31:22.041183 -0800	lockdownd	handle_get_value: <private>
default	13:31:22.042944 -0800	lockdownd	handle_get_value: <private>
default	13:31:22.595793 -0800	nsurlsessiond	Triggering periodic update to powerlog for client <private>
default	13:31:23.395094 -0800	Runner	XPC connection invalidated (daemon unloaded or disabled)
default	13:31:23.428400 -0800	Runner	client.trigger:#N CCFG for cid 0x35 has # of profiles: 2
default	13:31:23.431471 -0800	Runner	client.trigger:#N Random sample for 0x350002 is skip
default	13:31:23.434719 -0800	Runner	client.trigger:#N Random sample for 0x350002 is skip

Then nothing else from the runner.
I can not parse this so it is difficult to debug. I suspect it might have something to do with firebase messaging

tvolkert

tvolkert commented on Nov 30, 2018

@tvolkert
Contributor

@marnberg yeah that looks like a different issue

tvolkert

tvolkert commented on Dec 1, 2018

@tvolkert
Contributor

@collinjackson or @dnfield, I'm not familiar with Cocoapods. Do you know where/how the install_framework lines are getting expanded in #24641 (comment)?

30 remaining items

jmagman

jmagman commented on Dec 11, 2019

@jmagman
Member

@MisterJimson
Did you regenerate your Podfile?
#24641 (comment)

yxwandroid

yxwandroid commented on Dec 12, 2019

@yxwandroid

image
image

jmagman

jmagman commented on Dec 12, 2019

@jmagman
Member

Please follow the instructions in the error message and run rm ios/Podfile before commenting in this issue.
#24641 (comment)

ArunYogeshwaran

ArunYogeshwaran commented on Jan 20, 2020

@ArunYogeshwaran

image

xster

xster commented on Mar 11, 2020

@xster
Member

I'm locking this thread down since the error message specifically points out the resolution steps

locked as resolved and limited conversation to collaborators on Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolecustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-iosiOS applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @xster@zoechi@jmagman@jkira@marnberg

      Issue actions

        Release iOS build: VM snapshot must be valid · Issue #24641 · flutter/flutter