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
9d58a870
Unverified
Commit
9d58a870
authored
May 23, 2020
by
Devon Carew
Committed by
GitHub
May 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a typo in trace events for the image cache (#57821)
parent
721927ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
image_cache_tracing_test.dart
dev/tracing_tests/test/image_cache_tracing_test.dart
+35
-0
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+2
-2
No files found.
dev/tracing_tests/test/image_cache_tracing_test.dart
View file @
9d58a870
...
...
@@ -5,6 +5,8 @@
import
'dart:convert'
;
import
'dart:developer'
as
developer
;
import
'dart:isolate'
as
isolate
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/painting.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -31,12 +33,21 @@ void main() {
test
(
'Image cache tracing'
,
()
async
{
final
TestImageStreamCompleter
completer1
=
TestImageStreamCompleter
();
final
TestImageStreamCompleter
completer2
=
TestImageStreamCompleter
();
PaintingBinding
.
instance
.
imageCache
.
putIfAbsent
(
'Test'
,
()
=>
completer1
,
);
PaintingBinding
.
instance
.
imageCache
.
clear
();
// ignore: invalid_use_of_protected_member
completer2
.
setImage
(
const
ImageInfo
(
image:
TestImage
()));
PaintingBinding
.
instance
.
imageCache
.
putIfAbsent
(
'Test2'
,
()
=>
completer2
,
);
PaintingBinding
.
instance
.
imageCache
.
evict
(
'Test2'
);
final
Timeline
timeline
=
await
vmService
.
getVMTimeline
();
_expectTimelineEvents
(
timeline
.
traceEvents
,
...
...
@@ -59,6 +70,14 @@ void main() {
'isolateId'
:
isolateId
,
}
},
<
String
,
dynamic
>{
'name'
:
'ImageCache.putIfAbsent'
,
'args'
:
<
String
,
dynamic
>{
'key'
:
'Test2'
,
'isolateId'
:
isolateId
}
},
<
String
,
dynamic
>{
'name'
:
'ImageCache.evict'
,
'args'
:
<
String
,
dynamic
>{
'sizeInBytes'
:
0
,
'isolateId'
:
isolateId
}
},
],
);
},
skip:
isBrowser
);
// uses dart:isolate and io
...
...
@@ -92,3 +111,19 @@ bool _mapsEqual(Map<String, dynamic> expectedArgs, Map<String, dynamic> args) {
}
class
TestImageStreamCompleter
extends
ImageStreamCompleter
{}
class
TestImage
implements
ui
.
Image
{
const
TestImage
({
this
.
height
=
0
,
this
.
width
=
0
});
@override
final
int
height
;
@override
final
int
width
;
@override
void
dispose
()
{
}
@override
Future
<
ByteData
>
toByteData
({
ui
.
ImageByteFormat
format
=
ui
.
ImageByteFormat
.
rawRgba
})
{
throw
UnimplementedError
();
}
}
packages/flutter/lib/src/painting/image_cache.dart
View file @
9d58a870
...
...
@@ -31,7 +31,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
///
/// A caller can determine whether an image is already in the cache by using
/// [containsKey], which will return true if the image is tracked by the cache
/// in a pending or comp
el
ted state. More fine grained information is available
/// in a pending or comp
le
ted state. More fine grained information is available
/// by using the [statusForKey] method.
///
/// Generally this class is not used directly. The [ImageProvider] class and its
...
...
@@ -255,7 +255,7 @@ class ImageCache {
if
(!
kReleaseMode
)
{
Timeline
.
instantSync
(
'ImageCache.evict'
,
arguments:
<
String
,
dynamic
>{
'type'
:
'keepAlive'
,
'size
i
InBytes'
:
image
.
sizeBytes
,
'sizeInBytes'
:
image
.
sizeBytes
,
});
}
_currentSizeBytes
-=
image
.
sizeBytes
;
...
...
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