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

Improve the cache and memory management for Native Ads #662

Closed
YuriyVelichkoPI opened this issue Aug 10, 2023 · 1 comment
Closed

Improve the cache and memory management for Native Ads #662

YuriyVelichkoPI opened this issue Aug 10, 2023 · 1 comment
Assignees
Labels
needs_docs please add docs for your feature to https://github.com/prebid/prebid.github.io
Milestone

Comments

@YuriyVelichkoPI
Copy link
Contributor

Objectives

Deprecate Method:

public boolean registerView(View view, final PrebidNativeAdEventListener listener)

Update rename method

public boolean registerViewList(View container, List<View> viewList, final PrebidNativeAdEventListener listener)

to:

public boolean registerView(View view, List<View> clickableViews, final PrebidNativeAdEventListener listener)

view - the native ad container used to track impression
clickableViews - list of views that should handle click

  • Don't catch the registered view registeredView by the strong reference in the PrebidNativeAd.
  • Don't catch the registered view view by the strong reference in VisibilityDetector.
  • Don't catch the registered views in the clickableViews by the strong references.
  • Ensure that destroying the PrebidNativeAd all listeners and registered views are destroyed as well. No memory leaks should be here.
  • Ensure that the CacheManager signal the respective PrebidNativeAd objects on the expiration event.
  • Update tests
@ValentinPostindustria
Copy link
Collaborator

When a user uses registerView() with an anonymous listener parameter in Activity or Fragment, he can create a memory leak that we can't control. To prevent it a user should use a class that extends PrebidNativeAdEventListener.

class NativeListener : PrebidNativeAdEventListener {

        override fun onAdClicked() {}

        override fun onAdImpression() {}

        override fun onAdExpired() {}

}

And then use:

nativeAd.registerView(
            binding.adContainer,
            listOf(
                binding.tvNativeTitle,
                binding.ivNativeMain,
                binding.ivNativeIcon
            ),
            NativeListener() // ***
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_docs please add docs for your feature to https://github.com/prebid/prebid.github.io
Projects
Status: Done
Development

No branches or pull requests

2 participants