ente-io / ente

Fully open source, End to End Encrypted alternative to Google Photos and Apple Photos
https://ente.io
GNU Affero General Public License v3.0
16.01k stars 823 forks source link

error in heic-convert-worker causes uploads to stall out #3277

Closed kung-foo closed 1 month ago

kung-foo commented 1 month ago

Description

When uploading a batch of images (via Google Takeout), there appears to be a error converting some of the files. This causes all four workers to stall until the app is restarted.

image

[2024-09-15T19:42:18+02:00] [rndr] [info] Uploading IMG_5375(1).HEIC^M
[2024-09-15T19:42:18+02:00] [rndr] [info] Uploaded IMG_5377(1).heic with result 6 (UPLOADED)^M
[2024-09-15T19:42:18+02:00] [rndr] [info] Uploading IMG_5375.HEIC^M
[2024-09-15T19:42:20+02:00] [rndr] [info] Uploaded IMG_5377.HEIC with result 6 (UPLOADED)^M
[2024-09-15T19:42:20+02:00] [rndr] [info] Uploading IMG_5374(1).HEIC^M
[2024-09-15T19:42:21+02:00] [rndr] [info] Uploaded IMG_5376.HEIC with result 6 (UPLOADED)^M
[2024-09-15T19:42:22+02:00] [rndr] [info] Uploading IMG_5374.HEIC^M
[2024-09-15T19:42:23+02:00] [rndr] [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}^M
[2024-09-15T19:42:23+02:00] [rndr] [error] Unhandled error^M
[2024-09-15T19:42:46+02:00] [rndr] [info] Syncing location entities localEntitiesCount: 2^M
[2024-09-15T19:42:46+02:00] [rndr] [info] Syncing location entities syncTime: 1726326171046405^M
[2024-09-15T19:42:48+02:00] [rndr] [info] Uploaded IMG_5375(1).HEIC with result 6 (UPLOADED)^M
[2024-09-15T19:42:49+02:00] [rndr] [info] Uploading IMG_5373(1).HEIC^M
[2024-09-15T19:42:49+02:00] [rndr] [info] Uploaded IMG_5375.HEIC with result 6 (UPLOADED)^M
[2024-09-15T19:42:50+02:00] [rndr] [info] Uploading IMG_5373.HEIC^M
[2024-09-15T19:42:50+02:00] [rndr] [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}^M
[2024-09-15T19:42:50+02:00] [rndr] [error] Unhandled error^M
[2024-09-15T19:42:51+02:00] [rndr] [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}^M
[2024-09-15T19:42:51+02:00] [rndr] [error] Unhandled error^M
[2024-09-15T19:42:51+02:00] [rndr] [info] Uploaded IMG_5374(1).HEIC with result 6 (UPLOADED)^M
[2024-09-15T19:42:51+02:00] [rndr] [info] Uploading IMG_5372(1).HEIC^M
[2024-09-15T19:42:52+02:00] [rndr] [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}^M
[2024-09-15T19:42:52+02:00] [rndr] [error] Unhandled error^M
[2024-09-15T19:47:34+02:00] [rndr] [info] Syncing location entities localEntitiesCount: 2^M
[2024-09-15T19:47:34+02:00] [rndr] [info] Syncing location entities syncTime: 1726326171046405^M

console log:

_app-30c7e828c1ed2a2c.js:24 [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}
g @ _app-30c7e828c1ed2a2c.js:24
_app-30c7e828c1ed2a2c.js:24 [error] Unhandled error
g @ _app-30c7e828c1ed2a2c.js:24
c87b801d.41d2403723d3f507.js:1 Aborted()
d @ c87b801d.41d2403723d3f507.js:1
c87b801d.41d2403723d3f507.js:1 Uncaught RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
    at d (c87b801d.41d2403723d3f507.js:1:3213)
    at t (c87b801d.41d2403723d3f507.js:24:350)
    at 00318632:0x1f79
    at 00318632:0x2794
    at 00318632:0x831ab
    at 00318632:0x14eba
    at 00318632:0x3c0fc
    at 00318632:0x9571a
    at 00318632:0x95b2d
    at Object.heif_js_decode_image2 (eval at Ia (c87b801d.41d2403723d3f507.js:3:36482), <anonymous>:10:10)
_app-30c7e828c1ed2a2c.js:24 [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}
g @ _app-30c7e828c1ed2a2c.js:24
c87b801d.41d2403723d3f507.js:1 Uncaught RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
    at d (c87b801d.41d2403723d3f507.js:1:3213)
    at t (c87b801d.41d2403723d3f507.js:24:350)
    at 00318632:0x1f79
    at 00318632:0x2794
    at 00318632:0x1e47b
    at 00318632:0x3c05b
    at 00318632:0x9571a
    at 00318632:0x95b2d
    at Object.heif_js_decode_image2 (eval at Ia (c87b801d.41d2403723d3f507.js:3:36482), <anonymous>:10:10)
    at gA.<anonymous> (c87b801d.41d2403723d3f507.js:24:14439)
_app-30c7e828c1ed2a2c.js:24 [error] Unhandled error
g @ _app-30c7e828c1ed2a2c.js:24
c87b801d.41d2403723d3f507.js:1 Aborted()
d @ c87b801d.41d2403723d3f507.js:1
_app-30c7e828c1ed2a2c.js:24 [error] Got error event from worker: {"event":{"isTrusted":true},"name":"heic-convert-worker"}
g @ _app-30c7e828c1ed2a2c.js:24
c87b801d.41d2403723d3f507.js:1 Uncaught RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
    at d (c87b801d.41d2403723d3f507.js:1:3213)
    at t (c87b801d.41d2403723d3f507.js:24:350)
    at 00318632:0x1f79
    at 00318632:0x2794
    at 00318632:0x1a988
    at 00318632:0x3c05b
    at 00318632:0x9571a
    at 00318632:0x95b2d
    at Object.heif_js_decode_image2 (eval at Ia (c87b801d.41d2403723d3f507.js:3:36482), <anonymous>:10:10)
    at gA.<anonymous> (c87b801d.41d2403723d3f507.js:24:14439)

Version

v1.7.4

What product are you using?

Ente Photos

What platform are you using?

Mobile - iOS, Desktop - Windows

mnvr commented 1 month ago

Thank you for the details. If possible, it would be great if you could send a sample to support@ente.io so that we can try to reproduce this.

There are two issues here:

  1. The particular files not being decoded by the HEIC conversion library (we use libheif).
  2. The workers stalling.

Normally errors in the worker in be caught, and the app will move forward without a thumbnail, but for these files it looks like libheif is hitting an unrecoverable assert that comlink cannot catch.

kung-foo commented 1 month ago

Hi @mnvr, I'll send a sample and reference this issue. This doesn't seem to be a "rare" incident though. I'm in the process of doing a Google Takeout with ~165000 photos, and the desktop app makes it about 1000 photos before hanging. This necessitates an app restart and it continues on (not sure if it skips the file, or if it randomizes the input list). Note: the files open just fine in xviewer on Linux.

mnvr commented 1 month ago

Thank you for the samples. There does not seem to be anything specific to these files, we were able to import them just fine on both Ente Photos Windows and macOS (on macOS we have an alternative non-libheif conversion method, and that also worked for these files, thus it's nothing in those sample files). So I'm not sure what's going on.

Meanwhile, as a workaround, you could either (a) complete your upload sans the HEICs, then later upload them from the web/mobile app, or (b) just try the entire upload via the web or mobile app. The web app might also hit the same scenario, since the line of code which triggers the web worker for the HEIC conversion is the same for the Windows desktop and web apps, but it is also possible that the web app might work because of the difference in the browser runtime vs the Electron app runtime.

kung-foo commented 1 month ago

I can't really upload these any other way because this is a Google Takeout export (~1 TB and 160k files). Using the desktop app in Windows, it always stalls after 1000-2000 files (maybe a leak?). I've tried on the Linux desktop app (appimage) but run into different issues importing the Google Takeout (similar to https://github.com/ente-io/ente/discussions/2145)

mnvr commented 1 month ago

Thank you. I agree, the "maybe a leak?" or something similar sounds likely given how it seems to manifest differently. I've forked off a separate thread in the feature requests category so that people can vote on it - https://github.com/ente-io/ente/discussions/3420, closing the current one.