aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 247 forks source link

iOS Crash after sign in #4092

Closed adplant closed 10 months ago

adplant commented 11 months ago

Description

packages.txt ios_crash_report_after_sign_in.txt

I've attached the packages I used and the crash report from TESTFLIGHT.

Basically, when I download and open up the app via testflight, things work for the sign in page, but a few seconds after I sign in the app crashes.

IMPORTANT NOTES:

Categories

Steps to Reproduce

  1. open app from testflight
  2. sign in
  3. wait a few seconds and then the app crashes

iOS only! Android works fine.

Screenshots

No response

Platforms

Flutter Version

3.13.9

Amplify Flutter Version

1.6.0

Deployment Method

Amplify CLI

Schema

No response

Jordan-Nelson commented 11 months ago

Hello @adplant - I think this may be the result of a bug in the Flutter SDK that was recently resolved in Flutter's beta channel. See: https://github.com/flutter/flutter/issues/134548. Would you be willing to upgrade to Flutter beta and see if this is still reproducible?

adplant commented 11 months ago

@Jordan-Nelson Yeah I'll try it out

adplant commented 11 months ago

@Jordan-Nelson Switching to the latest beta channel did NOT work.

Also, of note, my whole app seemed to be in dark mode (not sure if that's what's supposed to happen or not).

Jordan-Nelson commented 11 months ago

Hm okay.

You mentioned that the crash happens a few seconds after sign in. Is there code that your app would be running after sign in?

Does it crash every time after login?

Are you seeing this on all devices?

adplant commented 11 months ago

@Jordan-Nelson Yes. Code runs after the sign in. It's hard to know exactly what's running because, like I mentioned, when I build in release mode locally it works so I don't see where it fails.

I'll look at the code and try to find out what should be running. I'll let you know soon.

As for devices... Yes, it's in multiple iPhones. But strictly iPhones. Android build works great.

Jordan-Nelson commented 11 months ago

There is a reference to this file from Amplify Swift in the crash report, which is interesting. The Datastore category within Amplify Flutter depends on Amplify Swift, but if you are not using Datastore, Amplify Swift should not be used.

I have a few follow up questions:

adplant commented 11 months ago

@Jordan-Nelson

I'm using Datastore, GraphQl API, and Auth as plugins AmplifyAPI(), AmplifyDataStore(), AmplifyAuthCognito().

I'm using Amplify Flutter 1.6.0 (My pubspec.lock says so, but I can't actually see the version from the codemagic output. It does the same flutter pub get with the pubspec.yaml stating amplify_flutter: ^1.0.0 and the output in codmagic just shows what I listed in the packages.txt file in the description of this ticket.)

I am NOT using Amplify Swift directly.

adplant commented 11 months ago

@Jordan-Nelson Here is the console log of what it should look like directly after a successful login and up to where the user would be ready to use the app.

iOS build and run ios_post_login_log.txt

Android build and run, but the same calls are happening. Post_loggin_log.txt

adplant commented 11 months ago

@Jordan-Nelson I just updated the last comment to provide both ios and android logs of what SHOULD be happening. They were produced from local builds.

Jordan-Nelson commented 11 months ago

From the crash log it seems like datastore is attempting to start multiple times. What datastore operations do you invoke after sign in? Can you share the relevant code that is invoked after sign in?

adplant commented 11 months ago

@Jordan-Nelson I'll try to get that together for you sometime today. And I could see that being true.

But why would this all of a sudden start crashing the app? It's been this way for over a year.

Jordan-Nelson commented 11 months ago

@adplant - were previous builds working even through Code Magic? If so, did you recently make any changes or upgrade flutter and/or amplify?

adplant commented 11 months ago

@Jordan-Nelson Yes. All builds worked fine through codemagic and then, yes, I upgraded flutter and packages.

Jordan-Nelson commented 11 months ago

Do you know what version of Flutter and Amplify Flutter you were previously using?

adplant commented 11 months ago

@Jordan-Nelson Flutter Version was 3.7.11 (because we'd noticed a bug causing issues, so we'd stayed on this for a while) Amplify Flutter Version: We've just had the pubspec.yaml file say amplify_flutter: ^1.0.0 for about 3 months, so we just keep getting the newest version, so it wasn't an issue with that.

Jordan-Nelson commented 11 months ago

Okay. Can you see if this issue is reproducible with the older version of flutter?

adplant commented 11 months ago

@Jordan-Nelson you want me to maintain the same pubspec.yaml file when I do that?

Should I use that same flutter version I had it last work with, or just any previous version?

adplant commented 11 months ago

@Jordan-Nelson I can't go back to Flutter 3.7.11 without also implementing older versions for a bunch of the packages (amplify packages included). Mainly due to the Dart Version being < 3.0.0.

Jordan-Nelson commented 11 months ago

Okay. Yes, Amplify Flutter v1.0.x was the last version to support an earlier version of dart. So it seems like everything was working with Amplify Flutter 1.0.x and Flutter 3.7.11 and is no longer working with Amplify Flutter 1.6.0 and Flutter 3.13.9.

We can see if anything that changed in Amplify could be the cause. If you are able to try to reproduce this with Amplify Flutter 1.1.0 (which was the first version to support dart 3.0) that might narrow it down.

adplant commented 11 months ago

@Jordan-Nelson Yeah, I'll try it out right now and report back.

adplant commented 11 months ago

@Jordan-Nelson Are you suggesting that I use the Stable Flutter version (3.13.9) while doing this?

adplant commented 11 months ago

@Jordan-Nelson Ok, here's what I did. I am using the current Flutter version (3.13.9) and I changed the amplify_flutter package to 1.1.0. I also had to downgrade my connectivity_plus package b/c of conflicts.

Here's my pubspec.yaml:

environment:
  sdk: ">=2.17.6 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  amplify_api: ^1.0.0
  amplify_auth_cognito: ^1.0.0
  amplify_authenticator: ^1.0.0
  amplify_datastore: ^1.0.0-supports-only-mobile.0
  amplify_flutter: 1.1.0 #^1.0.0
  animated_text_kit: ^4.2.2
  connectivity_plus: null #^5.0.1
  cupertino_icons: ^1.0.2
  flutter:
    sdk: flutter
  flutter_native_timezone: null
  flutter_riverpod: ^2.1.3
  fluttertoast: ^8.0.9
  geolocator: ^10.1.0
  intl: null
  jwt_decode: ^0.3.1
  mobile_scanner: ^3.5.1
  nfc_manager: ^3.2.0
  package_info_plus: ^4.2.0
  protobuf: null
  shared_preferences: ^2.0.17

Here's my pubspec.lock: pubspec.lock_amplify_flutter1.0_connectivity_plus3.0.6.txt

It failed again.

Here is the crash log: crash_log_flutter3.13.9_amplify_flutter1.0.0_connectivity_plus3.0.6.txt

adplant commented 11 months ago

@Jordan-Nelson Just to re-iterate, this is a pretty bad bug for us, as we're not able to push any updates to iOS.

adplant commented 11 months ago

@Equartey @Jordan-Nelson Any input?

atierian commented 11 months ago

Hey @adplant, thanks for all of the information so far.

I work on the Amplify iOS v1 library (where this crash is happening) and I have a few follow up questions. I may be missing some Flutter specific nuance in these questions, so @Equartey and/or @Jordan-Nelson can chime in to help translate anything that doesn't make sense.

The crash report has been helpful. To help us narrow this down further, can you please do the following:

One other question, can you confirm that the build you pushed to TestFlight was built with release configuration? This is the default when archiving an app. You can check in Xcode > <app-scheme> > Archive > Build configuration

If you have any questions about these requests, please let us know. And thanks for your patience here -- the logs and atos output should help us get to the bottom of this quickly.

adplant commented 11 months ago

@atierian I'll try to get you some of this info today sometime. However, I think there will be issues with your first request b/c it doesn't fail when I build it locally (in debug or release mode). It only seems to fail when built via codemagic and distributed via testflight.

adplant commented 11 months ago

@Jordan-Nelson @atierian @Equartey Looks like I've found the problem. It's the new version of xcode. It was working when I would build in release mode locally b/c I was using xcode 14.3.1. My codemagic.yaml file says to always grab the latest stable version of xcode, which changed a couple months back to 15.0.0, and then a month ago to 15.0.1. I know for sure that the latter breaks it. I'll do a build with 15.0.0 just to see if that breaks, too. But when using 14.3.1 it works just fine.

atierian commented 11 months ago

However, I think there will be issues with your first request b/c it doesn't fail when I build it locally (in debug or release mode). It only seems to fail when built via codemagic and distributed via testflight.

The logging system in Amplify iOS v1 uses os_log, so if you connect your iPhone to your Mac, you will be able to see logs generated in Console.app. This also applies for builds distributed via TestFlight, and enabling verbose logging should give us some more information here.


The insight about the Xcode version is interesting; thanks for finding and sharing that! A new linker was introduced in Xcode 15 (ld-prime), but I'm struggling to see how that could be connected. I'm looking forward to hearing whether this also happens with Xcode 15.0.0

Could you capture the build logs when archiving with Xcode 14.3.1 and Xcode 15.0.1 (or 15.0.0 if it also results in the crash), and share them here?

adplant commented 11 months ago

@atierian I wasn't able to get codemagic to build using 15.0.0, so couldn't verify. I'm also not sure I want to install 15.0.1 locally at the moment (if I do, I'll let you know).

I can try to do it via codemagic. Do you have any instructions as to how to do it?

FYI, this might take a day or so. This whole this has set me back, so I'm in catch up mode at the moment.

atierian commented 10 months ago

I'm not familiar enough with codemagic to help directly; I recommend reaching out to their support team for assistance on that.

Any luck getting the verbose logs and output from the atos command?

NikaHsn commented 10 months ago

I'm closing this isse as it is related to upgrading to xcode 15 and may be related to flutter/flutter#136060