Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore "MAX_RENDERBUFFER_SIZE" check as a warning rather than an error #4037

Merged
merged 2 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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