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

Clip rounded profile start to end after clipping rounded end to width / height #1399

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

confluence
Copy link
Collaborator

@confluence confluence commented Jan 28, 2025

Description

This should fix #1395.

I believe that this bug is triggered by the spatially matched images being non-overlapping, which leads to a profile sometimes being requested from the large image with both endpoints being the largest y value (i.e. 999 to 999). When the image is zoomed out and a large mip is used, the endpoints are rounded for decimation (from 999 to 1000). The end is then restricted to the height of the image (999), but we did not consider the possibility that the start value could be equal to the end and thus also need to be adjusted in the same way here.

This PR adds a line to restrict the start so that it does not exceed the end.

In my local test (on Ubuntu), the crash was happening in profile.reserve(end - start);. I'm not 100% sure if @crocka's crash on the Mac (a value being too large to fit in a size_t) was happening in exactly the same place, but it's likely to have had the same root cause (a negative number being incorrectly converted to an unsigned type).

If you cannot reproduce the crash in dev, try reducing the area available for the image viewer component (e.g. by opening the browser console in the window). It's only triggered when the mip is high enough (and I believe when your cursor is in the appropriate area of the image).

If there is no regression, I think this is a low-risk addition.

Checklist

  • changelog updated / no changelog update needed
  • e2e test passing / corresponding fix added / new e2e test created
  • ICD test passing / corresponding fix added / new ICD test created
  • protobuf updated to the latest dev commit / no protobuf update needed
  • protobuf version bumped / protobuf version not bumped
  • added reviewers and assignee
  • GitHub Project estimate added

@confluence confluence self-assigned this Jan 28, 2025
Copy link

Code Coverage

Package Line Rate Health
src.Cache 72%
src.DataStream 44%
src.FileList 67%
src.Frame 36%
src.HttpServer 42%
src.ImageData 28%
src.ImageFitter 83%
src.ImageGenerators 43%
src.ImageStats 75%
src.Logger 37%
src.Main 52%
src.Region 69%
src.Session 4%
src.Table 52%
src.ThreadingManager 67%
src.Timer 85%
src.Util 38%
Summary 46% (8644 / 18966)

@pford
Copy link
Collaborator

pford commented Jan 29, 2025

I tested on a Mac and got almost the same error in the dev branch: libc++abi: terminating due to uncaught exception of type std::length_error: vector. This is fixed in the branch for this PR.

I find it odd that when the second image goes out of view due to spatial matching, the frontend does not update the cursor in the backend with the pixel values outside the image (x < 0, y > max_y), sends two spatial requirements for the matched image as shown below, then does not show the profiles that are sent with the image's last valid cursor (if no stored valid cursor, no profiles). If the spectral profile is set to the active image, spectral requirements are requested and spectral data is sent for the last valid cursor (I assume, not in spectral data message) and shown.

  1. Frontend sends spatial requirements {'x': start=0, end=0} {'y': start=999, end=999} with mip=4 (image shape [1231, 999, 301]). Backend resolves the x-range to full range and sends the x-profile for the last valid cursor, but no y-profile. (no error)
  2. Frontend sends spatial requirements {'x': start=0, end=0} {'y': start=0, end=0} with mip=1. Backend resolves both to the full range and sends x and y profiles for the last valid cursor.

@confluence confluence marked this pull request as ready for review February 3, 2025 07:53
@confluence confluence added the awaiting testing For pull requests that require testing label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting testing For pull requests that require testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend crash due to 'n' exceeds maximum supported size after spatial matching of two images
2 participants