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

Take origin from current window instead of creating a new one in event of reflow #25777

Merged
merged 2 commits into from Feb 19, 2020

Conversation

@kunalmohan
Copy link
Collaborator

kunalmohan commented Feb 15, 2020

Everytime a new LayoutContext was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum ScriptReflow and
used in creating new LayoutContext in case of reflow.

r?@jdm


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #24720 (GitHub issue number if applicable)
  • There are tests for these changes
Everytime a new LayoutContext was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum ScriptReflow and
used in creating new LayoutContext in case of reflow.
@highfive
Copy link

highfive commented Feb 15, 2020

Heads up! This PR modifies the following files:

@highfive
Copy link

highfive commented Feb 15, 2020

warning Warning warning

  • These commits modify layout and script code, but no tests are modified. Please consider adding a test!
@kunalmohan
Copy link
Collaborator Author

kunalmohan commented Feb 15, 2020

@bors-servo try=wpt
I hope I did not break any existing tests.

@bors-servo
Copy link
Contributor

bors-servo commented Feb 15, 2020

@kunalmohan: 🔑 Insufficient privileges: not in try users

@kunalmohan
Copy link
Collaborator Author

kunalmohan commented Feb 15, 2020

Worth a try 😆

@kunalmohan kunalmohan changed the title Take origin from window instead of creating a new one in case of reflow Take origin from current window instead of creating a new one in event of reflow Feb 15, 2020
@kunalmohan
Copy link
Collaborator Author

kunalmohan commented Feb 16, 2020

These are the new logs:

[2020-02-16T07:36:01Z DEBUG net::image_cache] New image cache
[2020-02-16T07:36:05Z DEBUG net::image_cache] Find image or metadata for file:///mnt/sda1/Documents/web/rust/servo/tests/wpt/mozilla/tests/css/400x400_green.png (Opaque(OpaqueOrigin(21364485-ab9a-4d1b-be1a-1ac800ebf5d1)))
[2020-02-16T07:36:05Z DEBUG net::image_cache] Should be requesting file:///mnt/sda1/Documents/web/rust/servo/tests/wpt/mozilla/tests/css/400x400_green.png (PendingImageId(1))
[2020-02-16T07:36:05Z DEBUG net::image_cache] Received Ok(()) for PendingImageId(1)
[2020-02-16T07:36:05Z DEBUG net::image_cache] Got some data for PendingImageId(1)
[2020-02-16T07:36:05Z DEBUG net_traits::image_cache] Notifying listener
[2020-02-16T07:36:05Z DEBUG net::image_cache] Got some data for PendingImageId(1)
[2020-02-16T07:36:05Z DEBUG net::image_cache] Received EOF for PendingImageId(1)
[2020-02-16T07:36:05Z DEBUG net::image_cache] Async decoding file:///mnt/sda1/Documents/web/rust/servo/tests/wpt/mozilla/tests/css/400x400_green.png (PendingImageId(1))
[2020-02-16T07:36:05Z DEBUG net::image_cache] Find image or metadata for file:///mnt/sda1/Documents/web/rust/servo/tests/wpt/mozilla/tests/css/400x400_green.png (Opaque(OpaqueOrigin(21364485-ab9a-4d1b-be1a-1ac800ebf5d1)))
[2020-02-16T07:36:05Z DEBUG net::image_cache] Sync decoding file:///mnt/sda1/Documents/web/rust/servo/tests/wpt/mozilla/tests/css/400x400_green.png (PendingImageId(1))
[2020-02-16T07:36:05Z DEBUG net::image_cache] Image decoded
[2020-02-16T07:36:05Z DEBUG net_traits::image_cache] Notifying listener
[2020-02-16T07:36:26Z DEBUG net::resource_thread] Exited CoreResourceManager
@CYBAI
Copy link
Collaborator

CYBAI commented Feb 17, 2020

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

Trying commit a5b43b7 with merge e9b0982...

bors-servo added a commit that referenced this pull request Feb 17, 2020
Take origin from current window instead of creating a new one in event of reflow

Everytime a new `LayoutContext` was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum `ScriptReflow` and
used in creating new `LayoutContext` in case of reflow.

<!-- Please describe your changes on the following line: -->
r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24720  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 17, 2020

💔 Test failed - status-taskcluster

@gterzian
Copy link
Member

gterzian commented Feb 17, 2020

Those failures appear like intermittents from #24726

