Answer the question
In order to leave comments, you need to log in
What is the limitation on the amount of data transferred to Electron via ipcRenderer?
I encountered an application freeze on Electron when I began to transfer a 1.5 MB array through ipcRenderer. The app just crashes. Debug in Visual Studio Code is stuck. No exception is thrown.
I re-read the documentation for ipcMain, ipcRenderer, EventEmitter - nowhere is there anything about the restriction. Googling didn't help. Is this a bug, or is it written somewhere about the restriction?
-----
Apparently, you will have to cut the array into pieces and shove them separately, but even then the total size of the "packet" will vary from time to time, plus all this is wrapped by ipcRenderer itself into a JSON string with an unpredictable final length.
UPD.
After a similar problem with arrays, I ran tests. As you can see, the stack overflow occurs not from the total amount of data, but from their number.
// количество элементов, размер элемента
function test(itemsCount, itemSize) {
const str = '1'.repeat(itemSize)
let arr2 = []
let i = itemsCount
while (i--) {
arr2.push(str)
}
let arr1 = []
Array.prototype.push.apply(arr1, arr2)
}
// test(1000000000, 100) // 100.000.000.000 - 1 млрд * 100 - просто закрывается без ошибки
// test(100000000, 100) // 10.000.000.000 - 100 млн * 100 - зависает, потом просто закрывается без ошибки
// test(10000000, 100) // 1.000.000.000 - 10 млн * 100 - вылетает окно о переполнении стека
// test(1000000, 100) // 100.000.000 - 1 млн * 100 - вылетает окно о переполнении стека
// test(100000, 100) // 10.000.000 - 100 тыс * 100 - ok
// test(10000, 1000) // 10.000.000 - 10 тыс * 1000 - ok
// test(100000, 1000) // 100.000.000 - 100 тыс * 1000 - ok !
// test(100000, 10000) // 1.000.000.000 - 100 тыс * 10.000 - ok !
// test(100000, 100000) // 10.000.000.000 - 100 тыс * 100.000 - ok !
// test(100000, 1000000) // 100.000.000.000 - 100 тыс * 1.000.000 - ok !
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question