Skip to content

Commit

Permalink
Restore "MAX_RENDERBUFFER_SIZE" check as a warning rather than an err…
Browse files Browse the repository at this point in the history
…or (#4037)

* Restore "MAX_RENDERBUFFER_SIZE" check as a warning rather than an error

This sorta reverts commit 630d98c.

* Move test to Map#resize
  • Loading branch information
lucaswoj authored Jan 23, 2017
1 parent 2793b42 commit 33b3fc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
17 changes: 17 additions & 0 deletions test/js/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit 33b3fc9

Please sign in to comment.