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

Bug - iOS (Safari) runaway memory issue when panning while zoomed on single image #952

Closed
plougsgaard opened this issue Jun 4, 2016 · 10 comments · Fixed by #966
Closed
Labels
Milestone

Comments

@plougsgaard
Copy link
Contributor

I'm experiencing a major memory issue. It only happens when I'm zoomed in to a certain point though, and only on physical iOS devices.

I'd love to hear if anyone's having similar issues or have any ideas as to what might be wrong here. Also ideas to workarounds if it's not feasible to diagnose.

Steps

  1. Zoom in on the image (far enough, does not happen when only zoomed in.. eh.. some)
  2. Pan around
  3. Crash

Setup

  • Runs in within a Cordova app
  • iOS 9.3 (same on 3 different test devices)
    • Does not occur on Android
    • Also does not occur when running the same code through the various iOS simulators

Config

OpenSeadragon({
      id: 'seadragon-viewer',
      tileSources: {
        type: 'legacy-image-pyramid',
        levels: [{
          url: 'http://example.com/example.jpeg',
          height: 1938,
          width: 984
        }]
      },
      showNavigationControl: false,
      animationTime: 0.2,
      visibilityRatio: 1.0,
      gestureSettingsTouch: {
        pinchRotate: false,
        flickMomentum: 0,
        dblClickToZoom: false
      },
      maxZoomPixelRatio: 2.0,
      minZoomPixelRatio: 10.0,
      springStiffness: 4.5,
      viewportMargins: {
         left: deviceDimensions.clientWidth * 0.2,
         top: deviceDimensions.clientHeight * 0.1,
         right: deviceDimensions.clientWidth * 0.2,
         bottom: deviceDimensions.clientHeight * 0.1
      }
    })

Measurements

screen shot 2016-06-04 at 11 36 05

## Profiling

screen shot 2016-06-04 at 11 48 58

The QuartzCore behaves normally and allocates very little memory each time before suddenly jumping to 11.16MiB several times in the span of a few milliseconds.

@plougsgaard plougsgaard changed the title Bug - iOS runaway memory issue when panning while zoomed on single image Bug - iOS (Safari) runaway memory issue when panning while zoomed on single image Jun 6, 2016
@nordved
Copy link

nordved commented Jun 6, 2016

This is also an issue when browsing https://openseadragon.github.io/ on an IOS device. If zoomed in to some level, the memory usage spikes and the page reloads because of an error.

@iangilman
Copy link
Member

This is unfortunate! I don't know what would be causing it.

Are you using a single-tile LegacyTileSource in your actual code? I'd be curious to know if the same issue occurs with the ImageTileSource as well. For that matter, if you have any other kinds of images, like a DZI, that you could try, it would be interesting to know if they all behave the same.

I wouldn't think the single-tile LegacyTileSource would be a problem; it should just load that one image (and of course the canvas for drawing) and that should be all the memory allocation necessary.

I don't know that much about iOS Safari under the hood, but if you're seeing the memory allocation in QuartzCore, I suppose that implies that it has something to do with graphics processing. Maybe there's something iOS does when scaling an image after a certain point.

Hmm, another possibility is that now as of 2.2.0 we do an additional scaling step when we get over 1.1 times the actual pixels. Try using smoothTileEdgesMinZoom: Infinity in your options and see if that has an effect.

@iangilman iangilman added the bug label Jun 6, 2016
@iangilman
Copy link
Member

Hmm, if it's happening with https://openseadragon.github.io/ I suppose that answers some of my questions...that image is a DZI. Also, the maxZoomPixelRatio is 1.1, the same as smoothTileEdgesMinZoom, which should disable the smoothing.

That said, it might still be worth experimenting along some of those lines.

@iangilman
Copy link
Member

FWIW, I too can reproduce this on https://openseadragon.github.io/ on both iPhone and iPad with iOS 9.3.2. This must be new behavior as I've certainly zoomed and panned on that page on those devices in the past. It's unclear whether it's a change in iOS or in OSD that caused it.

@plougsgaard
Copy link
Contributor Author

I just had a chance to try out an iOS 8.1.2 device - which also crashes.

Supposing it's down to an error introduced in OSD at this point. :-)

@iangilman
Copy link
Member

Sounds like it! Well, one option would be to go back and try 2.1.0 and see if it's present there. Could even go for a different commits between 2.1.0 and 2.2.0 to isolate when the change happened.

@plougsgaard
Copy link
Contributor Author

plougsgaard commented Jun 15, 2016

@iangilman I found the culprit! - 8c4fcc9 - after some git bisect action testing with the overlay.html demo page.

This commit turns on when the zoom is greater than smoothTileEdgesMinZoom, so setting it to Infinity simply turns off that commit.

Edit: just like you eluded to in your first comment I suppose!

@iangilman
Copy link
Member

Beautiful! And you've verified that setting it to Infinity fixes the issue in 2.2.0? Well, probably the thing to do is have OSD forcibly disable that feature on iOS (or maybe all mobile). Would you be up for making a patch for this?

@iangilman iangilman added this to the 2.2.1 milestone Jun 15, 2016
@plougsgaard
Copy link
Contributor Author

I can take a stab at this later sure!

Thinking the structure is something like disabling the feature from 8c4fcc9 conditioned on browser sniffing for something that looks like an iOS device.

To your question, yes, I've verified setting it to Infinity fixes the issue in 2.2.0 - for all my available test devices. To that end I'm pretty confident.

@iangilman
Copy link
Member

Sounds good. Thank you for tracking it down! I look forward to the patch when you can get to it.

@MindFreeze FYI, it appears #764 causes problems on iOS; see above.

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

Successfully merging a pull request may close this issue.

3 participants