Skip to content

Lint: Prevent memory leak from implicit SAM conversion #588

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cartland
Copy link
Contributor

The lint tool reported an ImplicitSamInstance warning in PictureInPictureSnippets.kt. Lambdas used as listeners were being implicitly converted to new SAM instances, causing removeOnUserLeaveHintListener to fail because the listener instances did not match. This could lead to a memory leak.

This commit fixes the issue by explicitly wrapping the listener lambdas in a 'Runnable' instance. This ensures a stable object reference is used for both adding and removing the listener.

The lint tool reported an "ImplicitSamInstance" warning in PictureInPictureSnippets.kt. Lambdas used as listeners were being implicitly converted to new SAM instances, causing removeOnUserLeaveHintListener to fail because the listener instances did not match. This could lead to a memory leak.

This commit fixes the issue by explicitly wrapping the listener lambdas in a 'Runnable' instance. This ensures a stable object reference is used for both adding and removing the listener.
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.

2 participants