Open sinhpn92 opened 4 years ago
I have same problem, it take time to load data and make recyclerview slow to response on onscroll
I found that this issue by load ad. The UI has been blocking when loading ads :((. How can to fix it? 🍡
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);
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?
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?
Having the same issue...
It's seem to be google cann't fix it. :(( This issue have been created long time ago.
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.
Which's your test device? @zeroarst :(( I have tested on SamSung S10 Plus But It's still facing laggy. So bad
Mine is Samsung s7 edge
Any solution to this issue?
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.
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.
Facing the same issue here, is there any fix or a workaround at least?
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
Same error. Need a solution for this.
It's been years and still there is no fix.
any solutions yet??
Having the same issue. Any solution to this?
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?