Skip to content

Can't end BackgroundTask on iOS when launch other application. #41095

@wrl96

Description

@wrl96

Details

Xcode outputs "Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug." when launch other apps.

Code

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage();
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('UIApplicationEndBackgroundTaskError'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async => await launch('sms:1111111'), // The error will be occured after pressed.
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Logs

Xcode outputs:

2019-09-23 19:56:29.683983+0800 Runner[35877:35419171] flutter: Observatory listening on http://127.0.0.1:54688/jUqXY95Znm4=/
2019-09-23 19:56:29.891716+0800 Runner[35877:35419154] flutter: Overflow on channel: flutter/lifecycle.  Messages on this channel are being discarded in FIFO fashion.  The engine may not be running or you need to adjust the buffer size if of the channel.
2019-09-23 19:56:36.772622+0800 Runner[35877:35418906] Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

flutter doctor -v:

[✓] Flutter (Channel master, v1.10.6-pre.29, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
    • Flutter version 1.10.6-pre.29 at /Users/*/Documents/flutter
    • Framework revision 919cc97f6a (3 days ago), 2019-09-20 14:57:05 -0700
    • Engine revision 99092a0436
    • Dart version 2.6.0 (build 2.6.0-dev.0.0 7c1821c4aa)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/*/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.0, Build version 11A420a
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
    • iPhone       • **** • ios • iOS 13.0
    • iPhone 11 Pro Max • 4D1EE296-9A86-4315-B910-7C2D1EE25493     • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-0 (simulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer: crowdAffects or could affect many people, though not necessarily a specific customer.p: url_launcherPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.platform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions