Skip to content

Stacktraceless crash with “Lost connection to device” when using Lottie and blur effect on iOS #139796

@Cyp

Description

@Cyp

Is there an existing issue for this?

Steps to reproduce

  1. Run testcase on iOS. — Or run any app with a Lottie widget and a blur effect on an iPhone 8 or similar. Blur effect might not be needed, but seems to be the easiest way of making a reproducible crash. Happens with at least Flutter 3.16.2 and Flutter 3.13.9.
  2. Press the “Crash” button.
  3. Wait a few minutes (sometimes 2 minutes, sometimes over 10 minutes, but ran once for 10½ hours without crashing) if XCode version 15.0.1. Or just wait a few seconds if XCode version 14.3.1.

Expected results

Crash button shouldn't crash. Or should at least give some kind of stack trace. Think Lottie is a pure dart library, and shouldn't be able to trigger a mystery crash like this.

Actual results

App randomly closes/crashes (on iOS only), “Lost connection to device” or “Lost connection to the debugger on “iPhone (8)”.” or similar.

Have seen a crash after a couple of minutes, but ran once for over 10½ hours without crashing. Was crashing more reliably before updating from XCode 14.3.1 to XCode 15.0.1.

Have seen crashes in both debug mode and release mode, but have only tested in debug mode since creating flutter create-ing a new standalone crash test app.

Possibly related to #130478.

Code sample

Code sample

Dependencies:

  lottie: ^2.7.0

Assets — any lottie json will probably do, but taken randomly from https://raw.githubusercontent.com/spemer/lottie-animations-json/master/floating_action_button/ic_fab_animate.json:

  assets:
    - assets/ic_fab_animate.json
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

class CrashWidget extends StatefulWidget {
  const CrashWidget({super.key});

  @override
  State<StatefulWidget> createState() => _CrashWidgetState();
}

class _CrashWidgetState extends State<CrashWidget> with SingleTickerProviderStateMixin {
  var crash = false;
  late final AnimationController _animationController;

  @override
  void initState() {
    super.initState();
    _animationController = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(children: [
      Positioned(
        left: 30,
        top: 30,
        child: ElevatedButton(
          onPressed: () => setState(() {
            crash = true;
          }),
          child: const Text('Crash'),
        ),
      ),
      // Not sure, but a second Lottie widget seems to help a bit with crashing faster.
      if (crash)
        Positioned(
          left: 10,
          right: 0,
          top: 0,
          bottom: 0,
          child: Lottie.asset(
            'assets/ic_fab_animate.json',
            options: LottieOptions(enableMergePaths: true),
            repeat: true,
            height: 2000,
            controller: _animationController,
            onLoaded: (composition) {
              _animationController
                ..duration = composition.duration
                ..forward()
                ..repeat();
            },
          ),
        ),
      if (crash)
        BackdropFilter(
          filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
          child: Container(
            child: Lottie.asset(
              'assets/ic_fab_animate.json',
              options: LottieOptions(enableMergePaths: true),
              repeat: true,
              height: 2000,
              controller: _animationController,
              onLoaded: (composition) {
                _animationController
                  ..duration = composition.duration
                  ..forward()
                  ..repeat();
              },
            ),
          ),
        ),
    ]);
  }
}

void main() {
  runApp(const MaterialApp(home: CrashWidget()));
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.16.2, on macOS 13.6.1 22G313 darwin-x64, locale en-DK)
    ! Flutter version 3.16.2 on channel [user-branch] at /Users/cyp/git/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 9e1c857886 (8 days ago), 2023-11-30 11:51:18 -0600
    • Engine revision cf7a9d0800
    • Dart version 3.2.2
    • DevTools version 2.28.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/cyp/Library/Android/sdk
    • Platform android-34, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

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

[✗] 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 2022.3)
    • 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.6+0-17.0.6b829.9-10027231)

[✓] Connected device (2 available)
    • iPhone (8) (mobile) •                                          • ios        • iOS 15.8
    • macOS (desktop)     • macos                                    • darwin-x64 • macOS 13.6.1 darwin-x64

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

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.found in release: 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions