Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible resource leak #58

Closed
MV-GH opened this issue Dec 10, 2023 · 1 comment
Closed

Possible resource leak #58

MV-GH opened this issue Dec 10, 2023 · 1 comment
Assignees

Comments

@MV-GH
Copy link

MV-GH commented Dec 10, 2023

I have enabled StrictMode with LeakedClosable detection. To search for resources leaks that are reported in the logs.

Possibly one is coming from this library.

StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
	at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1924)
	at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:303)
	at java.io.FileInputStream.finalize(FileInputStream.java:500)
	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:292)
	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:279)
	at java.lang.Daemons$Daemon.run(Daemons.java:140)
	at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.Throwable: Explicit termination method 'close' not called
	at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:259)
	at dalvik.system.CloseGuard.open(CloseGuard.java:230)
	at java.io.FileInputStream.<init>(FileInputStream.java:176)
	at okio.Okio__JvmOkioKt.source(JvmOkio.kt:181)
	at okio.Okio.source(Unknown Source:1)
	at okio.JvmSystemFileSystem.source(JvmSystemFileSystem.kt:96)
	at me.saket.telephoto.subsamplingimage.internal.ExifMetadata$Companion$read$2.invokeSuspend(ExifMetadata.kt:32)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

I get this pretty consistent on opening and closing a composable with ZoomableAsyncImage

Looked further into it. It passes a inputStream to ExifInterface that is not cleaned up.

  • Reads Exif tags from the specified image input stream. Attribute mutation is not supported
    * for input streams. The given input stream will proceed from its current position. Developers
    * should close the input stream after use. This constructor is not intended to be used with
    * an input stream that performs any networking operations.

This says consumers should close the resource and this is not done. It seems that a simple inputStream.close after exif should be sufficient. (at ExifMetadata$read)

@saket saket self-assigned this Dec 20, 2023
@saket saket closed this as completed in d13b510 Jan 22, 2024
@saket
Copy link
Owner

saket commented Jan 22, 2024

Thanks for reporting @MV-GH!

github-merge-queue bot pushed a commit to slackhq/circuit that referenced this issue Feb 18, 2024
…1215)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[me.saket.telephoto:zoomable-image-coil](https://togithub.com/saket/telephoto)
| dependencies | minor | `0.7.1` -> `0.8.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>saket/telephoto
(me.saket.telephoto:zoomable-image-coil)</summary>

### [`v0.8.0`](https://togithub.com/saket/telephoto/releases/tag/0.8.0)

[Compare
Source](https://togithub.com/saket/telephoto/compare/0.7.1...0.8.0)

Breaking changes

- Reordered `SubSamplingImage()`'s parameters to move `Modifier` below
all required parameters.

New changes

- Update Compose UI to `1.6.1` and Compose Multiplatform to `1.6.0-rc02`
- Introduced
[ZoomableState#transformedContentBounds](https://togithub.com/saket/telephoto/blob/706cf08cb976c0d9d9c6d0f95e4e64fc4efbf4ef/zoomable/src/commonMain/kotlin/me/saket/telephoto/zoomable/ZoomableState.kt#L88-L96)
for observing transformed content bounds. This can be used for drawing
decorations around the content or performing hit tests.
- Placeholder images now respond to click listeners. Additionally, they
will swallow all other zoom gestures instead of ignoring them.
-
[saket/telephoto#3:
Read color space of bitmaps from Coil and Glide.

Bug fixes

-
[saket/telephoto#60,
[saket/telephoto#65:
Improved detection of pinch-to-zoom gestures.
-
[saket/telephoto#8:
Composables with `Modifier.zoomable()` are now drawn on the first frame.
This fixes their broken layout preview.
-
[saket/telephoto#58:
Fixed a resource leak when an image's EXIF metadata is read.
- `ZoomableState#resetZoom()` now calculates the content's position on
the same UI frame.
- Images no longer flicker on start when they can't zoom-in any further.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xOTQuMyIsInVwZGF0ZWRJblZlciI6IjM3LjE5NC4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
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

No branches or pull requests

2 participants