RangeError: Invalid array length when connect external monitor

We are consistently seeing an issue in which Cesium crashes when plugging in an external monitor. I am using Chrome 42.0.2311.135 (64-bit) on MacOS 10.9.5. It also occurs in Windows and other browsers.

The error report is as follows:
An error occurred while rendering. Rendering has stopped.
undefined
RangeError: Invalid array length
RangeError: Invalid array length
    at K (http://localhost:3000/vendor/cesium/Cesium.js:456:24374)
    at et (http://localhost:3000/vendor/cesium/Cesium.js:456:26223)
    at dt (http://localhost:3000/vendor/cesium/Cesium.js:456:31194)
    at vt.render (http://localhost:3000/vendor/cesium/Cesium.js:457:4984)
    at P.render (http://localhost:3000/vendor/cesium/Cesium.js:462:5471)
    at t (http://localhost:3000/vendor/cesium/Cesium.js:461:31242)P.showErrorPanel @ Cesium.js:462(anonymous function) @ Cesium.js:462r.raiseEvent @ Cesium.js:417vt.render @ Cesium.js:457P.render @ Cesium.js:462t @ Cesium.js:461
4Cesium.js:456 Uncaught RangeError: Invalid array lengthK @ Cesium.js:456et @ Cesium.js:456vt.pick @ Cesium.js:457vt.drillPick @ Cesium.js:457drillPick @ cesium.adapter.js:272drillPickPrimitive @ cesium.adapter.js:267pickAndCallListeners @ map.events.js:146(anonymous function) @ map.events.js:103
(index):1 WebGL: INVALID_OPERATION: loseContext: context already lost
4Cesium.js:456 Uncaught RangeError: Invalid array length

The RangeError occurs in 3D mode. When in 2D mode and plugging in an external monitor, we get the following error when using CesiumUnminified.

An error occurred while rendering. Rendering has stopped.
undefined
DeveloperError: drawingBufferDimensions.x must be greater than zero.
Error
    at new DeveloperError (http://localhost:3000/vendor/cesium/Cesium.js:1282:19)
    at OrthographicFrustum.getPixelSize (http://localhost:3000/vendor/cesium/Cesium.js:133980:19)
    at updateBoundingVolume (http://localhost:3000/vendor/cesium/Cesium.js:66406:33)
    at BillboardCollection.update (http://localhost:3000/vendor/cesium/Cesium.js:66591:9)
    at PrimitiveCollection.update (http://localhost:3000/vendor/cesium/Cesium.js:134977:27)
    at updatePrimitives (http://localhost:3000/vendor/cesium/Cesium.js:140351:27)
    at render (http://localhost:3000/vendor/cesium/Cesium.js:140404:9)
    at Scene.render (http://localhost:3000/vendor/cesium/Cesium.js:140445:13)
    at CesiumWidget.render (http://localhost:3000/vendor/cesium/Cesium.js:149817:25)
    at render (http://localhost:3000/vendor/cesium/Cesium.js:149237:32)CesiumWidget.showErrorPanel @ Cesium.js:149771(anonymous function) @ Cesium.js:149500Event.raiseEvent @ Cesium.js:4524Scene.render @ Cesium.js:140447CesiumWidget.render @ Cesium.js:149817render @ Cesium.js:149237
3Cesium.js:133980 Uncaught DeveloperError: drawingBufferDimensions.x must be greater than zero.
Error
    at new DeveloperError (http://localhost:3000/vendor/cesium/Cesium.js:1282:19)
    at OrthographicFrustum.getPixelSize (http://localhost:3000/vendor/cesium/Cesium.js:133980:19)
    at getPickOrthographicCullingVolume (http://localhost:3000/vendor/cesium/Cesium.js:140498:33)
    at getPickCullingVolume (http://localhost:3000/vendor/cesium/Cesium.js:140550:20)
    at Scene.pick (http://localhost:3000/vendor/cesium/Cesium.js:140590:36)
    at Scene.drillPick (http://localhost:3000/vendor/cesium/Cesium.js:140638:33)
    at drillPick (http://localhost:3000/bundle.js:38835:34)
    at Object.drillPickPrimitive (http://localhost:3000/bundle.js:38830:17)
    at pickAndCallListeners (http://localhost:3000/bundle.js:39444:41)
    at http://localhost:3000/bundle.js:39401:18

It looks like this may be a known issue: https://groups.google.com/forum/#!topic/cesium-dev/hQD6egAKU5U Are there any updates or workarounds? I'm curious why we don't get a DeveloperError in 3D mode with an external monitor with CesiumUnminified.

Is this only happening when you are mid application and plug in the external monitor or does this happen when you have multiple monitors on before loading your application?

It happens when the application has already been loaded then an external monitor is plugged in. Using multiple monitors while running the application is no problem as long as they were hooked up before the app was loaded.

Its definitely is a browser issue, it’s destroying the canvas context and not reinitializing it when the new monitor is connected. I’m not sure if it’s something that Cesium can ever actually prevent from happening due to browser limitations. I’ll ask the team though to see if they have any ideas on this.

This is still the same issue as https://groups.google.com/forum/#!msg/cesium-dev/hQD6egAKU5U/Z-KhKJ8jOsYJ.

There is no feasible way for Cesium to auto-recover for you. How you can handle this yourself would be to add an event handler for the webglcontextlost (https://www.khronos.org/webgl/wiki/HandlingContextLost). That method can capture some application state information, destroy the current Cesium instance and initialized the application back to the same place it was before.

Sorry for the necro-thread, but I was wondering if there are any other common external events that would cause context loss like this. I am seeing the exact same problem (both in 2D and 3D) using Cesium 1.20 on Windows 10 using Chrome.

Is the advice from 2015 still valid here? What else could cause context loss, we aren't switching monitors but we are seeing a pop-up command window coincident with the context loss.

Thanks,
Nick