How to eliminate cesium warning Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true

Hi Friends,
I’m new to cesium, when i use this software, i always get warning in Chrome’s console: Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. I guess there could be some setting to switch it on, but don’t know how.

Anybody can help, thanks!

Thanks & Regards,
Martin.

const canvas = document.createElement(‘canvas’);
const ctx = canvas.getContext(‘2d’, {willReadFrequently: true});

Using this could possibly have a negative effect on Cesium performance. See: HTMLCanvasElement.getContext() - Web APIs | MDN
“This will force the use of a software (instead of hardware accelerated) 2D canvas and can save memory when calling getImageData() frequently.”.
It’s also debatable whether the console messages do affect Cesium performance at all, very likely performance with willReadFrequently enabled will be worse than without it.
It may be a good idea to check the performance with and without this option to make sure you’re not shooting yourself in the foot.

1 Like