avoid incorrect usage of TimelineTask (#127527)
This code was added based on a misunderstanding of the API surface.
This commit is contained in:
parent
c05a05e6fc
commit
a21f33e7ad
@ -34,11 +34,18 @@ void main() {
|
||||
<Map<String, dynamic>>[
|
||||
<String, dynamic>{
|
||||
'name': 'ImageCache.putIfAbsent',
|
||||
'args': <String, dynamic>{'key': 'Test', 'isolateId': isolateId},
|
||||
'args': <String, dynamic>{
|
||||
'key': 'Test',
|
||||
'isolateId': isolateId,
|
||||
'parentId': null,
|
||||
},
|
||||
},
|
||||
<String, dynamic>{
|
||||
'name': 'listener',
|
||||
'args': <String, dynamic>{'isolateId': isolateId},
|
||||
'args': <String, dynamic>{
|
||||
'isolateId': isolateId,
|
||||
'parentId': null,
|
||||
},
|
||||
},
|
||||
<String, dynamic>{
|
||||
'name': 'ImageCache.clear',
|
||||
@ -48,15 +55,24 @@ void main() {
|
||||
'liveImages': 1,
|
||||
'currentSizeInBytes': 0,
|
||||
'isolateId': isolateId,
|
||||
'parentId': null,
|
||||
},
|
||||
},
|
||||
<String, dynamic>{
|
||||
'name': 'ImageCache.putIfAbsent',
|
||||
'args': <String, dynamic>{'key': 'Test2', 'isolateId': isolateId},
|
||||
'args': <String, dynamic>{
|
||||
'key': 'Test2',
|
||||
'isolateId': isolateId,
|
||||
'parentId': null,
|
||||
},
|
||||
},
|
||||
<String, dynamic>{
|
||||
'name': 'ImageCache.evict',
|
||||
'args': <String, dynamic>{'sizeInBytes': 4, 'isolateId': isolateId},
|
||||
'args': <String, dynamic>{
|
||||
'sizeInBytes': 4,
|
||||
'isolateId': isolateId,
|
||||
'parentId': null,
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
|
@ -325,7 +325,6 @@ class ImageCache {
|
||||
/// cause other images in the cache to be evicted.
|
||||
ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter Function() loader, { ImageErrorListener? onError }) {
|
||||
TimelineTask? timelineTask;
|
||||
TimelineTask? listenerTask;
|
||||
if (!kReleaseMode) {
|
||||
timelineTask = TimelineTask()..start(
|
||||
'ImageCache.putIfAbsent',
|
||||
@ -398,7 +397,7 @@ class ImageCache {
|
||||
}
|
||||
|
||||
if (!kReleaseMode) {
|
||||
listenerTask = TimelineTask(parent: timelineTask)..start('listener');
|
||||
timelineTask!.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
|
||||
@ -425,7 +424,7 @@ class ImageCache {
|
||||
|
||||
// Only touch if the cache was enabled when resolve was initially called.
|
||||
if (trackPendingImage) {
|
||||
_touch(key, image, listenerTask);
|
||||
_touch(key, image, timelineTask);
|
||||
} else {
|
||||
image.dispose();
|
||||
}
|
||||
@ -435,14 +434,15 @@ class ImageCache {
|
||||
pendingImage.removeListener();
|
||||
}
|
||||
if (!kReleaseMode && !listenedOnce) {
|
||||
listenerTask!.finish(arguments: <String, dynamic>{
|
||||
'syncCall': syncCall,
|
||||
'sizeInBytes': sizeBytes,
|
||||
});
|
||||
timelineTask!.finish(arguments: <String, dynamic>{
|
||||
'currentSizeBytes': currentSizeBytes,
|
||||
'currentSize': currentSize,
|
||||
});
|
||||
timelineTask!
|
||||
..finish(arguments: <String, dynamic>{
|
||||
'syncCall': syncCall,
|
||||
'sizeInBytes': sizeBytes,
|
||||
})
|
||||
..finish(arguments: <String, dynamic>{
|
||||
'currentSizeBytes': currentSizeBytes,
|
||||
'currentSize': currentSize,
|
||||
});
|
||||
}
|
||||
listenedOnce = true;
|
||||
}
|
||||
@ -504,9 +504,8 @@ class ImageCache {
|
||||
// maximum, or the cache is empty.
|
||||
void _checkCacheSize(TimelineTask? timelineTask) {
|
||||
final Map<String, dynamic> finishArgs = <String, dynamic>{};
|
||||
TimelineTask? checkCacheTask;
|
||||
if (!kReleaseMode) {
|
||||
checkCacheTask = TimelineTask(parent: timelineTask)..start('checkCacheSize');
|
||||
timelineTask!.start('checkCacheSize');
|
||||
finishArgs['evictedKeys'] = <String>[];
|
||||
finishArgs['currentSize'] = currentSize;
|
||||
finishArgs['currentSizeBytes'] = currentSizeBytes;
|
||||
@ -524,7 +523,7 @@ class ImageCache {
|
||||
if (!kReleaseMode) {
|
||||
finishArgs['endSize'] = currentSize;
|
||||
finishArgs['endSizeBytes'] = currentSizeBytes;
|
||||
checkCacheTask!.finish(arguments: finishArgs);
|
||||
timelineTask!.finish(arguments: finishArgs);
|
||||
}
|
||||
assert(_currentSizeBytes >= 0);
|
||||
assert(_cache.length <= maximumSize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user