0 matches
2 unexpected results that are NOT known-intermittents:
  ▶ FAIL [expected PASS] /css/CSS2/visufx/clip-031.xht
  │   → /css/CSS2/visufx/clip-031.xht 54a9df64f1476dd12020019d7cf22ac34d727bc0
  │   → /css/CSS2/reference/no-red-on-blank-page-ref.xht 03cf5c9a29d4bae8116d0882c40497d24a8a45a6
  └   → Screenshot is solid color 0xFFFFFF for /css/CSS2/visufx/clip-031.xht
  ▶ FAIL [expected PASS] /_mozilla/css/filter_sepia_a.html
  │   → /_mozilla/css/filter_sepia_a.html 54a9df64f1476dd12020019d7cf22ac34d727bc0
  │   → /_mozilla/css/filter_sepia_ref.html 113c211a1e5cd47a82321c2037e46755aa76787d
  └   → Screenshot is solid color 0xFFFFFF for /_mozilla/css/filter_sepia_a.html

@@ -1738,7 +1746,7 @@ impl LayoutThread {
ua_or_user: &ua_or_user_guard,
};
let snapshots = SnapshotMap::new();
let mut layout_context = self.build_layout_context(guards, false, &snapshots);
let mut layout_context = self.build_layout_context(guards, false, &snapshots, None);

This comment has been minimized.

@gterzian

gterzian Feb 17, 2020

Member

Here you might be able to receive the origin as part of the LayoutControlMsg::TickAnimations.

It is sent from

let msg = LayoutControlMsg::TickAnimations;

So there you have the Pipeline available, so you could to change the below:

Some(pipeline) => pipeline.layout_chan.send(msg),

into something like

Some(pipeline) => {
    let msg = LayoutControlMsg::TickAnimations(pipeline.load_data.url.origin());
    pipeline.layout_chan.send(msg);
}

This comment has been minimized.

@kunalmohan

kunalmohan Feb 17, 2020

Author Collaborator

Oh...I was misunderstanding the purpose and use of LayoutContext. And it was a really stupid one 🤦‍♂️. And, that None was a part of it. I'll correct that now.

Just out of curiosity what is the difference between layout_thread and layout_thread_2020🤔?

This comment has been minimized.

@gterzian

gterzian Feb 17, 2020

Member

Note that I'm not quite sure about the purpose of LayoutContext, I just saw the None there and was thinking that you might not need the option.

layout_thread_2020 is the "new version" of layout, so your fix might require to be implemented in both, or maybe on 2020? I don't know, @SimonSapin can probably tell you more.

This comment has been minimized.

@SimonSapin

SimonSapin Feb 17, 2020

Member

Yes, there’s also components/layout_thread_2020/lib.rs which is very similar to components/layout_thread/lib.rs. See https://github.com/servo/servo/wiki/Layout-2020#using for build instructions.

This comment has been minimized.

@kunalmohan

kunalmohan Feb 17, 2020

Author Collaborator

Okay. Earlier, I was under the impression that there might be cases where LayoutContext had to be assigned a new origin and was considering the above code to be a part of that.

@kunalmohan kunalmohan requested a review from gterzian Feb 17, 2020
Copy link
Member

gterzian left a comment

The changes to the messaging from the constellation looks good to me.

I'm not familiar enough with layout to review the rest.

@SimonSapin r?

@jdm
jdm approved these changes Feb 19, 2020
Copy link
Member

jdm left a comment

I forgot about how many places this would require touching to fix. Great work!

@jdm
Copy link
Member

jdm commented Feb 19, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

📌 Commit 4a3bf52 has been approved by jdm

bors-servo added a commit that referenced this pull request Feb 19, 2020
Take origin from current window instead of creating a new one in event of reflow

Everytime a new `LayoutContext` was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum `ScriptReflow` and
used in creating new `LayoutContext` in case of reflow.

<!-- Please describe your changes on the following line: -->
r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24720  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

Testing commit 4a3bf52 with merge d719b38...

@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Feb 19, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

Testing commit 4a3bf52 with merge 6cb3f73...

bors-servo added a commit that referenced this pull request Feb 19, 2020
Take origin from current window instead of creating a new one in event of reflow

Everytime a new `LayoutContext` was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum `ScriptReflow` and
used in creating new `LayoutContext` in case of reflow.

<!-- Please describe your changes on the following line: -->
r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24720  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Feb 19, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

Testing commit 4a3bf52 with merge 35b1548...

bors-servo added a commit that referenced this pull request Feb 19, 2020
Take origin from current window instead of creating a new one in event of reflow

Everytime a new `LayoutContext` was created, it created a new origin which
caused endless stream of image loads to occur in case of reflow. The reason
for this was that the existing image, although cached successfully, was not
used because the entry in hashmap did not match because of different(new)
origin.
This is solved by storing the origin of a window in enum `ScriptReflow` and
used in creating new `LayoutContext` in case of reflow.

<!-- Please describe your changes on the following line: -->
r?@jdm

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24720  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 19, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 35b1548 to master...

@bors-servo bors-servo merged commit 4a3bf52 into servo:master Feb 19, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@kunalmohan kunalmohan deleted the kunalmohan:24720-ImageCache branch Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.