mobile-sdk-android icon indicating copy to clipboard operation
mobile-sdk-android copied to clipboard

Not a good way to use BannerAdView in LazyColumn (jetpack compose)

Open miduch opened this issue 3 years ago • 3 comments

A common usecase is to show banner ads in LazyColumn

Following within a LazyColumn will recreate banner ad whenever item becomes visible and destroy it when it goes offscreen. if you try to cache BannerAdView and reuse it you will end up with tons of leaks as internally BannerAdView has lot of listeners e.t.c.

AndroidView(factory = { context ->
                       BannerAdView.apply {
                            this.loadAd()
                        }
                    })

A better way to re-use BannerAdView in compose/ lazycolumn is missing / None of provided samples covers this usecase

Related to https://github.com/appnexus/mobile-sdk-android/issues/67

miduch avatar Oct 29 '22 09:10 miduch

Hello, @miduch

Please refer to the LazyColumn sample banner ad. It displays the typical use case for banner ad display in LazyColumn.

Additionally, it caches the BannerAdView for later use without any leaks.

riteshzaveri avatar Nov 17 '22 12:11 riteshzaveri

Hello, @miduch

Have you, by chance, looked at our LazyColumn Sample Banner App?

Please let us know if there are no issues so we can close this ticket.

riteshzaveri avatar Nov 23 '22 17:11 riteshzaveri

Hi, yes i checked your example but i am afraid it was no where near actual/normal use cases.

We have multi module app, with compose navigation e.t.c. the way you are caching those views in activity can't be used in our case

If we try to cache these views inside a composeable that causes memory leaks.

miduch avatar Nov 23 '22 17:11 miduch

Hi @miduch ,

As per our analysis, our SDK works with Jetpack Compose without any issues. We have also provided a simple example of how to use it in a LazyColumn scenario. Having said that, we understand that we cannot cover all the use cases in a sample app. If you use the right design pattern or data structure in your app as per your business logic, we believe you should be able to use our SDK in your app without the need for any SDK modifications.

Do reach out to Xandr support if you feel we still need to support Compose Natively in our SDK. We will be able to do a formal review of the request and prioritize it.

riteshzaveri avatar Nov 29 '22 10:11 riteshzaveri