[ 
https://issues.apache.org/jira/browse/CB-11034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15232202#comment-15232202
 ] 

Dagfinn Parnas commented on CB-11034:
-------------------------------------

[~riknoll] For us the DATA_URL feature is necessary feature. 

We're working with mobile app for travel expenses on top SAP ERP systems. The 
front-end is implemented with OpenUI5 https://github.com/SAP/openui5 which is 
an MVC based javascript framework. The data communication between the front-end 
and the back-end is done with ajax and the SAP mobile framework we use provides 
automatic serialization between the formats used in the front-end and the 
back-end (front-end is a JSON based model, whilst the backend is an object 
oriented ABAP class). With this approach there is a limit for how large files 
you can handle as they need to be kept in memory, but for our use cases this is 
in general not an issue.

Because of the above, we do not have a traditional form being posted over HTTP 
POST. 

Here's a step by step overview on what happens when the user wants to attach a 
photo to a travel:
1. Call cordova plugin through camera.getPicture with DATA_URL
2. Receive base64 data in app and store in OpenUI5 javascript model
3. Draw base64 data into a canvas in order to perform operations on image (such 
as scaling, convert to black/white etc.) and provide preview
4. Fetch data from canvas to provide a preview in a HTML img element
5. Initiate ajax request to SAP with photo as base64 encoded data
6. Mobile framework in SAP automatically deserializes model into object 
oriented class (in ABAP)
7. Store photo in SAP

If cordova-camera-plugin didn't support DATA_URL we would need to first call 
camera.getPicture to get a FILE_URI and then call the cordova-file-plugin to 
read the contents of the file into a data url . I'm guessing there will be a 
few more edge cases where this approach would not work and it would be 
significantly harder to fix as it involves to different plugins

> 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
>
> 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: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to