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

openlayers performance #15850

Open
nipeone opened this issue May 21, 2024 · 17 comments
Open

openlayers performance #15850

nipeone opened this issue May 21, 2024 · 17 comments

Comments

@nipeone
Copy link

nipeone commented May 21, 2024

Using openlayers and geojs to display 90,000 features, when zooming or panning, the openlayers will lag for 1~2 seconds, but geojs works smoothly. Is the usage of openlayers not correct?
Here is my reference code:https://github.com/nipeone/geojs_vs_openlayers

@behoney
Copy link
Contributor

behoney commented May 21, 2024

Performance might be improved by setting renderBuffer to recommended value(the size of the largest symbol, line width or label; default is 100)

@ahocevar
Copy link
Member

Another option is to use an ImageVector layer instead of a Vector layer.

@nipeone
Copy link
Author

nipeone commented May 21, 2024

Another option is to use an ImageVector layer instead of a Vector layer.

Thanks for your reply, do you mean the class ol.layer.VectorImage? I am using this class and it does perform better than ol.layer.Vector. But still not as good as geojs performance.

@nipeone
Copy link
Author

nipeone commented May 21, 2024

@ahocevar Thanks for ur reply, i tried increasing the renderBuffer to 90,000, as same as number of my features, but I doesn't feel like the effect is improving.

@ahocevar
Copy link
Member

@nipeone I don't think the renderBuffer advice applies here.

@ahocevar
Copy link
Member

@nipeone If you want to use the WebGL renderer (which might improve performance), you need to write different code. See e.g. https://openlayers.org/en/latest/examples/webgl-vector-layer.html. Looks like what you have now comes from an OpenLayers v3 example.

@nipeone
Copy link
Author

nipeone commented May 21, 2024

@nipeone If you want to use the WebGL renderer (which might improve performance), you need to write different code. See e.g. https://openlayers.org/en/latest/examples/webgl-vector-layer.html. Looks like what you have now comes from an OpenLayers v3 example.

@ahocevar Thanks again, performance improves dramatically with the above example, but if increase the number of features to 360000, an error will be reported like this: RangeError: Invalid array length

@jia-mx
Copy link

jia-mx commented May 24, 2024

@nipeone If you want to use the WebGL renderer (which might improve performance), you need to write different code. See e.g. https://openlayers.org/en/latest/examples/webgl-vector-layer.html. Looks like what you have now comes from an OpenLayers v3 example.

When using WebGLLayer to render massive vector features, zooming or moving the map causes the memory to increase sharply until the web page crashes. In which version can this problem be solved?

@nipeone
Copy link
Author

nipeone commented May 24, 2024

@jia-mx you can try my example code, i did not test max limitation, when len(features)=90000, everything is ok.if len(features)=360000 will report error

@jia-mx
Copy link

jia-mx commented May 25, 2024

@jia-mx you can try my example code, i did not test max limitation, when len(features)=90000, everything is ok.if len(features)=360000 will report error

@nipeone Your example has the same problem. Continuously zooming or moving the map will cause memory to increase dramatically until the page crashes. @ahocevar In which version can this problem be solved?

@ahocevar
Copy link
Member

This is something for @jahow to answer.

@nipeone
Copy link
Author

nipeone commented May 27, 2024

@ahocevar is there an interface to free memory after panning and zooming? I'm not sure about the memory management rules of openlayers, from the phenomenon, it should be caused by not releasing the memory in time after each pan and zoom.

@ohe1013
Copy link

ohe1013 commented May 27, 2024

When uploading shp of a file of about 12 MB to the webgl layer using the WebGLVectorLayerRenderer (the feature is about 5000 multipolygons), a rangeerror invalid array length occurs.

@ohe1013
Copy link

ohe1013 commented May 28, 2024

When uploading shp of a file of about 12 MB to the webgl layer using the WebGLVectorLayerRenderer (the feature is about 5000 multipolygons), a rangeerror invalid array length occurs.

oh my... I solved it simply with VectorImageLayer. thank you

@ahocevar
Copy link
Member

For WebGL, @jahow should be able to help.

@furylee
Copy link

furylee commented May 28, 2024

老哥不会是长沙腾讯的吧

@jahow
Copy link
Contributor

jahow commented May 28, 2024

Unfortunately there are still unsolved issues regarding memory consumption with the WebGL vector renderer, I'm sorry for not having a better answer to that :/

Also 360k features sounds like it might be too much for the renderer at that time to be honest. You might want to look into using vector tiles to achieve btter results.

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

No branches or pull requests

7 participants