brodybits opened a new issue #986:
URL: https://github.com/apache/cordova-android/issues/986


   # Bug Report
   
   ## Problem
   
   I am working on a new plugin for a major customer, with some enhancements to 
support several hundred megabytes worth of response data. If I would send all 
of the data at once, the Java code would crash with a JSON memory error. The 
obvious workaround would be to send the response data in multiple parts, with 
multiple plugin responses as documented and supported by the API.
   
   But if I would send too many plugin responses, it would still crash with a 
JSON memory error. I think the cause is that the MAX_PAYLOAD_SIZE value of 500 
MB is way too large 
    
[here](https://github.com/apache/cordova-android/blob/8.1.0/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L42).
   
   I have made 
[`github:brodybits/cordova-big-android-response-payload-test`](https://github.com/brodybits/cordova-big-android-response-payload-test)
 as a demo which can be used to reproduce this issue. It will send the 
responses in 1 MB chunks, which should be no problem. It seems to work 
consistently stable with 20 native response chunks, memory issues with 400 
native response chunks.
   
   I tried reducing `MAX_PAYLOAD_SIZE` to 16 MB, and it does seem to resolve 
the crash. But if there are too many plugin responses, I would then see some 
ugly module warning messages like this:
   
   ```
   2020-06-04 23:23:53.703 6741-6741/com.demoapp I/chromium: [INFO:CONSOLE(53)] 
"Uncaught module cordova/plugin/android/polling not found", source: 
file:///android_asset/www/cordova.js (53)
   ```
   
   and if I don't use background threading, the JavaScript would not see all of 
the response messages.
   
   A project colleague pointed to the some code which seems to trigger the 
module not found messages - 
[here](https://github.com/apache/cordova-android/blob/8.1.0/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L199).
   
   Here is [the original thread on the mailing 
list](https://lists.apache.org/thread.html/ree03f1d05bea6d41171ab6f3f0d9a2406dba5f17ec11b2cdc043d0fa%40%3Cdev.cordova.apache.org%3E).
   
   ### What is expected to happen?
   
   - sending large sets of response payload data chunks should just work 
without crashes and without module not found warning messages
   
   ### What does actually happen?
   
   - sending large sets of response payload data, even in smaller chunks, leads 
to crashes, with both reproduction and analysis given above
   - reducing MAX_PAYLOAD_SIZE as described above does seem to resolve the 
crash but seems to uncover some other issues as described above
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   see above
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   see above
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   - cordova-android 8.1.0
   - cordova-android from master with MAX_PAYLOAD_SIZE reduced to 16 MB
   - device: Samsung Galaxy SM-G920V with Android version 7.0
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   - cordova-android: 8.1.0 & master
   - Cordova CLI: 9.0.0 (cordova-lib@9.0.1)
   - Cordova plugin: test plugin which is part of the test project described 
above
   - host: macOS Catalina
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to