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 visualisation FRP bugs. #6831

Merged

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented May 24, 2023

Pull Request Description

Fixes

Peek.2023-05-22.15-17.mp4
Peek.2023-05-25.12-52.mp4
Peek.2023-05-25.12-55.mp4
  • Redundant internal open/lose events caused by logic loops around the show/hide button, as well as many redundant layer setting/unsetting issues internal to the visualization code.

Generally improves the logic around the visualization API by avoiding decentralized logic in different places and removing old code that is no longer needed.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@MichaelMauderer MichaelMauderer self-assigned this May 24, 2023
@MichaelMauderer MichaelMauderer force-pushed the wip/MichaelMauderer/Visualisation_FRP_Refactoring_And_Bugfixes branch from 411b592 to 2846934 Compare May 24, 2023 13:06
…as well as some other undiscovered issues around the order of events that arrive at the visualisation container.
@MichaelMauderer MichaelMauderer force-pushed the wip/MichaelMauderer/Visualisation_FRP_Refactoring_And_Bugfixes branch from 2846934 to ea162d3 Compare May 25, 2023 11:58
@MichaelMauderer MichaelMauderer added the CI: No changelog needed Do not require a changelog entry for this PR. label May 25, 2023
@MichaelMauderer MichaelMauderer marked this pull request as ready for review May 25, 2023 11:58
/// Indicates the visibility state of the visualisation.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ViewState {
/// Visualisation is permanently enabled and visible in thw graph editor. It is attached to a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Visualisation is permanently enabled and visible in thw graph editor. It is attached to a
/// Visualisation is permanently enabled and visible in the graph editor. It is attached to a

Comment on lines 153 to 157
impl Default for ViewState {
fn default() -> Self {
ViewState::Disabled
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Derivable.

Comment on lines 162 to 169
pub fn visible(&self) -> bool {
!matches!(self, ViewState::Disabled)
}

/// Indicates whether the visualisation is fullscreen mode.
pub fn is_fullscreen(&self) -> bool {
matches!(self, ViewState::Fullscreen)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent is_

Copy link
Contributor

@farmaazon farmaazon left a comment

Choose a reason for hiding this comment

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

The code looks good, with some comments below. But I'm worried we have regressions in displaying errors (the visualization should be hidden on error). Should be checked during QA.

Comment on lines 2 to 3
//! a visualisation int he graph editor and includes a visual box that contains the visualisaiton,
//! a action bar that allows setting the visualisation type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//! a visualisation int he graph editor and includes a visual box that contains the visualisaiton,
//! a action bar that allows setting the visualisation type.
//! a visualisation in the graph editor and includes a visual box that contains the visualisaiton,
//! and the action bar that allows setting the visualisation type.

Comment on lines 7 to 8
//! is correctly positioned, sized and layouted in its different `ViewState`s (which include the
//! `Enabled`, `Fullscreen` and `Preview` states). Importantly, this also includes layer management
Copy link
Contributor

Choose a reason for hiding this comment

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

You can put ViewState in [] ([ViewState]) making them link to the structure; then I think it's not necessary to list enum variants.

Comment on lines 8 to 9
//! `Enabled`, `Fullscreen` and `Preview` states). Importantly, this also includes layer management
//! and ensuring that the visualisation is correctly layered with respect to other scene objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand the "layer management". Does visualization create new layers? What "correct layering" means? Is visualization split into layers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is about EnsoGL layers and management of occlusion. I clarified this now.

Enabled,
/// Visualisation is disabled and hidden in the graph editor.
Disabled,
/// Visualisation is temporarily enabled and visible in the graph editor. It should be placed
Copy link
Contributor

Choose a reason for hiding this comment

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

Is any difference between "enabled" and "visible"? Before, "enabled" meant that the visualization "eye" was toggled on. Visualization could be visible and not enabled (in case of Preview) and enabled but not visible (if there's error on the node - I think we miss that variant here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is now decoupled; thus, the visualization is either visible or not. While the button's state is managed independently. I will double-check the button has the correct state during preview.

Some(visualization::Registry::default_visualisation())
});
vis_input_type <- frp.set_vis_input_type.on_change();
vis_input_type <- input.set_vis_input_type.on_change();
vis_input_type <- vis_input_type.gate(&visualisation_uninitialised).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's an older code, but the name is bad, as it says nothing about the type being updated only when visualization is uninitialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the naming. But it does get a bit verbose.

Comment on lines 573 to 574
visualisation_uninitialised <- input.set_visualization.map(|t| t.is_none());
input_type_uninitialised <- input.set_vis_input_type.is_some().not();
Copy link
Contributor

Choose a reason for hiding this comment

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

The name "visualization_uninitialized" is a bit unfortunate. I think "non-chosen" says better what it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the naming.

Comment on lines 394 to 396
has_selection <- visualization_chooser.chosen_entry.is_some();
frp.source.visualisation_selection
<+ visualization_chooser.chosen_entry.gate(&has_selection);
Copy link
Contributor

Choose a reason for hiding this comment

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

.filter_map(|entry| *entry) does it in one line. And I use it a lot - maybe we could make filter_some node?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think .unwrap() already does exactly that.

Copy link
Member

@wdanilo wdanilo left a comment

Choose a reason for hiding this comment

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

Amazing that it's here! Skipping my code review seeing code reviews of Kaz and Adam :)

@vitvakatu
Copy link
Contributor

QA Report 🔴

Most importantly, error visualization is indeed affected, as @farmaazon noticed in his review.

Hovering the output with the mouse displays both the error message and a visualization. Switching visualization with the icon doesn't work, but using space or shift-space shortcuts toggles it.

2023-05-31.12-36-42.mp4

Also, I noticed that on complex projects a lot of visualizations disappear after loading. For example, for COVID project on my machine:

2023-05-31.12-31-51.mp4

@MichaelMauderer
Copy link
Contributor Author

MichaelMauderer commented Jun 1, 2023

Most importantly, error visualization is indeed affected, as @farmaazon noticed in his review.

This should now be fixed.

Also, I noticed that on complex projects a lot of visualizations disappear after loading. For example, for COVID project on my machine:

I can reproduce this also on develop and this seems to be #6724.

@vitvakatu
Copy link
Contributor

@MichaelMauderer shift-tab hotkey still opens fullscreen vis on a node with error. Is this intentional?

@MichaelMauderer
Copy link
Contributor Author

@MichaelMauderer shift-tab hotkey still opens fullscreen vis on a node with error. Is this intentional?

I think that does not make sense, even if it works like that on develop. So, it is fixed now to stop the empty vis from opening.

@vitvakatu
Copy link
Contributor

QA: passed 🟢

@MichaelMauderer MichaelMauderer added CI: Ready to merge This PR is eligible for automatic merge CI: Keep up to date Automatically update this PR to the latest develop. and removed CI: Keep up to date Automatically update this PR to the latest develop. labels Jun 2, 2023
@mergify mergify bot merged commit 72b202b into develop Jun 5, 2023
@mergify mergify bot deleted the wip/MichaelMauderer/Visualisation_FRP_Refactoring_And_Bugfixes branch June 5, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
6 participants