fix(immich): prevent OOM crash on large images and fix video asset handling#625
Open
iAndrea wants to merge 2 commits intofatihak:mainfrom
Open
fix(immich): prevent OOM crash on large images and fix video asset handling#625iAndrea wants to merge 2 commits intofatihak:mainfrom
iAndrea wants to merge 2 commits intofatihak:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Immich plugin was downloading full-resolution originals (up to 24MB+) on
every refresh, causing OOM kills on low-RAM devices (e.g. Pi Zero). Additionally,
video assets in albums could be selected and passed to
Image.open(), causinga crash, and a missing
import requestscaused aNameErrorthat swallowedthe real error in the image loader.
Changes
image_album.py/api/assets/{id}/originalURL with a version-aware resolver that probesthe server once (streaming GET, no body downloaded) and caches the working
endpoint for the lifetime of the provider:
/api/assets/{id}/thumbnail?size=preview— current Immich API/api/assets/{id}/thumbnail— older versions withoutsizeparam/originalwith a warning if both failPOST /api/search/metadataloop with a singleGET /api/albums/{id},with client-side
type == "IMAGE"filtering to exclude video assetsasset.viewto the required API key permissionsimage_loader.pyNameErrorin exception handlers —requestswas referenced inexcept requests.exceptions.RequestExceptionbut never imported_load_from_url_fast— replaceBytesIO(response.content)(two copies of compressed bytes in memory) withresponse.rawpiped directly into PIL;decode_content=Truehandlesgzip/deflate transparently
Required API key permissions
asset.view(NEW),asset.read,asset.download,album.read