Commit 0d5ba01b authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Avoid caman to consume all memory

parent 0bb6d171
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.50676.50330.49885</string> </value>
<value> <string>981.59367.17937.61354</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1581434761.85</float>
<float>1581984312.27</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -299,7 +299,8 @@
image_capture = new window.ImageCapture(
gadget.element.querySelector('video').srcObject.getVideoTracks()[0]
),
div;
div,
local_caman;
return new RSVP.Queue()
.push(function () {
......@@ -323,7 +324,7 @@
.push(function (result) {
return new Promise(function (resolve) {
// XXX the correct usage is `new Caman()` but the library does not support it
caman(canvas, null, function () {
local_caman = caman(canvas, null, function () {
if (settings.brightness && settings.brightness !== 0) {
this.brightness(settings.brightness);
}
......@@ -334,6 +335,14 @@
this.greyscale();
}
this.render(function () {
// It's weird but Caman store a lot of data
// in this variables. Please, double check before remove
// this code
this.pixelData = null;
this.originalPixelData = null;
this.renderer.modPixelData = null;
this.imageData = null;
this.initializedPixelData = null;
resolve([this.context.canvas, settings.compression]);
});
});
......@@ -346,6 +355,9 @@
var canvas = result_list[0],
compression = settings.compression || 1;
// Clear caman as much as possible
local_caman = null;
caman.Store.flush(true);
return RSVP.all([
gadget.getTranslationList(["Delete", "Save"]),
new Promise(function (resolve) {
......
import json
_, uuid = context.Base_postDataToActiveResult(
active_process_url, input_value,
generate_new_uid=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment