-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Closed
Copy link
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.
Description
Use case
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: "demo",
theme: CupertinoThemeData(),
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
backgroundColor: Colors.white70,
child: Padding(
padding: EdgeInsets.only(top: 100, left: 15, right: 15),
child: CupertinoTextField(
placeholder: "iOS-style text field",
),
),
);
}
}A simple Demo for TextField, the screenShot is as follows:

Proposal
Add Log in DiffContext::ComputeDamage https://github.com/flutter/engine/blob/main/flow/diff_context.cc#L70, we can see log as fellow:
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(94)] frame_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(93)] buffer_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(94)] frame_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(93)] buffer_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(94)] frame_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(93)] buffer_damage: width = 6 height = 48
E/flutter (17227): [ERROR:flutter/flow/diff_context.cc(94)] frame_damage: width = 0 height = 0
From the logs above we can see that sometimes the frame_damage is empty.
So, there is no difference between the current frame and the previous frame.
Then can we discard the subsequent processes of the current frame, such as layertree's preroll, layertree's paint, and so on?
When we discard the empty frame_damge, we can get the trace below:

(left is empty frame_damage, right is not.)
Can reduce 6 ms cpu time on my phone.
cedvdb
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.