Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11034

Camera.getPicture -Handle of OutOfMemoryError gracefully

    XMLWordPrintableJSON

Details

    Description

      We have an app for which we are dependent on using DATA_URL.

      On some older phones (Samsung SII Android 4.1), we have experienced sporadic OutOfMemoryError exceptions when taking a picture.

      When this occurs the app crashes since the camera plugin doesn't explicitly handle the java.lang.OutOfMemoryError which is thrown.

      It's ok that the OutOfMemoryError appear, but the apps should be able to handle it gracefully and not just have the app crash.

      Example stack trace from an uncaught OutOfMemoryError

      04-06 09:51:55.155: E/dalvikvm-heap(22744): Out of memory on a 31961104-byte allocation.
      04-06 09:51:55.155: I/dalvikvm(22744):   at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
      04-06 09:51:55.160: I/dalvikvm(22744):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:652)
      04-06 09:51:55.160: I/dalvikvm(22744):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:724)
      04-06 09:51:55.160: I/dalvikvm(22744):   at org.apache.cordova.camera.CameraLauncher.getScaledBitmap(CameraLauncher.java:916)
      04-06 09:51:55.160: I/dalvikvm(22744):   at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:454)
      04-06 09:51:55.160: I/dalvikvm(22744):   at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:753)
      04-06 09:51:55.160: I/dalvikvm(22744):   at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:120)
      

      In the example above, CameraLauncher.getScaledBitmap doesn't catch the java.lang.OutOfMemoryError and the app crashes. The same situation can occur in CameraLauncher.processPicture (which has a try catch with only exception)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dparnas Dagfinn Parnas
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: