cordova-android
cordova-android copied to clipboard
issues with large sets of response payload, even in smaller chunks
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.
I have made github: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.
Here is the original thread on the mailing list.
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
see above
Command or Code
see above
Environment, Platform, Device
- 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
- cordova-android: 8.1.0 & master
- Cordova CLI: 9.0.0 ([email protected])
- Cordova plugin: test plugin which is part of the test project described above
- host: macOS Catalina
Checklist
- [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
it is rare issue but still relevant