shorebird icon indicating copy to clipboard operation
shorebird copied to clipboard

fix: iOS Patch Startup Lag Despite No Native / Asset / Pubspec Changes

Open tushar-chadha opened this issue 2 months ago • 3 comments

App ID: a7e02bcf-28c1-4b6d-8ba8-f7f4bce271c7 Release: 1.5.26+1 Patch: Patch 2 (iOS)

Description

We’re running into a problem on iOS where the app startup becomes noticeably slower on all iPhones running iOS 17 and later after applying the Shorebird patch, even though:

✅ No native iOS code changed ✅ No iOS assets changed ✅ No package or plugin versions changed ✅ No pubspec.yaml changes ✅ Only pure Dart code changes were included (following Shorebird’s patching guidelines exactly)

Despite this, the patched build lags on cold startup across multiple physical devices.

To validate this, we also tested by patching from the exact same base commit with only Dart edits, and the issue still appears.

Expected Behavior

Since the patch contains Dart-only changes, the app should launch exactly as fast as the previous build, with no regression in startup performance.

Actual Behavior

On iOS 17+ devices (iPhone 12 and newer in our tests), the app takes noticeably longer to launch after applying the patch — even though the underlying Xcode archive remained unchanged.

Steps To Reproduce

  1. Take the current release archive (1.5.26+1)
  2. Apply a Dart-only patch using Shorebird
  3. Publish the patch
  4. Install the app on any device with iOS 17+
  5. Observe slower startup vs. unpatched version

Additional Context

We rely heavily on startup animations, so the lag is very visible.

The unpatched App Store build launches instantly; the patched version consistently takes longer.

Patch validation and size look normal — nothing abnormal in the diff.

Full Shorebird CLI Logs

rental@Tushars-Macbook mobile % shorebird patch ios  --target lib/main.dart --flavor production
✓ Fetching apps (1.0s)
✓ Fetching releases (0.5s)
Which release would you like to patch? 1.5.26+1
✓ Fetching xcarchive artifact (0.4s)
✓ Fetching ios_supplement artifact (0.5s)
✓ Downloading xcarchive (100%) (28.1s)
✓ Downloading ios_supplement (100%) (2.4s)
Building patch with Flutter 3.29.2 (b14323b05f)
Resolving dependencies... 
Downloading packages... 
  _fe_analyzer_shared 85.0.0 (92.0.0 available)
  _flutterfire_internals 1.3.59 (1.3.64 available)
  analyzer 7.7.1 (9.0.0 available)
  animate_do 3.3.9 (4.2.0 available)
  async 2.12.0 (2.13.0 available)
  bloc 8.1.4 (9.1.0 available)
  build 2.4.2 (4.0.2 available)
  camera 0.10.6 (0.11.3 available)
  camera_android 0.10.10+6 (0.10.10+11 available)
  camera_avfoundation 0.9.21+2 (0.9.22+4 available)
  camera_platform_interface 2.11.0 (2.12.0 available)
  characters 1.4.0 (1.4.1 available)
  checked_yaml 2.0.3 (2.0.4 available)
  connectivity_plus 6.1.5 (7.0.0 available)
  crypto 3.0.6 (3.0.7 available)
  dart_pubspec_licenses 3.0.4 (3.0.14 available)
  dart_style 3.1.1 (3.1.2 available)
  device_info_plus 10.1.2 (12.2.0 available)
  dotted_border 2.1.0 (3.1.0 available)
  emoji_picker_flutter 3.1.0 (4.3.0 available)
  envied 0.5.4+1 (1.3.1 available)
