Reset default UserTag at the time of the first flutter frame (#86516)
* Reset default UserTag at the time of the first flutter frame
This commit is contained in:
committed by
GitHub
parent
cd78190b0c
commit
33f4107cd1
@@ -859,6 +859,11 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
|
||||
firstFrameCallback = (List<FrameTiming> timings) {
|
||||
assert(sendFramesToEngine);
|
||||
if (!kReleaseMode) {
|
||||
// Change the current user tag back to the default tag. At this point,
|
||||
// the user tag should be set to "AppStartUp" (originally set in the
|
||||
// engine), so we need to change it back to the default tag to mark
|
||||
// the end of app start up for CPU profiles.
|
||||
developer.UserTag.defaultTag.makeCurrent();
|
||||
developer.Timeline.instantSync('Rasterized first useful frame');
|
||||
developer.postEvent('Flutter.FirstFrame', <String, dynamic>{});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('first frame callback sets the default UserTag', () {
|
||||
final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
expect(developer.getCurrentTag().label, equals('Default'));
|
||||
developer.UserTag('test tag').makeCurrent();
|
||||
expect(developer.getCurrentTag().label, equals('test tag'));
|
||||
|
||||
binding.drawFrame();
|
||||
// Simulates the engine again.
|
||||
binding.window.onReportTimings!(<FrameTiming>[]);
|
||||
|
||||
expect(developer.getCurrentTag().label, equals('Default'));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user