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
Make the display list dumping code more generic. #2893
Conversation
This is desirable for https://bugzilla.mozilla.org/show_bug.cgi?id=1475637 |
webrender_api/src/display_list.rs
Outdated
{ | ||
let mut iter = BuiltDisplayListIter::new(&temp); | ||
while let Some(item) = iter.next_raw() { | ||
println!("{:?}", item.display_item()); | ||
if index >= start.unwrap_or(0) && index < end.unwrap_or(u32::MAX) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: end.map_or(true, |e| index < e)
would avoid the need to include u32
webrender_api/src/display_list.rs
Outdated
indent: usize, | ||
start: Option<u32>, | ||
end: Option<u32>, | ||
) -> u32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason the start/end/result are u32
and not usize
? Typically, seeing a sized type implies some interop/size constraints, which I don't see here.
@@ -915,18 +915,36 @@ impl DisplayListBuilder { | |||
self.save_state.take().expect("No save to clear in DisplayListBuilder"); | |||
} | |||
|
|||
pub fn print_display_list(&mut self) { | |||
/// Print the display items in the list to stderr. If the start parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really be in the stderr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdout is buffered often, so things written to stdout don't always show up if you crash right after, for example. This is one of the reasons why pretty much all of gecko logging goes to stderr, and if this goes to stdout it won't be interleaved properly with the rest of the output. Although maybe this should return a string rather than dumping it directly and the caller can decide where to put it.
(The rest of your comments make sense, will update the patch accordingly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, my experience so far indicates that rust's println!
flushes, but print!
does not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if that's the case, these prints are going to be interleaved between prints from C++ code, so they should probably go to the same place.
webrender_api/src/display_list.rs
Outdated
if index >= start.unwrap_or(0) && index < end.unwrap_or(u32::MAX) { | ||
eprintln!("{}{:?}", " ".repeat(indent), item.display_item()); | ||
} | ||
index = index + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: index += 1;
This allows dumping a subset of items in the display list, at specified indentation.
Updated patch to address comments, but left it going to stderr. If you prefer I can split this into two methods: one that does what the old one did (print the whole thing to stdout), and one that takes the new arguments but returns the string instead of printing it. The caller can then print it to stderr or stdout as desired. edit: typo |
@kvark is this ready to merge? |
@bors-servo r+ |
📌 Commit 15a2efd has been approved by |
Make the display list dumping code more generic. This allows dumping a subset of items in the display list, at specified indentation. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2893) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-taskcluster |
… string. r?kvark For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to servo/webrender#2893) where it just dumps the whole display list to stdout. Differential Revision: https://phabricator.services.mozilla.com/D11195
For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to servo#2893) where it just dumps the whole display list to stdout. Reviewed by @kvark at https://phabricator.services.mozilla.com/D11195 Related bug in bugzilla: https://bugzil.la/1505375
For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to servo#2893) where it just dumps the whole display list to stdout. Reviewed by @kvark at https://phabricator.services.mozilla.com/D11195 Related bug in bugzilla: https://bugzil.la/1505375
For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to servo#2893) where it just dumps the whole display list to stdout. Reviewed by @kvark at https://phabricator.services.mozilla.com/D11195 Related bug in bugzilla: https://bugzil.la/1505375
Extract a method to return the dumped display list as a string. For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to #2893) where it just dumps the whole display list to stdout. Reviewed by @kvark at https://phabricator.services.mozilla.com/D11195 Related bug in bugzilla: https://bugzil.la/1505375 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3286) <!-- Reviewable:end -->
Extract a method to return the dumped display list as a string. For proper android support we need to dump this to logcat instead of stderr, so it seems better to just have a function to return the dumped string and we can send it wherever we want in the embedding application. This also changes the print_display_list back to the original semantics (prior to #2893) where it just dumps the whole display list to stdout. Reviewed by @kvark at https://phabricator.services.mozilla.com/D11195 Related bug in bugzilla: https://bugzil.la/1505375 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3286) <!-- Reviewable:end -->
This allows dumping a subset of items in the display list, at specified
indentation.
This change is