I am writing a custom camera plugin for iOS and Android, because by default it does not provide the functions I need.
What I want to achieve is to receive images from the camera in the background without displaying the screen / preview window so that they can be requested from Javascript and used directly in HTML or published to Base64 via HTTP POST. (+ a few more things that are not ready yet :))
I really managed, and I downloaded my plugin here: https://github.com/Moonware/cordova-cameraplus
Things work as expected on Android, but I have a problem with iOS (possibly a memory leak).
It works for 3-4 minutes, memory increases and suddently stops refreshing (the application is still alive, the Camera object also).
Since ARC is enabled, I cannot manually release / delete some objects myself. I tried to wrap some places that looked strategically with @autoreleasepool {}, memory usage is slightly better, but the problem is still there.
I was wondering if there is an Objective-C specialist out there who could take a look at my plugin and maybe give some advice on how to fix this or at least find where it came from.
I have the feeling that it is a fact of calling the plugin every 50-100 ms to obtain an image that consumes memory and does not free it (the returned string is between 8 kb and 2 MB depending on the resolution of the camera)
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:base64String]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
But even when the update is stopped and in the camera, the memory is never released, even when the CPU usage becomes lower.
To hopefully motivate someone to look at the code, I prepared a simple and ready-to-use Ionic project: https://github.com/Moonware/cordova-cameraplus-testapp
After that, all this needs to be done:
cordova platform add ios (or android) ionic build ios (or android)
Maybe there is a better approach. Suggestions are welcome anyway :)
I realized (of course, after creating my own) that I was not the first with this idea, but looking at the existing options did not help me solve this problem.
The ones I tried seem to have similar memory problems.
Thanks in advance.