Skip to content

Fix resource leaks and bitmap copy bug in image processing#3774

Merged
guiyanakuang merged 2 commits intomainfrom
fix/image-media-resource-leaks
Feb 8, 2026
Merged

Fix resource leaks and bitmap copy bug in image processing#3774
guiyanakuang merged 2 commits intomainfrom
fix/image-media-resource-leaks

Conversation

@guiyanakuang
Copy link
Copy Markdown
Member

@guiyanakuang guiyanakuang commented Feb 8, 2026

Summary

  • WebpImageWriter: Close FileImageOutputStream and dispose ImageWriter via try/finally to prevent file handle leaks
  • DesktopThumbnailLoader: Wrap InputStream and OutputStream in .use {} for readOriginMeta and defaultSave
  • MacCropTransformation: Fix fallback pixel copy to use readPixels + installPixels instead of discarding the read result
  • DesktopIconColorExtractor: Replace plain MutableMap with Ktor ConcurrentMap + Optional<Color> for thread-safe access under StripedMutex

Fixes #3773

Test plan

  • Verify WebP image writing still works and file handles are released promptly
  • Verify thumbnail loading/saving handles metadata streams correctly
  • Verify MacCropTransformation crop still works (primary path via extractSubset)
  • Verify icon color extraction works concurrently without ConcurrentModificationException

🤖 Generated with Claude Code

@guiyanakuang guiyanakuang force-pushed the fix/image-media-resource-leaks branch from 3c8acda to e9e9ca4 Compare February 8, 2026 07:24
- WebpImageWriter: close FileImageOutputStream and dispose ImageWriter
  after writing to prevent file handle leaks
- DesktopThumbnailLoader: wrap InputStream and OutputStream in .use {}
  for readOriginMeta and defaultSave to ensure proper cleanup
- MacCropTransformation: fix fallback pixel copy to use readPixels +
  installPixels instead of discarding the read result
- DesktopIconColorExtractor: replace plain MutableMap with
  ConcurrentHashMap for thread-safe access under StripedMutex

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@guiyanakuang guiyanakuang force-pushed the fix/image-media-resource-leaks branch from e9e9ca4 to 200c4b0 Compare February 8, 2026 07:29
@guiyanakuang guiyanakuang merged commit 95fe356 into main Feb 8, 2026
2 checks passed
@guiyanakuang guiyanakuang deleted the fix/image-media-resource-leaks branch February 8, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource leaks and bitmap copy bug in image processing

1 participant