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

Performance improvements with new version of GLSP and Sprotty #92

Open
planger opened this issue Feb 25, 2021 · 0 comments
Open

Performance improvements with new version of GLSP and Sprotty #92

planger opened this issue Feb 25, 2021 · 0 comments

Comments

@planger
Copy link
Contributor

planger commented Feb 25, 2021

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;
    }
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

No branches or pull requests

1 participant