googleads-mobile-android-examples icon indicating copy to clipboard operation
googleads-mobile-android-examples copied to clipboard

Native Advanced Ad Android laggy in Recyclerview

Open sinhpn92 opened this issue 5 years ago • 19 comments
trafficstars

I have tried to intergrate Native Advanced Ad into Recyclerview, but It is so laggy. I dont know why. I did fix site for media_view but it still lag.

Have any suggest to solve it?

sinhpn92 avatar Feb 25 '20 15:02 sinhpn92

I have same problem, it take time to load data and make recyclerview slow to response on onscroll

Shvet avatar Feb 26 '20 03:02 Shvet

I found that this issue by load ad. The UI has been blocking when loading ads :((. How can to fix it? 🍡

sinhpn92 avatar Feb 26 '20 14:02 sinhpn92

Apparently the issue coming from loadAd should be in separate thread

        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                MainActivity.runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        AdRequest adRequest = new AdRequest.Builder()
                                .addTestDevice(AD_TEST_DEVICE)
                                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                                .build();

                        adView.loadAd(adRequest);
                    }
                });
            }
        }, 1000);

baderkhane avatar Feb 29 '20 21:02 baderkhane

Apparently the issue coming from loadAd should be in separate thread

        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                MainActivity.runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        AdRequest adRequest = new AdRequest.Builder()
                                .addTestDevice(AD_TEST_DEVICE)
                                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                                .build();

                        adView.loadAd(adRequest);
                    }
                });
            }
        }, 1000);

Why do we need delay 1 second to load ad?

sinhpn92 avatar Aug 08 '20 02:08 sinhpn92

I did try to load ad in the Couroutines with IO or Main. lifecycleScope.launch(Dispatchers.Main) {...} But It's still happening. Is there anyone has facing problem?

sinhpn92 avatar Aug 25 '20 08:08 sinhpn92

Having the same issue...

zeroarst avatar Nov 19 '20 13:11 zeroarst

It's seem to be google cann't fix it. :(( This issue have been created long time ago.

sinhpn92 avatar Nov 24 '20 11:11 sinhpn92

It is actually not just on RecyclerView, it happens with all scrolls. I pull this repo https://github.com/googleads/googleads-mobile-android-examples/tree/master/kotlin/admob/NativeAdvancedExample and add a view with a height that higher than the screen, to make the screen scrollable. and I can see the lag. But the progress animation dose not lag at all. very weird.

zeroarst avatar Nov 24 '20 13:11 zeroarst

Which's your test device? @zeroarst :(( I have tested on SamSung S10 Plus But It's still facing laggy. So bad

sinhpn92 avatar Nov 25 '20 02:11 sinhpn92

Mine is Samsung s7 edge

zeroarst avatar Nov 25 '20 10:11 zeroarst

Any solution to this issue?

roma7481 avatar Apr 15 '21 15:04 roma7481

I can confirm that this is not specific to RecyclerView as I noticed this as well with ScrollView. The UI freeze in a second when loading NativeAd com.google.android.gms.ads.nativead.NativeAdView. The lag starts when loading and ad.

ArcherEmiya05 avatar Apr 22 '21 19:04 ArcherEmiya05

Apparently the issue coming from loadAd should be in separate thread

        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                MainActivity.runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        AdRequest adRequest = new AdRequest.Builder()
                                .addTestDevice(AD_TEST_DEVICE)
                                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                                .build();

                        adView.loadAd(adRequest);
                    }
                });
            }
        }, 1000);

Need to correct you else you will keep believing in a wrong idea. That is not how you run heavy task on different thread. What you did here is add a delay then just literally run the heavy task in the main thread which is UI thus the lag is all still there, you just delay it occurrence . One of the basic way of running heavy task on a separate thread to not block the UI in order to avoid lag/freeze is with AsyncTask which is now deprecated. You can use Concurrent or Courutines when using Kotlin.

ArcherEmiya05 avatar Apr 22 '21 19:04 ArcherEmiya05

Facing the same issue here, is there any fix or a workaround at least?

dexbyte avatar Aug 06 '21 10:08 dexbyte

I am also facing this issue, the loading of native ads seems to block the UI - running the ad loading in a coroutine doesn't change anything

Ynnck123 avatar Nov 21 '21 14:11 Ynnck123

Same error. Need a solution for this.

abkoradiya avatar Dec 01 '21 14:12 abkoradiya

It's been years and still there is no fix.

7kashif avatar Apr 26 '22 20:04 7kashif

any solutions yet??

Rdog69 avatar Jun 13 '23 15:06 Rdog69

Having the same issue. Any solution to this?

vamshikrishnag0 avatar Jun 25 '24 11:06 vamshikrishnag0