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

[NGRM] - In SyncLogViewer initial mount sometimes has wrong zoom when sync scale by controllers #2108

Closed
mirisb opened this issue Jun 18, 2024 · 2 comments
Labels
bug Something isn't working well-log-viewer

Comments

@mirisb
Copy link
Collaborator

mirisb commented Jun 18, 2024

While mounting the component we fetch data from server which takes some. while the data is being fetched we first pass an empty log in the props:

const emptyLog : WellLog = {
      header: { startIndex: 0, endIndex: 1, step: 1 },
      curves: [
        {
          name: "MD",
          unit: "m",
          dimensions: 1,
        },
        {
          name: "Empty",
        },
      ],
      data: [
        [0, null],
        [1, null],
      ],
    };

Once fetching from server is complete the props are replaced with the real props that contain real logs from several wells.

We sync scales between different controllers in SLV using onContentRescale callback from the component (usually this function is only called when use flattening and want to apply our own logic for track positioning):

   const onContentRescale = React.useCallback(
     (iView: number) => {
       if (controllers.length <= iView) {
         return;
       }

       // we want to mantain the same aspect ratio - thus we take the scale from the affected well and apply it to all the wells
       const scale = controllers[iView].getContentScale();
       if (!isFinite(scale)) {
         return;
       }

       controllers.forEach(controller => {
         if (controller == controllers[iView]) {
           return; // skip controller which caused the onContentRescale
         }
        controller.setContentScale(scale);
       });
    },
    [controllers]
  );

The problem occurs when sometimes when calling controller.setContentScale we get the correct scale however the zoom itself is calculated according to the size of the overlay, in function getContentBaseScale () in WellLogView.ts (in Webviz codebase). When this function is called, the overlay has not yet become visible, its size not yet calculated and it contains a bogus height which causes it to give wrong results which leads to calculation of wrong zoom.

image

This is easily recreated in Viz storybook by mounting story "Two Wells Same Log" and after it is mounted correctly switch to story "Two Wells Different Log". Since this bug depends on timing and fetching data from server, to recreate the storybook must be reloaded from scratch to clear caches.

@mirisb
Copy link
Collaborator Author

mirisb commented Jun 19, 2024

@Vladimir-Kokin , maybe a solution would be to add a query to the controller to make sure that it is fully rendered.

In debugger I was able to display the overlay and see that it is not visible:
image

If the controller has a query function to make sure it is rendered, we could test it before trying to change the scale...

@mirisb
Copy link
Collaborator Author

mirisb commented Jul 25, 2024

This seems to have been fixed by #2114

@mirisb mirisb closed this as completed Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working well-log-viewer
Projects
None yet
Development

No branches or pull requests

2 participants