Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Document my current understanding

Manav Rathi4c651da2445b
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index 11d5d36ec6..0693ec316d 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -379,8 +379,29 @@ setupLogging();
// - ContextIsolation:
// https://www.electronjs.org/docs/latest/tutorial/context-isolation
//
-// - IPC
-// https://www.electronjs.org/docs/latest/tutorial/ipc
+// - IPC https://www.electronjs.org/docs/latest/tutorial/ipc
+//
+//
+// [Note: Transferring Files over IPC]
+//
+// Electron's IPC implementation uses the HTML standard Structured Clone
+// Algorithm to serialize objects passed between processes. [1]
+// https://www.electronjs.org/docs/latest/tutorial/ipc#object-serialization
+//
+// In particular, both ArrayBuffer and the web File types can be passed.
+// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
+//
+// Also, ArrayBuffer is "transferable", which means it is a zero-copy operation
+// operation when it happens across threads.
+// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects
+//
+// In our case though, we're not dealing with threads but separate processes, so
+// I'm not yet aware if the transfer involves copying or not. I haven't found
+// any explicit documentation stating one way or the other.
+//
+// Closest is a note from one of the Electron committers stating that even with
+// copying, the IPC should be fast enough for even moderately large data:
+// https://github.com/electron/electron/issues/1948#issuecomment-864191345
//
contextBridge.exposeInMainWorld("ElectronAPIs", {
exists,