Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e06650bd
Unverified
Commit
e06650bd
authored
Jul 17, 2023
by
Michael Goderbauer
Committed by
GitHub
Jul 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guard access to dart:developer with !kReleaseMode (#130627)
parent
7937b1d5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
32 deletions
+47
-32
binding.dart
packages/flutter/lib/src/foundation/binding.dart
+8
-4
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+18
-19
shader_warm_up.dart
packages/flutter/lib/src/painting/shader_warm_up.dart
+7
-3
binding.dart
packages/flutter/lib/src/scheduler/binding.dart
+7
-3
platform_channel.dart
packages/flutter/lib/src/services/platform_channel.dart
+7
-3
No files found.
packages/flutter/lib/src/foundation/binding.dart
View file @
e06650bd
...
...
@@ -158,9 +158,8 @@ abstract class BindingBase {
initServiceExtensions
();
assert
(
_debugServiceExtensionsRegistered
);
developer
.
postEvent
(
'Flutter.FrameworkInitialization'
,
<
String
,
String
>{});
if
(!
kReleaseMode
)
{
developer
.
postEvent
(
'Flutter.FrameworkInitialization'
,
<
String
,
String
>{});
FlutterTimeline
.
finishSync
();
}
}
...
...
@@ -657,14 +656,19 @@ abstract class BindingBase {
/// [locked].
@protected
Future
<
void
>
lockEvents
(
Future
<
void
>
Function
()
callback
)
{
final
developer
.
TimelineTask
timelineTask
=
developer
.
TimelineTask
()..
start
(
'Lock events'
);
developer
.
TimelineTask
?
debugTimelineTask
;
if
(!
kReleaseMode
)
{
debugTimelineTask
=
developer
.
TimelineTask
()..
start
(
'Lock events'
);
}
_lockCount
+=
1
;
final
Future
<
void
>
future
=
callback
();
future
.
whenComplete
(()
{
_lockCount
-=
1
;
if
(!
locked
)
{
timelineTask
.
finish
();
if
(!
kReleaseMode
)
{
debugTimelineTask
!.
finish
();
}
try
{
unlocked
();
}
catch
(
error
,
stack
)
{
...
...
packages/flutter/lib/src/painting/image_cache.dart
View file @
e06650bd
...
...
@@ -103,9 +103,9 @@ class ImageCache {
if
(
value
==
maximumSize
)
{
return
;
}
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.setMaximumSize'
,
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
);
...
...
@@ -114,10 +114,10 @@ class ImageCache {
if
(
maximumSize
==
0
)
{
clear
();
}
else
{
_checkCacheSize
(
t
imelineTask
);
_checkCacheSize
(
debugT
imelineTask
);
}
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
();
debugT
imelineTask
!.
finish
();
}
}
...
...
@@ -142,9 +142,9 @@ class ImageCache {
if
(
value
==
_maximumSizeBytes
)
{
return
;
}
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.setMaximumSizeBytes'
,
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
);
...
...
@@ -153,10 +153,10 @@ class ImageCache {
if
(
_maximumSizeBytes
==
0
)
{
clear
();
}
else
{
_checkCacheSize
(
t
imelineTask
);
_checkCacheSize
(
debugT
imelineTask
);
}
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
();
debugT
imelineTask
!.
finish
();
}
}
...
...
@@ -283,7 +283,6 @@ class ImageCache {
/// Resizes the cache as appropriate to maintain the constraints of
/// [maximumSize] and [maximumSizeBytes].
void
_touch
(
Object
key
,
_CachedImage
image
,
TimelineTask
?
timelineTask
)
{
assert
(
timelineTask
!=
null
);
if
(
image
.
sizeBytes
!=
null
&&
image
.
sizeBytes
!
<=
maximumSizeBytes
&&
maximumSize
>
0
)
{
_currentSizeBytes
+=
image
.
sizeBytes
!;
_cache
[
key
]
=
image
;
...
...
@@ -324,9 +323,9 @@ class ImageCache {
/// Images that are larger than [maximumSizeBytes] are not cached, and do not
/// cause other images in the cache to be evicted.
ImageStreamCompleter
?
putIfAbsent
(
Object
key
,
ImageStreamCompleter
Function
()
loader
,
{
ImageErrorListener
?
onError
})
{
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.putIfAbsent'
,
arguments:
<
String
,
dynamic
>{
'key'
:
key
.
toString
(),
...
...
@@ -337,7 +336,7 @@ class ImageCache {
// Nothing needs to be done because the image hasn't loaded yet.
if
(
result
!=
null
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'pending'
});
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'pending'
});
}
return
result
;
}
...
...
@@ -348,7 +347,7 @@ class ImageCache {
final
_CachedImage
?
image
=
_cache
.
remove
(
key
);
if
(
image
!=
null
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
}
// The image might have been keptAlive but had no listeners (so not live).
// Make sure the cache starts tracking it as live again.
...
...
@@ -369,10 +368,10 @@ class ImageCache {
liveImage
.
completer
,
sizeBytes:
liveImage
.
sizeBytes
,
),
t
imelineTask
,
debugT
imelineTask
,
);
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
}
return
liveImage
.
completer
;
}
...
...
@@ -382,7 +381,7 @@ class ImageCache {
_trackLiveImage
(
key
,
result
,
null
);
}
catch
(
error
,
stackTrace
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'error'
,
'error'
:
error
.
toString
(),
'stackTrace'
:
stackTrace
.
toString
(),
...
...
@@ -397,7 +396,7 @@ class ImageCache {
}
if
(!
kReleaseMode
)
{
t
imelineTask
!.
start
(
'listener'
);
debugT
imelineTask
!.
start
(
'listener'
);
}
// A multi-frame provider may call the listener more than once. We need do make
// sure that some cleanup works won't run multiple times, such as finishing the
...
...
@@ -424,7 +423,7 @@ class ImageCache {
// Only touch if the cache was enabled when resolve was initially called.
if
(
trackPendingImage
)
{
_touch
(
key
,
image
,
t
imelineTask
);
_touch
(
key
,
image
,
debugT
imelineTask
);
}
else
{
image
.
dispose
();
}
...
...
@@ -434,7 +433,7 @@ class ImageCache {
pendingImage
.
removeListener
();
}
if
(!
kReleaseMode
&&
!
listenedOnce
)
{
t
imelineTask
!
debugT
imelineTask
!
..
finish
(
arguments:
<
String
,
dynamic
>{
'syncCall'
:
syncCall
,
'sizeInBytes'
:
sizeBytes
,
...
...
packages/flutter/lib/src/painting/shader_warm_up.dart
View file @
e06650bd
...
...
@@ -88,14 +88,18 @@ abstract class ShaderWarmUp {
final
ui
.
Picture
picture
=
recorder
.
endRecording
();
assert
(
debugCaptureShaderWarmUpPicture
(
picture
));
if
(!
kIsWeb
||
isCanvasKit
)
{
// Picture.toImage is not yet implemented on the web.
final
TimelineTask
shaderWarmUpTask
=
TimelineTask
();
shaderWarmUpTask
.
start
(
'Warm-up shader'
);
TimelineTask
?
debugShaderWarmUpTask
;
if
(!
kReleaseMode
)
{
debugShaderWarmUpTask
=
TimelineTask
()..
start
(
'Warm-up shader'
);
}
try
{
final
ui
.
Image
image
=
await
picture
.
toImage
(
size
.
width
.
ceil
(),
size
.
height
.
ceil
());
assert
(
debugCaptureShaderWarmUpImage
(
image
));
image
.
dispose
();
}
finally
{
shaderWarmUpTask
.
finish
();
if
(!
kReleaseMode
)
{
debugShaderWarmUpTask
!.
finish
();
}
}
}
picture
.
dispose
();
...
...
packages/flutter/lib/src/scheduler/binding.dart
View file @
e06650bd
...
...
@@ -14,7 +14,6 @@ import 'debug.dart';
import
'priority.dart'
;
import
'service_extensions.dart'
;
export
'dart:developer'
show
Flow
;
export
'dart:ui'
show
AppLifecycleState
,
FrameTiming
,
TimingsCallback
;
export
'priority.dart'
show
Priority
;
...
...
@@ -940,7 +939,10 @@ mixin SchedulerBinding on BindingBase {
}
_warmUpFrame
=
true
;
final
TimelineTask
timelineTask
=
TimelineTask
()..
start
(
'Warm-up frame'
);
TimelineTask
?
debugTimelineTask
;
if
(!
kReleaseMode
)
{
debugTimelineTask
=
TimelineTask
()..
start
(
'Warm-up frame'
);
}
final
bool
hadScheduledFrame
=
_hasScheduledFrame
;
// We use timers here to ensure that microtasks flush in between.
Timer
.
run
(()
{
...
...
@@ -969,7 +971,9 @@ mixin SchedulerBinding on BindingBase {
// scheduled frame has finished.
lockEvents
(()
async
{
await
endOfFrame
;
timelineTask
.
finish
();
if
(!
kReleaseMode
)
{
debugTimelineTask
!.
finish
();
}
});
}
...
...
packages/flutter/lib/src/services/platform_channel.dart
View file @
e06650bd
...
...
@@ -39,14 +39,18 @@ class _ProfiledBinaryMessenger implements BinaryMessenger {
}
Future
<
ByteData
?>?
sendWithPostfix
(
String
channel
,
String
postfix
,
ByteData
?
message
)
async
{
final
TimelineTask
task
=
TimelineTask
();
_debugRecordUpStream
(
channelTypeName
,
'
$channel$postfix
'
,
codecTypeName
,
message
);
task
.
start
(
'Platform Channel send
$channel$postfix
'
);
TimelineTask
?
debugTimelineTask
;
if
(!
kReleaseMode
)
{
debugTimelineTask
=
TimelineTask
()..
start
(
'Platform Channel send
$channel$postfix
'
);
}
final
ByteData
?
result
;
try
{
result
=
await
proxy
.
send
(
channel
,
message
);
}
finally
{
task
.
finish
();
if
(!
kReleaseMode
)
{
debugTimelineTask
!.
finish
();
}
}
_debugRecordDownStream
(
channelTypeName
,
'
$channel$postfix
'
,
codecTypeName
,
result
);
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment