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

fix(measurements): The image stack sync tool fails to work on non-FOR instances and hangs the browser #642

Merged
merged 12 commits into from
Sep 7, 2023

Conversation

wayfarer3130
Copy link
Collaborator

@wayfarer3130 wayfarer3130 commented Jun 5, 2023

Context

Synchronizers hang the browser if they do asynchronous actions.

The imageStackSync uses two algorithms, of which only one actually works correctly.
Changed to use a single algorithm, just different starting conditions depending on options.

Changes & Results

Made the synchronizers thread safe

Made the imageStackSync work with non same FOR images, and same FOR using current positions when configured to do so.

Testing

Display 4 up (2x2 mode) with the same FOR series in all frames, turn on image stack synchronizer - depending on the series selected, it may hang the browser.

Display 2+up mode with different FOR but coplanar series. Activate image stack sync (without doing anything special - just activate it, eg in the hanging protocol). Ensure that image stacks navigate together for coplanar series in stack mode.

Checklist

PR

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] "OS:
  • [] "Node version:
  • [] "Browser:

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit 3f1a2f2
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/64fa2a2e181b3b00085bb84d
😎 Deploy Preview https://deploy-preview-642--cornerstone-3d-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@wayfarer3130 wayfarer3130 requested review from sedghi and jbocce June 5, 2023 17:07
@wayfarer3130 wayfarer3130 changed the title fix(synchronizer): The synchronizer needs to discontinue listening until done fix(measurements): The image stack sync tool fails to work on non-FOR instances and hangs the browser Jun 7, 2023
}
} catch (ex) {
console.warn(`Synchronizer, for: ${this._eventName}`, ex);
} finally {
this._ignoreFiredEvents = false;
if (promises.length) {

Choose a reason for hiding this comment

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

@wayfarer3130 and I reviewed this on a call; this is causing issues in the TVM mode. This is also an important fix that was making the browser hang so we want to keep it.
Mentioning here just so we know we need to fix it before merging

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use the viewport status instead of making this async

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems to be ok in the TVM mode now, at least I can't reproduce any hangs. I believe the issue was caused by multiple initial renders causing a loop, and the existing OHIF changes to prevent extra renders resolved the base issue.

Copy link
Member

Choose a reason for hiding this comment

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

@mateusfreira can you try again, It seems to work with tmtv now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mateusfreira - you have to try it with the merge update branch of FlexView, as it was changes outside of CS3D that fixed the hang issue.

Copy link
Member

Choose a reason for hiding this comment

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

@mateusfreira can you try and let me know?

Choose a reason for hiding this comment

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

@sedghi and @wayfarer3130 I confirmed it is working as expected
Screenshot 2023-09-07 at 12 27 46 PM

@@ -211,13 +212,20 @@ class Synchronizer {
if (targetIsSource) {
continue;
}

this._eventHandler(this, sourceViewport, targetViewport, sourceEvent);
promises.push(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know how to avoid this synchronization - the basic synchronizer design relies on being able to turn off secondary notifications so that only a single change applies, and if this doesn't use async, then you get an event from the target viewport, which changs the source viewport, which sends an event etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changes in this file fix the browser hanging issue.

Comment on lines 92 to 99
if (!registrationMatrixMat4) {
throw new Error(
`No registration matrix found for sourceViewport: ${sourceViewport.viewportId} and targetViewport: ${targetViewport.viewportId}, viewports with different frameOfReferenceUIDs must have a registration matrix in the registrationMetadataProvider. Use calculateViewportsRegistrationMatrix to calculate the matrix.`
console.log(
"Viewports still don't have registration:",
sourceViewport.viewportId,
targetViewport.viewportId
);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

this should be a throw IMO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, there are legitimate times this won't return a value, and you can't set it up to simply deny the display in the viewprot - for example, simple CR images won't have that, and may still want to default the viewport to have the stack sync on for when the HP is used for another image set.

@sedghi
Copy link
Member

sedghi commented Aug 1, 2023

can you do a git pull origin main --no-rebase ? it is showing 67 commits

Copy link

@mateusfreira mateusfreira left a comment

Choose a reason for hiding this comment

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

LGTM

@wayfarer3130 wayfarer3130 merged commit cd5efa0 into main Sep 7, 2023
@wayfarer3130 wayfarer3130 deleted the fix/image-stack-sync branch September 7, 2023 22:09
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.

3 participants