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

Recover from situations where the maximum canvas size is exceeded #1928

Merged
merged 4 commits into from Apr 3, 2014

Conversation

ahocevar
Copy link
Member

@ahocevar ahocevar commented Apr 2, 2014

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.

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.
@ahocevar
Copy link
Member Author

ahocevar commented Apr 2, 2014

Pull request attached. Thanks for any review.

@@ -46,6 +46,12 @@ ol.renderer.canvas.TileLayer = function(mapRenderer, tileLayer) {

/**
* @private
* @type {boolean}
*/
this.canvasTooBig_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be initialized.

@ahocevar
Copy link
Member Author

ahocevar commented Apr 3, 2014

Pull request updated.

@elemoine
Copy link
Member

elemoine commented Apr 3, 2014

Looks good to me. Please merge when Travis build passes.

ahocevar added a commit that referenced this pull request Apr 3, 2014
Recover from situations where the maximum canvas size is exceeded
@ahocevar ahocevar merged commit 7f2a628 into openlayers:master Apr 3, 2014
@ahocevar ahocevar deleted the recover-from-canvas-too-big branch April 3, 2014 09:46
@ahocevar ahocevar mentioned this pull request Apr 5, 2014
return function(context, size) {
var x = size[0] - 1;
var y = size[1] - 1;
var originalImageData = context.getImageData(x, y, 1, 1);
Copy link
Member

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 .

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants