Skip to content

Transactions are very slow to complete when started inside appRunner, block the UI from showing up #2233

@maBarabas

Description

@maBarabas

Platform

Flutter Mobile

Obfuscation

Disabled

Debug Info

Disabled

Doctor

`flutter doctor -v`
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.6 23G80 darwin-arm64, locale en-GB)
    • Flutter version 3.22.3 on channel stable at /Users/barabas/src/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (4 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/barabas/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/barabas/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] Connected device (4 available)
    • Pixel 5 (mobile)                • 0C221FDD4003LH            • android-arm64 • Android 13 (API 33)
    • iPhone XR (mobile)              • 00008020-001E2C881A33002E • ios           • iOS 16.5.1 20F75
    • macOS (desktop)                 • macos                     • darwin-arm64  • macOS 14.6 23G80 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin        • macOS 14.6 23G80 darwin-arm64

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Version

8.7.0

Steps to Reproduce

Run this app on iOS or android in profile mode (using a real DSN):

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options
        ..dsn =
            '<snip>'
        ..tracesSampleRate = 1.0;
    },
    appRunner: appMain,
  );
}

Future<void> appMain() async {
  final transaction = Sentry.startTransaction('hello', 'hello');
  await transaction.finish();

  runApp(MyApp());
}

Expected Result

App UI appears almost instantly after app is launched.

Actual Result

The UI appears after about 10s.

Rerun without the tracesSamplerate or without the dsn or without the transaction or with Sentry before and notice that the UI appears in less than a second. Removing just one of these is enough to avoid the bug.

I bisected on android and the first slow commit is 5e7abc5, where the app UI never appears.

Are you willing to submit a PR?

No

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions