FG
📱 Mobile & Cross-PlatformGoogle

Observatory port timeout on iOS

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

I'm unable to debug a freshly created app on physical iOS devices when pubspec dependencies reach a certain size, because it causes the "waiting for observatory port" step to timeout after 30 seconds. Devices tested: iPhone 8 iPhone 12 iPhone 12 Pro iOS versions tested: 14.2 14.2.1 14.3 Xcode versions tested: 12.2 12.3 Tests run using MacOS Catalina 10.15.7 on a late 2019 MBP 16". Simply commenting out random pubspec dependencies from the below, cleaning and rebuilding allows debugging to attach - sometimes just barely, at the 28 second or 29 second mark. Here's a triggering pubspec: [code block]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Increase Observatory Timeout for iOS Debugging

Medium Risk

The 'waiting for observatory port' timeout occurs due to the large size of pubspec dependencies, which causes the app to take longer to initialize and bind the observatory port. The default timeout is set to 30 seconds, which is insufficient for larger apps, especially on physical devices with limited resources.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Modify Flutter Tool Timeout

    Increase the timeout duration for the observatory port by setting the environment variable 'FLUTTER_OBSERVATORY_PORT_TIMEOUT' to a higher value, such as 60 seconds.

    bash
    export FLUTTER_OBSERVATORY_PORT_TIMEOUT=60
  2. 2

    Clean Flutter Build

    Run the Flutter clean command to remove any old build artifacts that may be causing issues.

    bash
    flutter clean
  3. 3

    Rebuild the App

    Rebuild the app to ensure that all dependencies are correctly linked and the new timeout setting is applied.

    bash
    flutter run
  4. 4

    Monitor Debugging Process

    Observe the debugging process to ensure that the app attaches successfully within the new timeout period. If it still fails, consider further optimizing dependencies.

  5. 5

    Optimize Dependencies

    Review and optimize the pubspec dependencies to reduce the overall size of the app. Remove any unnecessary packages or replace heavy packages with lighter alternatives.

Validation

Confirm the fix worked by successfully attaching the debugger to the app within the new timeout period. If the debugger attaches without timing out, the issue is resolved. Additionally, check for any performance improvements in the app startup time.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

flutterdartmobilec:-regressionplatform-ioswaiting-for-customer-responsetool