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

Alternative diff views #16

Merged
merged 2 commits into from
Jan 30, 2025
Merged

Alternative diff views #16

merged 2 commits into from
Jan 30, 2025

Conversation

spirali
Copy link
Collaborator

@spirali spirali commented Jan 28, 2025

Report allows to switch between diff views (implemented as "tabs" under the diff view)

Original red green:

image

Overlay view:

image

@spirali spirali changed the title Alaternative diff views Alternative diff views Jan 28, 2025
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of the actual code, this seems like a reasonable improvement. I am slightly concerned about the potential performance costs, especially for larger-scale cases (incidentally, this is actually a fantastic use case for the planned virtual scrolling in Xilem)

However, these concerns needn't block this pr - there isn't another reasonable way to implement the report functionality into the browser with this feature (short of computing the diffs in wasm or other nastiness).

It just provides greater motivation for the future work I want to do of a Rust frontend to this.

@@ -15,7 +15,8 @@ pub enum ImageDifference {
Content {
n_different_pixels: u64,
distance_sum: u64,
diff_image: Image,
rg_diff_image: Image,
overlay_diff_image: Image,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work always being done twice concerns me slightly for performance reasons. I think the pattern I'd like to see is:

  1. only the absolute/scalar difference is calculated.
  2. producing the diff images is a separate step, either with a function for each or a "mode" enum.

@@ -41,6 +42,48 @@ impl Debug for ImageDifference {
}
}

fn compute_rg_diff_image(left: &Image, right: &Image) -> (Image, u64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, these should probably be publicly exposed, somehow

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

html! {
img class="zoom" src=(embed_png_url(&data)) width=[w] height=[h] onclick="openImageDialog(this)";
img id=(format!("img-diff1-{}", id)) class="zoom" src=(embed_png_url(&rg_data)) width=[w] height=[h] onclick="openImageDialog(this)";
img id=(format!("img-diff2-{}", id)) style="display: none" class="zoom" src=(embed_png_url(&overlay_data)) width=[w] height=[h] onclick="openImageDialog(this)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is partly why I want a Xilem or similar app for Kompari; so that these diffs could be computed on-the-fly. This change effectively doubles the cost of creating a report, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it doubles the cost of creation, but I would not be worried about it much. I just have made an artificial error in Nelsie and this new version took about ~2s to generate report for 540 images. Moreover it can be easily parallelized by Rayon. btw: Scrolling in the browser is still smooth for all (3+1)x540 images.

@spirali spirali added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit c991215 Jan 30, 2025
15 checks passed
@spirali spirali deleted the diff-views branch January 30, 2025 12:10
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.

2 participants