Visitar URL original
debugProfilePlatformChannels in release mode · flutter/flutter@8dd6d32 · GitHub
Skip to content

Commit 8dd6d32

Browse files
committed
debugProfilePlatformChannels in release mode
1 parent b03f533 commit 8dd6d32

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎packages/flutter/lib/src/services/debug.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ KeyDataTransitMode? debugKeyEventSimulatorTransitModeOverride;
2525
/// The statistics include the total bytes transmitted and the average number of
2626
/// bytes per invocation in the last quantum. "Up" means in the direction of
2727
/// Flutter to the host platform, "down" is the host platform to flutter.
28+
///
29+
/// Contrary to other debugging toggles in this package, this will function even
30+
/// when [kReleaseMode] is true.
2831
bool debugProfilePlatformChannels = false;
2932

3033
/// Setting to true will cause extensive logging to occur when key events are

‎packages/flutter/lib/src/services/platform_channel.dart‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ class _ProfiledBinaryMessenger implements BinaryMessenger {
4040

4141
Future<ByteData?>? sendWithPostfix(String channel, String postfix, ByteData? message) async {
4242
_debugRecordUpStream(channelTypeName, '$channel$postfix', codecTypeName, message);
43-
TimelineTask? debugTimelineTask;
44-
if (!kReleaseMode) {
45-
debugTimelineTask = TimelineTask()..start('Platform Channel send $channel$postfix');
46-
}
43+
final TimelineTask timelineTask = TimelineTask()..start('Platform Channel send $channel$postfix');
4744
final ByteData? result;
4845
try {
4946
result = await proxy.send(channel, message);
5047
} finally {
51-
if (!kReleaseMode) {
52-
debugTimelineTask!.finish();
53-
}
48+
timelineTask.finish();
5449
}
5550
_debugRecordDownStream(channelTypeName, '$channel$postfix', codecTypeName, result);
5651
return result;
@@ -183,7 +178,7 @@ class BasicMessageChannel<T> {
183178
/// [BackgroundIsolateBinaryMessenger.ensureInitialized].
184179
BinaryMessenger get binaryMessenger {
185180
final BinaryMessenger result = _binaryMessenger ?? _findBinaryMessenger();
186-
return !kReleaseMode && debugProfilePlatformChannels
181+
return debugProfilePlatformChannels
187182
? _debugBinaryMessengers[this] ??= _ProfiledBinaryMessenger(
188183
// ignore: no_runtimetype_tostring
189184
result, runtimeType.toString(), codec.runtimeType.toString())
@@ -272,7 +267,7 @@ class MethodChannel {
272267
/// [BackgroundIsolateBinaryMessenger.ensureInitialized].
273268
BinaryMessenger get binaryMessenger {
274269
final BinaryMessenger result = _binaryMessenger ?? _findBinaryMessenger();
275-
return !kReleaseMode && debugProfilePlatformChannels
270+
return debugProfilePlatformChannels
276271
? _debugBinaryMessengers[this] ??= _ProfiledBinaryMessenger(
277272
// ignore: no_runtimetype_tostring
278273
result, runtimeType.toString(), codec.runtimeType.toString())
@@ -303,7 +298,7 @@ class MethodChannel {
303298
Future<T?> _invokeMethod<T>(String method, { required bool missingOk, dynamic arguments }) async {
304299
final ByteData input = codec.encodeMethodCall(MethodCall(method, arguments));
305300
final ByteData? result =
306-
!kReleaseMode && debugProfilePlatformChannels ?
301+
debugProfilePlatformChannels ?
307302
await (binaryMessenger as _ProfiledBinaryMessenger).sendWithPostfix(name, '#$method', input) :
308303
await binaryMessenger.send(name, input);
309304
if (result == null) {

0 commit comments

Comments
 (0)