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
37de4960
Unverified
Commit
37de4960
authored
Jul 08, 2022
by
Dan Field
Committed by
GitHub
Jul 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove listeners from pending images when clearing cache (#107276)
parent
742a1c38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
image_cache.dart
packages/flutter/lib/src/painting/image_cache.dart
+3
-0
image_cache_test.dart
packages/flutter/test/painting/image_cache_test.dart
+29
-2
No files found.
packages/flutter/lib/src/painting/image_cache.dart
View file @
37de4960
...
...
@@ -195,6 +195,9 @@ class ImageCache {
image
.
dispose
();
}
_cache
.
clear
();
for
(
final
_PendingImage
pendingImage
in
_pendingImages
.
values
)
{
pendingImage
.
removeListener
();
}
_pendingImages
.
clear
();
_currentSizeBytes
=
0
;
}
...
...
packages/flutter/test/painting/image_cache_test.dart
View file @
37de4960
...
...
@@ -179,6 +179,10 @@ void main() {
return
completer1
;
})!
as
TestImageStreamCompleter
;
// Make the image seem live.
final
ImageStreamListener
listener
=
ImageStreamListener
((
_
,
__
)
{});
completer1
.
addListener
(
listener
);
expect
(
imageCache
.
statusForKey
(
testImage
).
pending
,
true
);
expect
(
imageCache
.
statusForKey
(
testImage
).
live
,
true
);
imageCache
.
clear
();
...
...
@@ -346,10 +350,10 @@ void main() {
imageCache
.
clear
();
expect
(
imageCache
.
statusForKey
(
testImage1
).
pending
,
false
);
expect
(
imageCache
.
statusForKey
(
testImage1
).
live
,
tru
e
);
expect
(
imageCache
.
statusForKey
(
testImage1
).
live
,
fals
e
);
completer1
.
testSetImage
(
testImage1
);
expect
(
imageCache
.
statusForKey
(
testImage1
).
keepAlive
,
tru
e
);
expect
(
imageCache
.
statusForKey
(
testImage1
).
keepAlive
,
fals
e
);
expect
(
imageCache
.
statusForKey
(
testImage1
).
live
,
false
);
imageCache
.
putIfAbsent
(
testImage2
,
()
=>
completer2
);
...
...
@@ -602,4 +606,27 @@ void main() {
imageInfo
.
dispose
();
expect
(
testImage
.
debugGetOpenHandleStackTraces
()!.
length
,
0
);
},
skip:
kIsWeb
);
// https://github.com/flutter/flutter/issues/87442
test
(
'clear does not leave pending images stuck'
,
()
async
{
final
ui
.
Image
testImage
=
await
createTestImage
(
width:
8
,
height:
8
);
final
TestImageStreamCompleter
completer1
=
TestImageStreamCompleter
();
imageCache
.
putIfAbsent
(
testImage
,
()
{
return
completer1
;
});
expect
(
imageCache
.
statusForKey
(
testImage
).
pending
,
true
);
expect
(
imageCache
.
statusForKey
(
testImage
).
live
,
true
);
expect
(
imageCache
.
statusForKey
(
testImage
).
keepAlive
,
false
);
imageCache
.
clear
();
// No one else is listening to the completer. It should not be considered
// live anymore.
expect
(
imageCache
.
statusForKey
(
testImage
).
pending
,
false
);
expect
(
imageCache
.
statusForKey
(
testImage
).
live
,
false
);
expect
(
imageCache
.
statusForKey
(
testImage
).
keepAlive
,
false
);
});
}
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