Don't store page-level data, in the API, after cleanup has run (bug 1854145)

For large/complex images it's possible that the image-data arrives in the API *after* the page has been scrolled out-of-view and thus been cleaned-up. In this case we obviously shouldn't cache such page-level data, since it'll first of all be unused and secondly can increase memory usage *a lot*.
Also, ensure that we *immediately* release any `ImageBitmap` data in this case to help reclaim memory faster.
This commit is contained in:
Jonas Jenwald 2023-10-10 19:01:16 +02:00
parent 2c39a739f5
commit 0238cf134d

View File

@ -2768,6 +2768,11 @@ class WorkerTransport {
if (pageProxy.objs.has(id)) {
return;
}
// Don't store data *after* cleanup has successfully run, see bug 1854145.
if (pageProxy._intentStates.size === 0) {
imageData?.bitmap?.close(); // Release any `ImageBitmap` data.
return;
}
switch (type) {
case "Image":