[
https://issues.apache.org/jira/browse/CB-11034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15233613#comment-15233613
]
ASF GitHub Bot commented on CB-11034:
-------------------------------------
Github user elsewhat commented on the pull request:
https://github.com/apache/cordova-plugin-camera/pull/201#issuecomment-207814319
@riknoll @nikhilkh as an app developer I have to disagree with you.
I would **expect a framework such as cordova to never crash an app under no
circumstances if it's preventable**.
Crashing an app is a very significant event which impacts users perception
of the app very negatively and causes a significant effort wrt. end-user
support for enterprise apps. It will in many cases cause entered data to be
lost, and nothing frustrates users more.
There is lots the app can do to handle such an exception. In my case I can
make sure the users understand the issue is because the size of the image and
how they can perform workarounds.
Ideally, the CameraLauncher.failPicture would allow me to pass some
semantics regarding the nature of the issue for example an error code. But
since this was not in place already in the code, I didn't do any changes to it.
However, **I totally agree that refactoring the code to reduce the memory
footprint is an even better approach which actually tackles the root cause. But
this doesn't negate the need to avoid OutOfMemoryErrors when performing memory
intensive operations**. Even with an exceptionally optimized memory handling of
images in cordova-camera-plugin there will always be situations where an
OutOfMemoryError occurs, for example if the app uses a lot of memory on the
webview side and the device is old with a strict limit on heap size (a G1 had
16MB of heap)
> Camera.getPicture -Handle of OutOfMemoryError gracefully
> --------------------------------------------------------
>
> Key: CB-11034
> URL: https://issues.apache.org/jira/browse/CB-11034
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin Camera
> Affects Versions: 2.1.1
> Environment: Android
> Reporter: Dagfinn Parnas
> Labels: Android, mustfix, triaged
>
> 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
> {code}
> 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)
> {code}
> 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)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]