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

Make the display list dumping code more generic. #2893

Merged
merged 1 commit into from Jul 17, 2018

Conversation

staktrace
Copy link
Contributor

@staktrace staktrace commented Jul 13, 2018

This allows dumping a subset of items in the display list, at specified
indentation.


This change is Reviewable

@staktrace
Copy link
Contributor Author

This is desirable for https://bugzilla.mozilla.org/show_bug.cgi?id=1475637

{
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) {
Copy link
Member

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

indent: usize,
start: Option<u32>,
end: Option<u32>,
) -> u32 {
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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)

Copy link
Member

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.

Copy link
Contributor Author

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.

if index >= start.unwrap_or(0) && index < end.unwrap_or(u32::MAX) {
eprintln!("{}{:?}", " ".repeat(indent), item.display_item());
}
index = index + 1;
Copy link
Member

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.
@staktrace
Copy link
Contributor Author

staktrace commented Jul 13, 2018

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

@gw3583
Copy link
Contributor

gw3583 commented Jul 16, 2018

@kvark is this ready to merge?

@kvark
Copy link
Member

kvark commented Jul 17, 2018

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 15a2efd has been approved by kvark

@bors-servo
Copy link
Contributor

⌛ Testing commit 15a2efd with merge 88dab3f...

bors-servo pushed a commit that referenced this pull request Jul 17, 2018
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing 88dab3f to master...

@bors-servo bors-servo merged commit 15a2efd into servo:master Jul 17, 2018
staktrace added a commit to staktrace/gecko-dev that referenced this pull request Nov 7, 2018
… 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
staktrace added a commit to staktrace/webrender that referenced this pull request Nov 8, 2018
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
staktrace added a commit to staktrace/webrender that referenced this pull request Nov 8, 2018
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
staktrace added a commit to staktrace/webrender that referenced this pull request Nov 8, 2018
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
bors-servo pushed a commit that referenced this pull request Nov 8, 2018
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 -->
bors-servo pushed a commit that referenced this pull request Nov 8, 2018
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants