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

Memory leak when updating from geojson at 15Hz in 3d mode #477

Open
HeavenlyHost opened this issue Jul 18, 2017 · 7 comments
Open

Memory leak when updating from geojson at 15Hz in 3d mode #477

HeavenlyHost opened this issue Jul 18, 2017 · 7 comments

Comments

@HeavenlyHost
Copy link

HeavenlyHost commented Jul 18, 2017

So our problem is when updating a vector source with geojson, the first thing that we do is clear the source and then reload the source features from a GeoJSON object returned via a websocket. The memory leak can be catastrophic and needs to be addressed either by ol-cesium issuing a command to cesium to release resource or for cesium to be updated to correctly clean-up after itself.

To summarise, there are up to 2000 geojson points/features which require updating at 15Hz, which are being supplied over websocket NOT from file.

Original Code - on change to vectorData

        this.vectorSource.clear(); // <-- Causes Memory Leak (suspect Cesium not releasing resource)
        this.vectorSource.addFeatures((new ol.format.GeoJSON()).readFeatures(this.vectorData));

I do have a workaround but it causes a great deal of flicker on the 3d map...

Workaround (Bad flicker in 3d) - on change to vectorData

        let newVectorSource = new ol.source.Vector({
            features: [],
        });
        let newVectorLayer = new ol.layer.Vector({
            source: newVectorSource,
            style: this.styleFunction,
        });
        newVectorSource.addFeatures((new ol.format.GeoJSON()).readFeatures(this.vectorData));
        this.map.addLayer(newVectorLayer);
        this.map.removeLayer(this.vectorLayer);
        this.vectorSource = newVectorSource;
        this.vectorLayer = newVectorLayer;

My question, is there a better way to do this or do I need to live with the flicker... ???

@HeavenlyHost HeavenlyHost changed the title Memory when updating from geojson at 15Hz Memory leak when updating from geojson at 15Hz in 3d mode Jul 18, 2017
@gberaudo
Copy link
Member

The synchronization of the OpenLayers source with Cesium is done in src/vectorsynchronizer.js. Each time a feature is removed from the source, OL-Cesium gets notified and should remove the 3D primitives which are the counterparts of the 2D feature.

There may be some missing cleanup in OL-Cesium or as you said it might be in Cesium itself.

Your workaround looks good to me and is actually a good approach for data updating quickly.
Flickering (the whole globe disappears briefly) has been reported already and can be reproduced in the vector example but the cause still needs to be tracked down.

@HeavenlyHost
Copy link
Author

HeavenlyHost commented Jul 19, 2017

So is the problem with ol-cesium or cesium itself ???
Do we have an ETA on this fix ???
This is catastrophic for the end user and makes the 3d map unusable :-(

@gberaudo
Copy link
Member

Since the globe disappears, it looks like a problem in Cesium.
See http://openlayers.org/ol-cesium/examples/vectors.html and click add/remove one layer.
Also notice the first time one clicks the globe does not flicker.

Are you experiencing the same flickering?

To my knowledge no one is working on it. The steps would be:

  • reproduce the problem with a pure Cesium example;
  • create an issue on Cesium github bug tracker;
  • have a fix found and merged.

I agree it would be great if someone could take some time to dig into it.

@HeavenlyHost
Copy link
Author

ok, I have had a look at the example outlined and yes I am seeing the same problem only much worse as I am removing and adding the layer 15 times a second, hence unusable.

You say that this is already reported on Cesium, can you give me the number ???

@gberaudo
Copy link
Member

No, I said it was reported in OL-Cesium. I quickly searched for flickering issues in Cesium but none looks related to what we see.

@HeavenlyHost
Copy link
Author

Ok, so could you let me know what the number is on ol-cesium, many thanks :-)

@gberaudo
Copy link
Member

Sure, see #465.

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

2 participants