From 33b3fc93803d363456c54871984be9a38690f02f Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Mon, 23 Jan 2017 15:25:03 -0800 Subject: [PATCH] Restore "MAX_RENDERBUFFER_SIZE" check as a warning rather than an error (#4037) * Restore "MAX_RENDERBUFFER_SIZE" check as a warning rather than an error This sorta reverts commit 630d98c7ec2574fb769e2c96b9fd964f05e9a613. * Move test to Map#resize --- js/ui/map.js | 9 +++++++++ test/js/ui/map.test.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/js/ui/map.js b/js/ui/map.js index b11a742c005..e32f1d782dd 100755 --- a/js/ui/map.js +++ b/js/ui/map.js @@ -346,6 +346,15 @@ class Map extends Camera { this.transform.resize(width, height); this.painter.resize(width, height); + const gl = this.painter.gl; + const maxSize = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) / 2; + if (this._canvas.width > maxSize || this._canvas.height > maxSize) { + util.warnOnce( + `Map is larger than maximum size supported by this system ` + + `(${maxSize}px by ${maxSize}px).` + ); + } + return this .fire('movestart') .fire('move') diff --git a/test/js/ui/map.test.js b/test/js/ui/map.test.js index 9ccb5279eba..9c4783f0337 100755 --- a/test/js/ui/map.test.js +++ b/test/js/ui/map.test.js @@ -62,6 +62,23 @@ test('Map', (t) => { container: 'anElementIdWhichDoesNotExistInTheDocument' }); }, new Error("Container 'anElementIdWhichDoesNotExistInTheDocument' not found"), 'throws on invalid map container id'); + + t.end(); + }); + + t.test('constructor, max size detection', (t) => { + t.stub(console, 'warn'); + + const container = window.document.createElement('div'); + container.offsetWidth = 10000; + container.offsetHeight = 10000; + new Map({container}); + + t.match( + console.warn.getCall(0).args[0], + /Map is larger than maximum size supported by this system \([0-9]+px by [0-9]+px\)./ + ); + t.end(); });