Hello,
We recently ran into a pretty interesting issue with camera events. If your position is lat=0, lon=0 or close, you have a top down view, and the targetFrameRate is low (like 20), you’ll have an infinite loop of camera.moveStart and camera.moveEnd events. We depend on these events for some of our features, and it causes performance issues at the end.
We managed to simulate this behaviour in the Cesium Sandcastle:
Please advise, how this can be fixed or any workaround. Thank you.
Hi @Alexandr23, welcome to the community!
Those moveStart
and moveEnd
events are fired from View.prototype.checkForCameraUpdates
.
I don’t fully understand why it gets into an infinite loop in your case. However, I found one workaround: set Scene.cameraEventWaitTime
to a larger value, like 2000. Please see this updated Sandcastle and let us know if it works for you.
Note that cameraEventWaitTime
is not part of the public API, so this fix is not guaranteed to work in future versions of CesiumJS.
Hi @jjhembd, thank you for your quick response!
Your workaround works, but apparently delays the camera moveEnd significantly.
Should I raise an issue in the CesiumJS repository to resolve it properly?
Hi @Alexandr23, thanks for the followup. Yes, an issue in the repository is appropriate. Thanks for bringing this to our attention!
I got this issue too. I’m also using a top-down view, but in my case it is not related to the location or the frame rate. It happens randomly on rare occasions after panning or zooming, where an infinite (or very long) sequence of moveStart and moveEnd events is raised. If you check the values of camera.positionCartographic.height
and camera.computeViewRectangle()
after every event you can see that they are not changing, so the camera is not moving but these events are being raised anyways. I also noticed that this sequence of events can be stopped if you pan or zoom again. My workaround was to create my own events and only raise them if the camera height and the computed rectangle change