! extended_text_field 16.0.2 (overridden)
  fake_async 1.3.2 (1.3.3 available)
  fast_contacts 4.0.0 (5.0.1 available)
  ffmpeg_kit_flutter_new 3.2.0 (4.1.0 available)
  file_picker 8.3.7 (10.3.3 available)
  file_selector_macos 0.9.4+4 (0.9.4+5 available)
  firebase_analytics 11.6.0 (12.0.4 available)
  firebase_analytics_platform_interface 4.4.3 (5.0.4 available)
  firebase_analytics_web 0.5.10+16 (0.6.1 available)
  firebase_core 3.15.2 (4.2.1 available)
  firebase_core_web 2.24.1 (3.3.0 available)
  firebase_crashlytics 4.3.10 (5.0.4 available)
  firebase_crashlytics_platform_interface 3.8.10 (3.8.15 available)
  firebase_database 11.3.10 (12.0.4 available)
  firebase_database_platform_interface 0.2.6+10 (0.2.6+15 available)
  firebase_database_web 0.2.6+16 (0.2.7 available)
  firebase_messaging 15.2.10 (16.0.4 available)
  firebase_messaging_platform_interface 4.6.10 (4.7.4 available)
  firebase_messaging_web 3.10.10 (4.1.0 available)
  flutter_bloc 8.1.6 (9.1.1 available)
  flutter_hooks 0.18.6 (0.21.3+1 available)
  flutter_local_notifications 18.0.1 (19.5.0 available)
  flutter_local_notifications_linux 5.0.0 (6.0.0 available)
  flutter_local_notifications_platform_interface 8.0.0 (9.1.0 available)
  flutter_plugin_android_lifecycle 2.0.31 (2.0.32 available)
  flutter_riverpod 2.6.1 (3.0.3 available)
  flutter_sound_platform_interface 9.28.0 (10.3.8 available)
  flutter_sound_web 9.28.0 (10.3.8 available)
  flutter_svg 2.2.1 (2.2.2 available)
  fluttertoast 8.2.14 (9.0.0 available)
  googleapis 13.2.0 (15.0.0 available)
  googleapis_auth 1.6.0 (2.0.0 available)
  grpc 4.1.0 (4.3.1 available)
  image_picker_android 0.8.13+1 (0.8.13+7 available)
  image_picker_ios 0.8.13 (0.8.13+1 available)
  image_picker_macos 0.2.2 (0.2.2+1 available)
  infinite_scroll_pagination 4.1.0 (5.1.1 available)
! intl 0.20.2 (overridden)
! js 0.7.2 (overridden)
  json_serializable 6.9.5 (6.11.1 available)
  leak_tracker 10.0.8 (11.0.2 available)
  leak_tracker_flutter_testing 3.0.9 (3.0.10 available)
  leak_tracker_testing 3.0.1 (3.0.2 available)
  lints 5.1.1 (6.0.0 available)
  lottie 3.3.1 (3.3.2 available)
  material_color_utilities 0.11.1 (0.13.0 available)
  meta 1.16.0 (1.17.0 available)
  native_image_cropper 0.6.0 (0.7.0 available)
  native_image_cropper_ios 0.2.0 (0.3.0 available)
  objective_c 8.0.0 (8.1.0 available)
  package_info_plus 8.3.1 (9.0.0 available)
  path_provider_android 2.2.19 (2.2.20 available)
  path_provider_foundation 2.4.2 (2.4.3 available)
  pdfrx 1.3.5 (2.2.8 available)
  permission_handler 11.4.0 (12.0.1 available)
  permission_handler_android 12.1.0 (13.0.1 available)
  petitparser 6.1.0 (7.0.1 available)
  process 5.0.3 (5.0.5 available)
! protobuf 4.2.0 (overridden) (5.1.0 available)
  protoc_plugin 22.5.0 (24.0.0 available)
  riverpod 2.6.1 (3.0.3 available)
  sensors_plus 6.1.2 (7.0.0 available)
  sentry 9.7.0 (9.8.0 available)
  sentry_flutter 9.7.0 (9.8.0 available)
  share_plus 10.1.4 (12.0.1 available)
  share_plus_platform_interface 5.0.2 (6.1.0 available)
  shared_preferences_android 2.4.13 (2.4.15 available)
  shared_preferences_foundation 2.5.4 (2.5.5 available)
  smart_auth 2.0.0 (3.2.0 available)
  source_gen 2.0.0 (4.0.2 available)
  source_helper 1.3.7 (1.3.8 available)
  sqflite_android 2.4.1 (2.4.2+2 available)
  sqflite_common 2.5.5 (2.5.6 available)
  swipe_to_action 0.2.0 (0.3.0 available)
  synchronized 3.3.1 (3.4.0 available)
  test_api 0.7.4 (0.7.7 available)
  url_launcher_android 6.3.20 (6.3.24 available)
  url_launcher_ios 6.3.4 (6.3.5 available)
  url_launcher_macos 3.2.3 (3.2.4 available)
  uuid 4.5.1 (4.5.2 available)
  vector_math 2.1.4 (2.2.0 available)
  video_player_android 2.8.15 (2.8.17 available)
  video_player_avfoundation 2.8.4 (2.8.5 available)
  vm_service 14.3.1 (15.0.2 available)
  wakelock_plus 1.3.3 (1.4.0 available)
  webdriver 3.0.4 (3.1.0 available)
  win32 5.13.0 (5.15.0 available)
  win32_registry 1.1.5 (2.1.0 available)
  xml 6.5.0 (6.6.1 available)
Got dependencies!
107 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Archiving com.misfitso28.mobile...
Automatically signing iOS for device deployment using specified development team in Xcode project:
H2FXH266QT
Running pod install...                                              6.9s
Running Xcode build...                                                  
 └─Compiling, linking and signing...                        15.7s
Xcode archive done.                                         190.3s
✓ Built build/ios/archive/Runner.xcarchive (441.1MB)
[✓] App Settings Validation
    • Version Number: 1.5.26
    • Build Number: 1
    • Display Name: Misfits
    • Deployment Target: 13.0
    • Bundle Identifier: com.misfitso28.mobile
To update the settings, please refer to https://flutter.dev/to/ios-deploy
Building App Store IPA...                                         123.7s
✓ Built IPA to build/ios/ipa (104.4MB)
To upload to the App Store either:
    1. Drag and drop the "build/ios/ipa/*.ipa" bundle into the Apple Transporter macOS app
    https://apps.apple.com/us/app/transporter/id1450874784
    2. Run "xcrun altool --upload-app --type ios -f build/ios/ipa/*.ipa --apiKey your_api_key --apiIssuer
    your_issuer_id".
       See "man altool" for details about how to authenticate with the App Store Connect API key.
✓ Verifying patch can be applied to release (1.5s)
✓ Extracting release artifact (1.2s)
✓ Linking AOT files (174.0s)
✓ Generating patch diff base (0.6s)
🚀 Ready to publish a new patch!
📱 App: misfits (production-2.0) (a7e02bcf-28c1-4b6d-8ba8-f7f4bce271c7)
🍧 Flavor: production
📦 Release Version: 1.5.26+1
🕹️  Platform: iOS [arm64 (5.81 MB)]
🟢 Track: Stable
Would you like to continue? (y/N) Yes
✓ Creating patch (0.7s)
✓ Uploading artifacts (4.9s)
✓ Fetching channels (0.4s)
✓ Promoting patch to stable (1.2s)
✅ Published Patch 2!

tushar-chadha avatar Nov 11 '25 00:11 tushar-chadha

That's definitely unexpected. Looking at the patch metadata for the latest patch on that app, I don't see anything that would suggest the patch should be slow.

{
 "release_platform": "ios",
 "used_ignore_asset_changes_flag": false,
 "has_asset_changes": false,
 "used_ignore_native_changes_flag": false,
 "has_native_changes": true,
 "inferred_release_version": false,
 "link_percentage": 97.174178476598,
 "link_metadata": null,
 "environment": {
  "flutter_revision": "b14323b05f28b2c72b34f57c8059ec3001d65712",
  "shorebird_version": "1.6.57",
  "operating_system": "macos",
  "operating_system_version": "Version 26.0 (Build 25A354)",
  "shorebird_yaml": {
   "app_id": "a7e02bcf-28c1-4b6d-8ba8-f7f4bce271c7",
   "flavors": {
    "production": "a7e02bcf-28c1-4b6d-8ba8-f7f4bce271c7"
   },
   "base_url": null,
   "auto_update": null
  },
  "xcode_version": "Xcode 16.4 Build version 16F6"
 }
}

is this a very large application?

eseidel avatar Nov 12 '25 18:11 eseidel

To answer my own question, the app is only 4mb, which isn't super large.

However I now notice "has_native_changes": true, in that patch metadata, which could be causing all sorts of issues (but not typically slowdown during launch).

Are you using patch-signing by chance? https://docs.shorebird.dev/code-push/guides/patch-signing/ (we don't seem to record a yes/no in the metadata for patch signing, but probably should.)

eseidel avatar Nov 12 '25 18:11 eseidel

https://github.com/shorebirdtech/updater/issues/301 is an issue about potential speedups we can make to signed builds.

eseidel avatar Nov 18 '25 21:11 eseidel