App crashes when trying to display three panoramic photos on one screen

eoLithic

So, it's a fairly simple question. I have a screen which has a button. Every time a user taps the button we let the user to pick a panoramic photo from his Photos, and add a UIImageView that displays the panoramic photo. Each UIImageView has a frame ~375x150 points(to show panoramic photo completely on iPhone 6).
The problem is that when we add second UIImageView we receive an error in NSLog: "Connection to assetsd was interrupted or assetsd died". Plus, we get slight UI 'freezes'. But UIImageView displays the second photo and we're absolutely okay.
And when we add third UIImageView the app simply crashes and Xcode displays "Lost connection to "Admin's iPhone 6"."
Considering panoramic photo resolutions (~13600x~3000) it's completely understandable why the app crashes and has UI freezes. The question is: is there anyway (except simply compressing the photo and showing the resized version on the screen) to show a lot of panoramic photos without lags? Looking at the Photos app, it displays panoramic photos without any bugs and doesn't have any UI freezes.

dandan78

Your question is desceptively simple. You are right, the size of your images means that your app is grappling with memory issues. You're passing a huge image to a UIImageView and hoping it will take care of everything for you. It won't, not with that much data.

The way the built-in Photos app gets around this is by using a technique called tiling, combined with resizing. It works something like this:

  1. Initially, it displays a scaled-down version of the panarama.
  2. When you begin to zoom in, it gets the coordinates of your fingers, calculates where they are relative to the full-sized image.
  3. Then it calculates what parts its needs to grab from the full-size image, gets that at full resolusion, then scales and displays just that part. Continued zooming consequently takes a mere fraction of the memory that would be needed for the full-size image.
  4. At the same time, it calculates rectangles of screen size for the surrounding area and keeps them ready for when you decide to pan, but obviously not at full resolution.
  5. As you continue to scroll/zoom, the process is repeated.

Google around, you might be able to find a library that takes care of that for you, and I think there even might have been an example from Apple (see this question). Otherwise, it's an interesting learning experience to write it yourself.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android new Photos app crashes when trying to edit a picture after using the camera

From Dev

Application crashes when it trying to display Toast

From Dev

ios app crashes when screen is touched

From Dev

App crashes when trying to implement multilingual support

From Dev

App crashes when trying to show AlertDialog in thread

From Dev

Meteor app crashes when trying to populate collections

From Dev

App crashes when trying to fullscreen activity

From Dev

App crashes when trying to record audio

From Dev

App crashes when trying to open a fragment with listview

From Dev

App crashes when trying to start a new activity

From Dev

App crashes when trying to connect to Neura service

From Dev

App crashes when trying to save to SQLite database

From Dev

IllegalStateException when trying selecting photo from Google Photos app

From Dev

How can IOS Photos app can show hundreds of photos in one screen?

From Dev

App Crashes When Switching from Splash Screen to MainActivity

From Dev

android: app stops and then crashes when the screen goes off

From Dev

Photo app does not display photos

From Dev

App crashes when trying to add a row into table by pressing a button

From Dev

Visual Studio crashes when trying to associate Cordova app with store

From Dev

App crashes when nothing is entered in the TextBoxes I'm trying to parse

From Dev

App crashes when trying to access a viewcontroller from AppDelegate

From Dev

App crashes when trying to capture video using a camera intent

From Dev

My Android app crashes when trying to store SQLite data

From Dev

App crashes when trying to access array Android SDK

From Dev

Instagram crashes when my android app trying post on it using intent

From Dev

App crashes when nothing is entered in the TextBoxes I'm trying to parse

From Dev

App crashes when trying to connect to SignalR server after disconnecting it

From Dev

App Crashes When Trying to Set Wallpaper as Activity Background

From Dev

App crashes when trying to reuse toolbar by extending custom activity

Related Related

  1. 1

    Android new Photos app crashes when trying to edit a picture after using the camera

  2. 2

    Application crashes when it trying to display Toast

  3. 3

    ios app crashes when screen is touched

  4. 4

    App crashes when trying to implement multilingual support

  5. 5

    App crashes when trying to show AlertDialog in thread

  6. 6

    Meteor app crashes when trying to populate collections

  7. 7

    App crashes when trying to fullscreen activity

  8. 8

    App crashes when trying to record audio

  9. 9

    App crashes when trying to open a fragment with listview

  10. 10

    App crashes when trying to start a new activity

  11. 11

    App crashes when trying to connect to Neura service

  12. 12

    App crashes when trying to save to SQLite database

  13. 13

    IllegalStateException when trying selecting photo from Google Photos app

  14. 14

    How can IOS Photos app can show hundreds of photos in one screen?

  15. 15

    App Crashes When Switching from Splash Screen to MainActivity

  16. 16

    android: app stops and then crashes when the screen goes off

  17. 17

    Photo app does not display photos

  18. 18

    App crashes when trying to add a row into table by pressing a button

  19. 19

    Visual Studio crashes when trying to associate Cordova app with store

  20. 20

    App crashes when nothing is entered in the TextBoxes I'm trying to parse

  21. 21

    App crashes when trying to access a viewcontroller from AppDelegate

  22. 22

    App crashes when trying to capture video using a camera intent

  23. 23

    My Android app crashes when trying to store SQLite data

  24. 24

    App crashes when trying to access array Android SDK

  25. 25

    Instagram crashes when my android app trying post on it using intent

  26. 26

    App crashes when nothing is entered in the TextBoxes I'm trying to parse

  27. 27

    App crashes when trying to connect to SignalR server after disconnecting it

  28. 28

    App Crashes When Trying to Set Wallpaper as Activity Background

  29. 29

    App crashes when trying to reuse toolbar by extending custom activity

HotTag

Archive