Krupen / AutoplayVideos

Android library to auto-play/pause videos from url in recyclerview.
Apache License 2.0
996 stars 147 forks source link

java.lang.OutOfMemoryError happen sometimes #55

Closed firojandev closed 6 years ago

firojandev commented 6 years ago

Hey, Thanks for nice library. I am using this library into my project. Few minitues works fine, but after some time app go to freeze. I set the beow

holder.setLooping(false);

setDownloadVideos(false); // because of device memory issue

I got bellow error from logcat. Can you help me please?

java.lang.OutOfMemoryError: at java.lang.Thread.nativeCreate (Native Method) at java.lang.Thread.start (Thread.java:730) at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView.playAvailableVideos (AAH_CustomRecyclerView.java:85) at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView$1.onScrollStateChanged (AAH_CustomRecyclerView.java:70) at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged (RecyclerView.java:4759) at android.support.v7.widget.RecyclerView.setScrollState (RecyclerView.java:1434) at android.support.v7.widget.RecyclerView$ViewFlinger.fling (RecyclerView.java:4954) at android.support.v7.widget.RecyclerView.fling (RecyclerView.java:2130) at android.support.v7.widget.RecyclerView.onTouchEvent (RecyclerView.java:2994) at android.view.View.dispatchTouchEvent (View.java:10081) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2779) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2408) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422) at com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:435) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1836) at android.app.Activity.dispatchTouchEvent (Activity.java:3063) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68) at com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:397) at android.view.View.dispatchPointerEvent (View.java:10312) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4949) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4808) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315) at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4368) at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4334) at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4480) at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4342) at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4537) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315) at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4368) at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4334) at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4342) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315) at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6844) at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6818) at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6761) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:7016) at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnce (Native Method) at android.os.MessageQueue.next (MessageQueue.java:328) at android.os.Looper.loop (Looper.java:148) at android.app.ActivityThread.main (ActivityThread.java:6276) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1063) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)

Krupen commented 6 years ago

Hi,

There is no straight forward solution to this, but you can try using caching to reduce this problem. Also try to paginate your RecyclerView so there aren't many Videos in memory at the same time.

Krupen commented 6 years ago

Closing this for now, feel free to re-open if issue persists.