Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory issue: WR image resources are not deleted #25927

Open
paulrouget opened this issue Mar 9, 2020 · 0 comments
Open

Memory issue: WR image resources are not deleted #25927

paulrouget opened this issue Mar 9, 2020 · 0 comments

Comments

@paulrouget
Copy link
Contributor

@paulrouget paulrouget commented Mar 9, 2020

Even after the image cache has been destroyed, the WR image resources are still in memory.

Sending a delete_image transaction appears to solve the issue, but I'm not exactly sure when we should tell WR to drop the images.

The options are:

  • when the pipeline is destroyed
  • when ImageCacheStore is destroyed
  • when the image fragment are destroyed
  • … any other time?
--- a/components/net/image_cache.rs
+++ b/components/net/image_cache.rs
@@ -342,6 +342,22 @@ struct ImageCacheStore {
     webrender_api: WebrenderIpcSender,
 }

+impl Drop for ImageCacheStore {
+    fn drop(&mut self) {
+        for load in self.completed_loads.values() {
+            if let ImageResponse::Loaded(image, _) = &load.image_response {
+                if let Some(image_key) = image.id {
+                    let mut txn = webrender_api::Transaction::new();
+                    txn.delete_image(image_key);
+                    self.webrender_api.update_resources(txn.resource_updates);
+                }
+            }
+        }
+    }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.