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
Hide 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 {
...
@@ -158,9 +158,8 @@ abstract class BindingBase {
initServiceExtensions
();
initServiceExtensions
();
assert
(
_debugServiceExtensionsRegistered
);
assert
(
_debugServiceExtensionsRegistered
);
developer
.
postEvent
(
'Flutter.FrameworkInitialization'
,
<
String
,
String
>{});
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
developer
.
postEvent
(
'Flutter.FrameworkInitialization'
,
<
String
,
String
>{});
FlutterTimeline
.
finishSync
();
FlutterTimeline
.
finishSync
();
}
}
}
}
...
@@ -657,14 +656,19 @@ abstract class BindingBase {
...
@@ -657,14 +656,19 @@ abstract class BindingBase {
/// [locked].
/// [locked].
@protected
@protected
Future
<
void
>
lockEvents
(
Future
<
void
>
Function
()
callback
)
{
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
;
_lockCount
+=
1
;
final
Future
<
void
>
future
=
callback
();
final
Future
<
void
>
future
=
callback
();
future
.
whenComplete
(()
{
future
.
whenComplete
(()
{
_lockCount
-=
1
;
_lockCount
-=
1
;
if
(!
locked
)
{
if
(!
locked
)
{
timelineTask
.
finish
();
if
(!
kReleaseMode
)
{
debugTimelineTask
!.
finish
();
}
try
{
try
{
unlocked
();
unlocked
();
}
catch
(
error
,
stack
)
{
}
catch
(
error
,
stack
)
{
...
...
packages/flutter/lib/src/painting/image_cache.dart
View file @
e06650bd
...
@@ -103,9 +103,9 @@ class ImageCache {
...
@@ -103,9 +103,9 @@ class ImageCache {
if
(
value
==
maximumSize
)
{
if
(
value
==
maximumSize
)
{
return
;
return
;
}
}
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.setMaximumSize'
,
'ImageCache.setMaximumSize'
,
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
);
);
...
@@ -114,10 +114,10 @@ class ImageCache {
...
@@ -114,10 +114,10 @@ class ImageCache {
if
(
maximumSize
==
0
)
{
if
(
maximumSize
==
0
)
{
clear
();
clear
();
}
else
{
}
else
{
_checkCacheSize
(
t
imelineTask
);
_checkCacheSize
(
debugT
imelineTask
);
}
}
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
();
debugT
imelineTask
!.
finish
();
}
}
}
}
...
@@ -142,9 +142,9 @@ class ImageCache {
...
@@ -142,9 +142,9 @@ class ImageCache {
if
(
value
==
_maximumSizeBytes
)
{
if
(
value
==
_maximumSizeBytes
)
{
return
;
return
;
}
}
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.setMaximumSizeBytes'
,
'ImageCache.setMaximumSizeBytes'
,
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
arguments:
<
String
,
dynamic
>{
'value'
:
value
},
);
);
...
@@ -153,10 +153,10 @@ class ImageCache {
...
@@ -153,10 +153,10 @@ class ImageCache {
if
(
_maximumSizeBytes
==
0
)
{
if
(
_maximumSizeBytes
==
0
)
{
clear
();
clear
();
}
else
{
}
else
{
_checkCacheSize
(
t
imelineTask
);
_checkCacheSize
(
debugT
imelineTask
);
}
}
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
();
debugT
imelineTask
!.
finish
();
}
}
}
}
...
@@ -283,7 +283,6 @@ class ImageCache {
...
@@ -283,7 +283,6 @@ class ImageCache {
/// Resizes the cache as appropriate to maintain the constraints of
/// Resizes the cache as appropriate to maintain the constraints of
/// [maximumSize] and [maximumSizeBytes].
/// [maximumSize] and [maximumSizeBytes].
void
_touch
(
Object
key
,
_CachedImage
image
,
TimelineTask
?
timelineTask
)
{
void
_touch
(
Object
key
,
_CachedImage
image
,
TimelineTask
?
timelineTask
)
{
assert
(
timelineTask
!=
null
);
if
(
image
.
sizeBytes
!=
null
&&
image
.
sizeBytes
!
<=
maximumSizeBytes
&&
maximumSize
>
0
)
{
if
(
image
.
sizeBytes
!=
null
&&
image
.
sizeBytes
!
<=
maximumSizeBytes
&&
maximumSize
>
0
)
{
_currentSizeBytes
+=
image
.
sizeBytes
!;
_currentSizeBytes
+=
image
.
sizeBytes
!;
_cache
[
key
]
=
image
;
_cache
[
key
]
=
image
;
...
@@ -324,9 +323,9 @@ class ImageCache {
...
@@ -324,9 +323,9 @@ class ImageCache {
/// Images that are larger than [maximumSizeBytes] are not cached, and do not
/// Images that are larger than [maximumSizeBytes] are not cached, and do not
/// cause other images in the cache to be evicted.
/// cause other images in the cache to be evicted.
ImageStreamCompleter
?
putIfAbsent
(
Object
key
,
ImageStreamCompleter
Function
()
loader
,
{
ImageErrorListener
?
onError
})
{
ImageStreamCompleter
?
putIfAbsent
(
Object
key
,
ImageStreamCompleter
Function
()
loader
,
{
ImageErrorListener
?
onError
})
{
TimelineTask
?
t
imelineTask
;
TimelineTask
?
debugT
imelineTask
;
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
=
TimelineTask
()..
start
(
debugT
imelineTask
=
TimelineTask
()..
start
(
'ImageCache.putIfAbsent'
,
'ImageCache.putIfAbsent'
,
arguments:
<
String
,
dynamic
>{
arguments:
<
String
,
dynamic
>{
'key'
:
key
.
toString
(),
'key'
:
key
.
toString
(),
...
@@ -337,7 +336,7 @@ class ImageCache {
...
@@ -337,7 +336,7 @@ class ImageCache {
// Nothing needs to be done because the image hasn't loaded yet.
// Nothing needs to be done because the image hasn't loaded yet.
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'pending'
});
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'pending'
});
}
}
return
result
;
return
result
;
}
}
...
@@ -348,7 +347,7 @@ class ImageCache {
...
@@ -348,7 +347,7 @@ class ImageCache {
final
_CachedImage
?
image
=
_cache
.
remove
(
key
);
final
_CachedImage
?
image
=
_cache
.
remove
(
key
);
if
(
image
!=
null
)
{
if
(
image
!=
null
)
{
if
(!
kReleaseMode
)
{
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).
// The image might have been keptAlive but had no listeners (so not live).
// Make sure the cache starts tracking it as live again.
// Make sure the cache starts tracking it as live again.
...
@@ -369,10 +368,10 @@ class ImageCache {
...
@@ -369,10 +368,10 @@ class ImageCache {
liveImage
.
completer
,
liveImage
.
completer
,
sizeBytes:
liveImage
.
sizeBytes
,
sizeBytes:
liveImage
.
sizeBytes
,
),
),
t
imelineTask
,
debugT
imelineTask
,
);
);
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'keepAlive'
});
}
}
return
liveImage
.
completer
;
return
liveImage
.
completer
;
}
}
...
@@ -382,7 +381,7 @@ class ImageCache {
...
@@ -382,7 +381,7 @@ class ImageCache {
_trackLiveImage
(
key
,
result
,
null
);
_trackLiveImage
(
key
,
result
,
null
);
}
catch
(
error
,
stackTrace
)
{
}
catch
(
error
,
stackTrace
)
{
if
(!
kReleaseMode
)
{
if
(!
kReleaseMode
)
{
t
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
debugT
imelineTask
!.
finish
(
arguments:
<
String
,
dynamic
>{
'result'
:
'error'
,
'result'
:
'error'
,
'error'
:
error
.
toString
(),
'error'
:
error
.
toString
(),
'stackTrace'
:
stackTrace
.
toString
(),
'stackTrace'
:
stackTrace
.
toString
(),
...
@@ -397,7 +396,7 @@ class ImageCache {
...
@@ -397,7 +396,7 @@ class ImageCache {
}
}
if
(!
kReleaseMode
)
{
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
// 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
// sure that some cleanup works won't run multiple times, such as finishing the
...
@@ -424,7 +423,7 @@ class ImageCache {
...
@@ -424,7 +423,7 @@ class ImageCache {
// Only touch if the cache was enabled when resolve was initially called.
// Only touch if the cache was enabled when resolve was initially called.
if
(
trackPendingImage
)
{
if
(
trackPendingImage
)
{
_touch
(
key
,
image
,
t
imelineTask
);
_touch
(
key
,
image
,
debugT
imelineTask
);
}
else
{
}
else
{
image
.
dispose
();
image
.
dispose
();
}
}
...
@@ -434,7 +433,7 @@ class ImageCache {
...
@@ -434,7 +433,7 @@ class ImageCache {
pendingImage
.
removeListener
();
pendingImage
.
removeListener
();
}
}
if
(!
kReleaseMode
&&
!
listenedOnce
)
{
if
(!
kReleaseMode
&&
!
listenedOnce
)
{
t
imelineTask
!
debugT
imelineTask
!
..
finish
(
arguments:
<
String
,
dynamic
>{
..
finish
(
arguments:
<
String
,
dynamic
>{
'syncCall'
:
syncCall
,
'syncCall'
:
syncCall
,
'sizeInBytes'
:
sizeBytes
,
'sizeInBytes'
:
sizeBytes
,
...
...
packages/flutter/lib/src/painting/shader_warm_up.dart
View file @
e06650bd
...
@@ -88,14 +88,18 @@ abstract class ShaderWarmUp {
...
@@ -88,14 +88,18 @@ abstract class ShaderWarmUp {
final
ui
.
Picture
picture
=
recorder
.
endRecording
();
final
ui
.
Picture
picture
=
recorder
.
endRecording
();
assert
(
debugCaptureShaderWarmUpPicture
(
picture
));
assert
(
debugCaptureShaderWarmUpPicture
(
picture
));
if
(!
kIsWeb
||
isCanvasKit
)
{
// Picture.toImage is not yet implemented on the web.
if
(!
kIsWeb
||
isCanvasKit
)
{
// Picture.toImage is not yet implemented on the web.
final
TimelineTask
shaderWarmUpTask
=
TimelineTask
();
TimelineTask
?
debugShaderWarmUpTask
;
shaderWarmUpTask
.
start
(
'Warm-up shader'
);
if
(!
kReleaseMode
)
{
debugShaderWarmUpTask
=
TimelineTask
()..
start
(
'Warm-up shader'
);
}
try
{
try
{
final
ui
.
Image
image
=
await
picture
.
toImage
(
size
.
width
.
ceil
(),
size
.
height
.
ceil
());
final
ui
.
Image
image
=
await
picture
.
toImage
(
size
.
width
.
ceil
(),
size
.
height
.
ceil
());
assert
(
debugCaptureShaderWarmUpImage
(
image
));
assert
(
debugCaptureShaderWarmUpImage
(
image
));
image
.
dispose
();
image
.
dispose
();
}
finally
{
}
finally
{
shaderWarmUpTask
.
finish
();
if
(!
kReleaseMode
)
{
debugShaderWarmUpTask
!.
finish
();
}
}
}
}
}
picture
.
dispose
();
picture
.
dispose
();
...
...
packages/flutter/lib/src/scheduler/binding.dart
View file @
e06650bd
...
@@ -14,7 +14,6 @@ import 'debug.dart';
...
@@ -14,7 +14,6 @@ import 'debug.dart';
import
'priority.dart'
;
import
'priority.dart'
;
import
'service_extensions.dart'
;
import
'service_extensions.dart'
;
export
'dart:developer'
show
Flow
;
export
'dart:ui'
show
AppLifecycleState
,
FrameTiming
,
TimingsCallback
;
export
'dart:ui'
show
AppLifecycleState
,
FrameTiming
,
TimingsCallback
;
export
'priority.dart'
show
Priority
;
export
'priority.dart'
show
Priority
;
...
@@ -940,7 +939,10 @@ mixin SchedulerBinding on BindingBase {
...
@@ -940,7 +939,10 @@ mixin SchedulerBinding on BindingBase {
}
}
_warmUpFrame
=
true
;
_warmUpFrame
=
true
;
final
TimelineTask
timelineTask
=
TimelineTask
()..
start
(
'Warm-up frame'
);
TimelineTask
?
debugTimelineTask
;
if
(!
kReleaseMode
)
{
debugTimelineTask
=
TimelineTask
()..
start
(
'Warm-up frame'
);
}
final
bool
hadScheduledFrame
=
_hasScheduledFrame
;
final
bool
hadScheduledFrame
=
_hasScheduledFrame
;
// We use timers here to ensure that microtasks flush in between.
// We use timers here to ensure that microtasks flush in between.
Timer
.
run
(()
{
Timer
.
run
(()
{
...
@@ -969,7 +971,9 @@ mixin SchedulerBinding on BindingBase {
...
@@ -969,7 +971,9 @@ mixin SchedulerBinding on BindingBase {
// scheduled frame has finished.
// scheduled frame has finished.
lockEvents
(()
async
{
lockEvents
(()
async
{
await
endOfFrame
;
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 {
...
@@ -39,14 +39,18 @@ class _ProfiledBinaryMessenger implements BinaryMessenger {
}
}
Future
<
ByteData
?>?
sendWithPostfix
(
String
channel
,
String
postfix
,
ByteData
?
message
)
async
{
Future
<
ByteData
?>?
sendWithPostfix
(
String
channel
,
String
postfix
,
ByteData
?
message
)
async
{
final
TimelineTask
task
=
TimelineTask
();
_debugRecordUpStream
(
channelTypeName
,
'
$channel$postfix
'
,
codecTypeName
,
message
);
_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
;
final
ByteData
?
result
;
try
{
try
{
result
=
await
proxy
.
send
(
channel
,
message
);
result
=
await
proxy
.
send
(
channel
,
message
);
}
finally
{
}
finally
{
task
.
finish
();
if
(!
kReleaseMode
)
{
debugTimelineTask
!.
finish
();
}
}
}
_debugRecordDownStream
(
channelTypeName
,
'
$channel$postfix
'
,
codecTypeName
,
result
);
_debugRecordDownStream
(
channelTypeName
,
'
$channel$postfix
'
,
codecTypeName
,
result
);
return
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