Skip to content

Title Widget calling setSystemChromeApplicationSwitcherDescription multiple times causing ANRs #176008

@kazbeksultanov

Description

@kazbeksultanov

Steps to reproduce

  1. Create a normal project using Material or Widget App
  2. Introduce state changes on the top of the App without changing the title
  3. The Title widget build method is executed again, triggering the switcher even when there's no change in the title and color

Expected results

Only trigger setSystemChromeApplicationSwitcherDescription once and only after title of color changes

Actual results

setSystemChromeApplicationSwitcherDescription is called multiple times without being needed. causing ANRs.

Detected ANRs Image
StackTrace
          main (native):tid=1 systid=28345 
#00 pc 0xe42c8 libc.so (__ioctl + 8) (BuildId: 899237b27ce70ad3ff85d806309243c0)
#01 pc 0x9d2dc libc.so (ioctl + 156) (BuildId: 899237b27ce70ad3ff85d806309243c0)
#02 pc 0x71eb0 libbinder.so (android::IPCThreadState::talkWithDriver + 280) (BuildId: 7d0e34af83340709fbee99659190ea9a)
#03 pc 0x733b0 libbinder.so (android::IPCThreadState::waitForResponse + 60) (BuildId: 7d0e34af83340709fbee99659190ea9a)
#04 pc 0x730d4 libbinder.so (android::IPCThreadState::transact + 300) (BuildId: 7d0e34af83340709fbee99659190ea9a)
#05 pc 0x8a5f0 libbinder.so (android::BpBinder::transact + 188) (BuildId: 7d0e34af83340709fbee99659190ea9a)
#06 pc 0x1d0e3c libandroid_runtime.so (android_os_BinderProxy_transact + 152) (BuildId: e205f2989297fb3ba5815631854ad9cc)
       at android.os.BinderProxy.transactNative(Native method)
       at android.os.BinderProxy.transact(BinderProxy.java:606)
       at android.app.IActivityClientController$Stub$Proxy.setTaskDescription(IActivityClientController.java:2108)
       at android.app.ActivityClient.setTaskDescription(ActivityClient.java:432)
       at android.app.Activity.setTaskDescription(Activity.java:7863)
       at io.flutter.plugin.platform.PlatformPlugin.setSystemChromeApplicationSwitcherDescription(PlatformPlugin.java:228)
       at io.flutter.plugin.platform.PlatformPlugin.access$200(PlatformPlugin.java:36)
       at io.flutter.plugin.platform.PlatformPlugin$1.setApplicationSwitcherDescription(PlatformPlugin.java:97)
       at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:87)
       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
       at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
       at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
       at android.os.Handler.handleCallback(Handler.java:996)
       at android.os.Handler.dispatchMessage(Handler.java:110)
       at android.os.Looper.loopOnce(Looper.java:210)
       at android.os.Looper.loop(Looper.java:302)
       at android.app.ActivityThread.main(ActivityThread.java:9675)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1062)

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'title',
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              TextButton(
                onPressed: () {
                  setState(() {});
                },
                child: const Text('Update State'),
              )
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.8, on macOS 15.6.1 24G90 darwin-arm64, locale en-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 16.2)
    ! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] Connected device (3 available)
    ! Error: Browsing on the local area network for Kazbek’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Labels

P2Important issues not at the top of the work listc: crashStack traces logged to the consoleframeworkflutter/packages/flutter repository. See also f: labels.needs repro infoAutomated crash report whose cause isn't yet knownr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions