Flutter Android consecutive app startups much slower than the first one

34 Views Asked by At

I am working on a sizeable Flutter project for mobile devices (geolocation, database, web communication, camera use), and I am experiencing a following issue: When the app is first installed (both debug and release versions have been tested for this), the launch screen appears for a magnitude of 2-3 seconds and the app starts. However, if the app is turned off or the phone is restarted, turning the app on again generates a wait time of around 50 seconds in the launch screen. This issue is present only on Android devices, the IOS version's loading time doesn't change.

Could it be caused by some libraries? Or incorrect implementation of the launch screen?

Here's my pubspec.yaml

name: flutter_app
description: A new Flutter application.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 4.369.010+4369010

environment:
  sdk: ">=2.17.0 <3.0.0"
  flutter: ">=3.10.0"

dependencies:
  flutter:
    sdk: flutter
  camera: ^0.10.5+2
  path_provider: ^2.0.15
  path: ^1.8.3
  flutter_riverpod: ^2.1.3  
  flutter_localizations:
    sdk: flutter
  #lifted to 0.18.0 for flutter_audit
  intl: ^0.18.0 

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.4
  sqflite: ^2.0.0+4
  #password: 1.0.0
  http: ^0.13.4
  http_parser: ^4.0.2
  #combos: ^1.2.0
  fluttertoast: ^8.0.4
  signature: ^5.3.0
  flutter_image_compress: ^1.1.0
  syncfusion_flutter_signaturepad: ^20.3.57
  #device_info: ^2.0.3
  #flutter_ip: ^0.2.0
  flutter_launcher_icons: ^0.11.0
  package_info_plus: ^4.0.1
  shared_preferences: ^2.0.15
  package_info_plus_web: ^2.0.0
  crypto: ^3.0.2
  # url_launcher: ^6.0.9
  detect_fake_location: ^1.0.1
  camera_android: ^0.10.8+3
  safe_device: ^1.1.4
  # geolocator: ^8.2.1
  geolocator: ^10.1.0
  permission_handler: ^11.0.1 
  # 10.4.3 
  device_info_plus: ^9.0.3
  image: ^3.3.0
  carousel_slider: ^4.2.1
  sensors: ^2.0.3
  vector_math: any
  motion_sensors: ^0.1.0
  google_mlkit_text_recognition: ^0.10.0
  url_launcher: '6.0.0'
  restart_app: ^1.2.1
  dart_ipify: ^1.1.1
  image_compression: ^1.0.3
  native_shutter_sound: ^0.0.1



flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: assets\images\launcher.png

dev_dependencies:
  flutter_lints: ^2.0.1
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pubpubspec

# The following section is specific to Flutter.
flutter:
  generate: true

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
  assets:
    - assets/logo.png
    - assets/config/
    - assets/images/
    - assets/demo/tmp_app4748.json
    - assets/demo/tmp_app4716.json
    - assets/demo/tmp_app4717.json
    - assets/demo/tmp_app4748eng.json

  fonts:
    - family: Montserrat
      fonts:
        - asset: fonts/Montserrat-Regular.ttf

This has been tested on 3 different Android phones, and not observed on an IOS one, so this is an Android-only issue, but I am not certain what to do next. Libraries seem to be the most likely to me as the cause -- maybe some of them are updating on second app start and that causes the problem? How to check for it? Have any of you faced similar startup problems before?

0

There are 0 best solutions below