My goal is to gain better understanding of the codebase, to learn to create a PR for resolving a bug in DeltaChat Android and Desktop.
I wrote a webxdc app.
This app locally generates large binary files, often more than 300 MB, and stores them as blobs in the webview’s IndexedDB.
I want my app to be able to export those files to the device that’s running DeltaChat.
Desktop: works for files smaller than ~ 220 MB. Larger than that, the file gets written, but has a size of 0 B.
Android: works for files smaller than ~ 70 MB. Larger than that, I get the following errors:
Error invoking sendToChat: Java exception was raised during method invocation.Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
How is transferring large files from IndexedDB to device storage supposed to work?
I have no idea how to debug this, where do I start?
What I’ve got so far:
(sorry for no proper links: the forum doesn’t let me post them)
webxdc.js:99-151 — /deltachat/deltachat-android/blob/847c63a9/src/main/res/raw/webxdc.js#L99-L151
The webxdc.sendToChat method gets passed the file blob, serializes it to base64:
base64content = await blobToBase64(message.file.blob);
and passes it as a stringified JSON to the InternalJSApi.
WebxdcActivity.java:757-784 — /deltachat/deltachat-android/blob/847c63a9/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java#L757-L784
The InternalJSApi.sendToChat method deserializes the base64 back to binary:
data = Base64.decode(jsonObject.getString("base64"), Base64.NO_WRAP | Base64.NO_PADDING);
and passes it as an application/octet-stream to the DcHelper.
Questions:
- Why does the data have to be serialized to base64 for passing the js → java barrier?
- Could this be made more efficient by directly passing binary (“application/octet-stream”?) to reduce memory usage?
DcHelper.java:331-352 — /deltachat/deltachat-android/blob/847c63a9/src/main/java/org/thoughtcrime/securesms/connect/DcHelper.java#L331-L352
The DcHelper.sendToChat method creates an intent out of the data:
Uri uri = PersistentBlobProvider.getInstance().create(activity, data, mimeType, fileName);
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, uri);
ShareUtil.setSharedTitle(intent, activity.getString(R.string.send_file_to, fileName));
and starts an activity (which comes from the “DcContext”) with it.
Aaand that’s where my understanding currently ends.
Where do the error messages above come from?
And most importantly, any ideas how to fix this?
I’d be grateful for your help in getting further ![]()