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>>[
|
<Map<String, dynamic>>[
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': 'ImageCache.putIfAbsent',
|
'name': 'ImageCache.putIfAbsent',
|
||||||
'args': <String, dynamic>{'key': 'Test', 'isolateId': isolateId},
|
'args': <String, dynamic>{
|
||||||
|
'key': 'Test',
|
||||||
|
'isolateId': isolateId,
|
||||||
|
'parentId': null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': 'listener',
|
'name': 'listener',
|
||||||
'args': <String, dynamic>{'isolateId': isolateId},
|
'args': <String, dynamic>{
|
||||||
|
'isolateId': isolateId,
|
||||||
|
'parentId': null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': 'ImageCache.clear',
|
'name': 'ImageCache.clear',
|
||||||
@ -48,15 +55,24 @@ void main() {
|
|||||||
'liveImages': 1,
|
'liveImages': 1,
|
||||||
'currentSizeInBytes': 0,
|
'currentSizeInBytes': 0,
|
||||||
'isolateId': isolateId,
|
'isolateId': isolateId,
|
||||||
|
'parentId': null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': 'ImageCache.putIfAbsent',
|
'name': 'ImageCache.putIfAbsent',
|
||||||
'args': <String, dynamic>{'key': 'Test2', 'isolateId': isolateId},
|
'args': <String, dynamic>{
|
||||||
|
'key': 'Test2',
|
||||||
|
'isolateId': isolateId,
|
||||||
|
'parentId': null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'name': 'ImageCache.evict',
|
'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.
|
/// 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? timelineTask;
|
TimelineTask? timelineTask;
|
||||||
TimelineTask? listenerTask;
|
|
||||||
if (!kReleaseMode) {
|
if (!kReleaseMode) {
|
||||||
timelineTask = TimelineTask()..start(
|
timelineTask = TimelineTask()..start(
|
||||||
'ImageCache.putIfAbsent',
|
'ImageCache.putIfAbsent',
|
||||||
@ -398,7 +397,7 @@ class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!kReleaseMode) {
|
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
|
// 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
|
||||||
@ -425,7 +424,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, listenerTask);
|
_touch(key, image, timelineTask);
|
||||||
} else {
|
} else {
|
||||||
image.dispose();
|
image.dispose();
|
||||||
}
|
}
|
||||||
@ -435,14 +434,15 @@ class ImageCache {
|
|||||||
pendingImage.removeListener();
|
pendingImage.removeListener();
|
||||||
}
|
}
|
||||||
if (!kReleaseMode && !listenedOnce) {
|
if (!kReleaseMode && !listenedOnce) {
|
||||||
listenerTask!.finish(arguments: <String, dynamic>{
|
timelineTask!
|
||||||
'syncCall': syncCall,
|
..finish(arguments: <String, dynamic>{
|
||||||
'sizeInBytes': sizeBytes,
|
'syncCall': syncCall,
|
||||||
});
|
'sizeInBytes': sizeBytes,
|
||||||
timelineTask!.finish(arguments: <String, dynamic>{
|
})
|
||||||
'currentSizeBytes': currentSizeBytes,
|
..finish(arguments: <String, dynamic>{
|
||||||
'currentSize': currentSize,
|
'currentSizeBytes': currentSizeBytes,
|
||||||
});
|
'currentSize': currentSize,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
listenedOnce = true;
|
listenedOnce = true;
|
||||||
}
|
}
|
||||||
@ -504,9 +504,8 @@ class ImageCache {
|
|||||||
// maximum, or the cache is empty.
|
// maximum, or the cache is empty.
|
||||||
void _checkCacheSize(TimelineTask? timelineTask) {
|
void _checkCacheSize(TimelineTask? timelineTask) {
|
||||||
final Map<String, dynamic> finishArgs = <String, dynamic>{};
|
final Map<String, dynamic> finishArgs = <String, dynamic>{};
|
||||||
TimelineTask? checkCacheTask;
|
|
||||||
if (!kReleaseMode) {
|
if (!kReleaseMode) {
|
||||||
checkCacheTask = TimelineTask(parent: timelineTask)..start('checkCacheSize');
|
timelineTask!.start('checkCacheSize');
|
||||||
finishArgs['evictedKeys'] = <String>[];
|
finishArgs['evictedKeys'] = <String>[];
|
||||||
finishArgs['currentSize'] = currentSize;
|
finishArgs['currentSize'] = currentSize;
|
||||||
finishArgs['currentSizeBytes'] = currentSizeBytes;
|
finishArgs['currentSizeBytes'] = currentSizeBytes;
|
||||||
@ -524,7 +523,7 @@ class ImageCache {
|
|||||||
if (!kReleaseMode) {
|
if (!kReleaseMode) {
|
||||||
finishArgs['endSize'] = currentSize;
|
finishArgs['endSize'] = currentSize;
|
||||||
finishArgs['endSizeBytes'] = currentSizeBytes;
|
finishArgs['endSizeBytes'] = currentSizeBytes;
|
||||||
checkCacheTask!.finish(arguments: finishArgs);
|
timelineTask!.finish(arguments: finishArgs);
|
||||||
}
|
}
|
||||||
assert(_currentSizeBytes >= 0);
|
assert(_currentSizeBytes >= 0);
|
||||||
assert(_cache.length <= maximumSize);
|
assert(_cache.length <= maximumSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user