cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thehuijb <...@git.apache.org>
Subject [GitHub] cordova-plugin-camera pull request: CB-8804 implement check for sa...
Date Mon, 22 Jun 2015 09:42:59 GMT
Github user thehuijb commented on the pull request:

    https://github.com/apache/cordova-plugin-camera/pull/97#issuecomment-114052451
  
    ## How a cordova camera application works on android
    
    This is basically  how a cordova application works:
    ![image00](https://cloud.githubusercontent.com/assets/902441/8279233/f8407912-18d2-11e5-8761-7fd55deaa3c7.png)
    - User presses App-icon
    - Applications start
    - Mainactivity start
    - Java side of plugins included
    - WebView initialized
    - Html loads
    - javascript side of plugins loaded
    - onDeviceReady fired
    
    Now we have our application up and running.
    It’s time to take a picture
    ![image01](https://cloud.githubusercontent.com/assets/902441/8279256/2814f032-18d3-11e5-9abd-d349185ab3f5.png)
    
    - We call getPicture
    - The call goes to the CordovaBridge
    - CordovaBridge uses the PluginManager to pass it to the camera Plugin
    - Camera plugin launches a camera Activity
    
    Now that a camera Activity is running, our MainActivity is pushed to the background, onPause
is fired.
    
    When the Camera Activity finished the MainActivity is called again via onActivityResult
    ![image02](https://cloud.githubusercontent.com/assets/902441/8279282/6a7ddf10-18d3-11e5-8b43-67675a2f61dc.png)
    
    the result is dispatched to the javascript succesFunction where our application can then
do with it as planned.
    That’s what happens in a high memory availability scenario, a happy flow.
    
    Now what happens when there isn’t enough memory left and the OS decides to kill our
MainActivity?
    ![image03](https://cloud.githubusercontent.com/assets/902441/8279295/97699f1e-18d3-11e5-9776-a41f8d87dea3.png)
    
    - CameraActivity is finished and sends its result back to the activity that launched it.
    - Our MainActivity, is started.
    - Java side of plugins included
    - onActivityResult fires
    - plugin fails to send result back to the javascript because it is not there anymore
    - a completely new WebView is initialized
    - Html loads
    - javascript side of plugins loaded
    - onDeviceReady fired
    
    the precise order of event could differ on occasion but that doesn’t matter because
the entire webview has to be rebuilt and with it all the javascript therefor the callback
can never be completed in this situation.
    You will always have to call a method in (or after) onDeviceReady to solve this problem.
    
    Serge


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message