servo: Merge #17120 - fix double borrowing of image request (from gterzian:fix_double_borrowing_of_image_request); r=jdm
authorGregory Terzian <gterzian@users.noreply.github.com>
Wed, 31 May 2017 21:47:33 -0700
changeset 361700 7d08d1135232d16077d1df8580ef67a11cc601d3
parent 361699 941c6923e4071fd91d079bdc2b827cb5162fd982
child 361701 7bdd66505228718a7c68723e1364c1aa98956bf1
push id31939
push usercbook@mozilla.com
push dateThu, 01 Jun 2017 11:49:28 +0000
treeherdermozilla-central@d96110d76619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs17120, 17109
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17120 - fix double borrowing of image request (from gterzian:fix_double_borrowing_of_image_request); r=jdm <!-- Please describe your changes on the following line: --> @jdm I couldn't reproduce the crashes, but looking at the code, I can tell that if we hit the cache inside `fetch_image`, we go straight to `process_image_response`, so we're still in the same scope as that where the borrowing occurs in `prepare_image_request`. When there is no cache hit, `process_image_response` is executed as part of a task... This should fix the issue, while retaining the original logic. All tests in `the-img-element` are passing... --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #17109 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 6a638876fdf1f7c87d9c17d302864d38b67510cb
servo/components/script/dom/htmlimageelement.rs
--- a/servo/components/script/dom/htmlimageelement.rs
+++ b/servo/components/script/dom/htmlimageelement.rs
@@ -519,32 +519,30 @@ impl HTMLImageElement {
                             pending_request.image = None;
                             pending_request.parsed_url = None;
                             LoadBlocker::terminate(&mut pending_request.blocker);
                             // TODO: queue a task to restart animation, if restart-animation is set
                             return
                         }
                         self.image_request.set(ImageRequestPhase::Pending);
                         self.init_image_request(&mut pending_request, &url, &src);
-                        self.fetch_image(&url);
                     },
                     (_, State::Broken) | (_, State::Unavailable) => {
                         // Step 12.5
                         self.init_image_request(&mut current_request, &url, &src);
-                        self.fetch_image(&url);
                     },
                     (_, _) => {
                         // step 12.6
                         self.image_request.set(ImageRequestPhase::Pending);
                         self.init_image_request(&mut pending_request, &url, &src);
-                        self.fetch_image(&url);
                     },
                 }
             }
         }
+        self.fetch_image(&url);
     }
 
     /// Step 8-12 of html.spec.whatwg.org/multipage/#update-the-image-data
     fn update_the_image_data_sync_steps(&self) {
         let document = document_from_node(self);
         // Step 8
         // TODO: take pixel density into account
         match self.select_image_source() {