Skip to content

Performance improvements with new version of GLSP and Sprotty #92

Description

@planger

In order to improve performance, Sprotty introduced a mechanism that allows to check whether a model element is actually visible in the current viewport and, depending on visibility, should be rendered or not.
eclipse-sprotty/sprotty@e74b908
Preventing the rendering for model elements that aren't visible anyway for sure has a positive impact on performance. So the visibility should also be considered in Ecore's view renderings, once upgraded to the latest version of GLSP and Sprotty.

In addition, consider to skip rendering of certain detail elements if the zoom level is very low (ie zoomed out a lot). With that also the performance in showing very large diagrams from a very far perspective can be significantly improved by avoiding to render e.g. attributes or edges, if they won't be readable due to the zoom factor anyway. The zoom factor can easily be determined with the following code. Also in another project we've increased the font size of class titles based on the zoom factor to keep the important details (such as the title of an EClass) readable even if zoomed out a lot.

   const textStyle = { fontSize: `${this.computeNormalizedFontSize(node)}pt` };

   ...
   <text style={textStyle} ... />
   ...

    protected computeNormalizedFontSize(node: Readonly<SChildElement>) {
        const viewPort = findParentByFeature(node, isViewport);
        const zoomFactor = viewPort ? viewPort.zoom : 1;
        const minSize = 5;
        const maxSize = 20;
        const normalizedFontSize = Math.max(Math.min(10 / zoomFactor, maxSize), minSize);
        return normalizedFontSize;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions