-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Recover from situations where the maximum canvas size is exceeded #1928
Recover from situations where the maximum canvas size is exceeded #1928
Conversation
This is a way to detect whether a canvas exceeds the maximum dimensions if these are limited on the target device. See https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html for limitations on iOS devices.
For performance reason, we only make the canvas bigger, but not smaller. With this change, we also make it smaller, but only when we know that its current size exceeds the maximum dimensions.
Pull request attached. Thanks for any review. |
@@ -46,6 +46,12 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) { | |||
|
|||
/** | |||
* @private | |||
* @type {boolean} | |||
*/ | |||
this.canvasTooBig_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be initialized.
Pull request updated. |
Looks good to me. Please merge when Travis build passes. |
Recover from situations where the maximum canvas size is exceeded
return function(context, size) { | ||
var x = size[0] - 1; | ||
var y = size[1] - 1; | ||
var originalImageData = context.getImageData(x, y, 1, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this will raise security errors if not same origin or appropriate header .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. So we'll need to test the size with a canvas only made for that purpose. I'll create a pull request.
Eventually we will need a better solution than this workaround anyway, since most HiDPI devices have a limitation in canvas size that we run into.
On HiDPI devices or displays with very high resolutions, it can happen that zooming or rotating the map exceeds the maximum possible canvas size. In such cases (at least on iPads), the map completely disappears and cannot be brought back. Until we have a better fix (e.g. canvas tiles or stripes instead of a single canvas), at least after zooming or resetting the rotation, the map should be visible again.
See https://groups.google.com/d/msg/ol3-dev/ydA_0uW7F7Q/pA4JAwCXB28J for more details on this problem.