OHIF / Viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages
https://docs.ohif.org/
MIT License
3.12k stars 3.29k forks source link

[Bug] Await missing in createEmptySegmentationForViewport #4207

Open Billuc opened 3 months ago

Billuc commented 3 months ago

Describe the Bug

I am writing a function that creates a new segmentation and then performs actions on the newly created segmentation. I am calling the createEmptySegmentationForViewport command to create a new segmentation. However, when the function ends, I don't see any new segmentation:

// CREATE NEW (EMPTY) SEGMENTATION
const command = commandsManager.getCommand(
    "createEmptySegmentationForViewport",
    "SEGMENTATION",
);
await command.commandFn({ viewportId: viewportGridService.getActiveViewportId() });

console.log({...segmentationService.segmentations}); // The new segmentation isn't there

but the segmentation does appear in the UI. It appears that an async function in the createEmptySegmentationForViewport isn't awaited:

[...]
updateViewportsForSegmentationRendering({...});
// instead of await updateViewportsForSegmentationRendering({...});

Is this on purpose or is it a bug ?

Steps to Reproduce

  1. Call the createEmptySegmentationForViewport command
  2. Get the segmentations via the segmentationManager right after

The current behavior

The new segmentation isn't there because it is added in an async function that is not awaited

The expected behavior

After the call to the command, the newly created segmentation appears in the segmentationService

OS

Fedora 40 with Docker (Debian 12 Bookworm)

Node version

18.20.3

Browser

Chromium

sedghi commented 3 months ago

Yeah we should await it i guess