Poor rendering performance of 20% CPU for trivial animation due to per-frame overhead on Mac
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
Create trivial project, put a CircularProgressIndicator hooked up to a button, observe cpu usage for app using top/task manager, press button, observe cpu usage.
This was done on a MBP M2 Max 12core w/ 120Hz display
### Expected results
Very low cpu usage when spinning.
### Actual results
Observe very low (<2%) cpu usage with spinner not spinning. Push button to start spinner, observe anywhere from 17% to 25% CPU (depending on building for Impeller, Skia, with performance monitoring, without (all builds Release build except for Perf tooling).
### Code sample
Code sample
```dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const SpinnerPage(),
);
}
}
class SpinnerPage extends StatefulWidget {
const SpinnerPage({super.key});
@override
State createState() => _SpinnerPageState();
}
class _SpinnerPageState extends State {
bool _spinning = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 48,
width: 48,
child: _spinning ? const CircularProgressIndicator() : null,
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () => setState(() => _spinning = !_spinning),
child: Text(_spinning ? 'Stop' : 'Start'),
),
],
),
),
);
}
}
```
### Screenshots or Video
_No response_
### Logs
_No response_
### Flutter Doctor output
Doctor output
```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.41.2, on macOS 26.2 25C56 darwin-arm64, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.2)
[✓] Chrome - develop for the web
[✓] Connected device (3 available)
.. snip network devices...
[✓] Network resources
• No issues found!
```
Contributor guide
Assessment
This issue has not been assessed yet.