Forum Xamarin.Forms

mmap out of Memory, Videoview: “Can't play this video”

I have a large project where I'm storing videos in the raw file (Around a few gig) Everything has been going smoothly until now. Sometimes my videos will not play and show "Can't play this video" message, I've noticed I have been getting mmap failed: Out of memory errors in my stack trace and I'm struggling to resolve this issue, and my uri returns null.

Since my source code files are huge I'll be leaving out what I thought of as trivial code:

    VideoView Video = FindViewById <VideoView>(Resource.Id.videoViewMainActivty);


    MediaController mediaController = new MediaController(this, true);
    Video.SetMediaController (mediaController);

    var uri = Android.Net.Uri.Parse ("android.resource://" + PackageName + "/" + Resource.Raw.V11_2_1_1_Completing_the_square);
    Video.SetVideoURI (uri);
    Video.Start ();

Log:

[libEGL] loaded /system/lib/egl/libEGL_mali.so
[libEGL] loaded /system/lib/egl/libGLESv1_CM_mali.so
[libEGL] loaded /system/lib/egl/libGLESv2_mali.so
[] Device driver API match
[] Device driver API version: 10
[] User space API version: 10 
[] mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
[OpenGLRenderer] Enabling debug mode 0
Thread finished: <Thread Pool> #5
[Mono] [0xb8c7e958] worker finishing
Thread finished: <Thread Pool> #3
Thread finished: <Thread Pool> #4
[Mono] [0xb9648f00] worker finishing
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 5 mFalseSizeCnt:0
[dalvikvm-heap] Grow heap (frag case) to 13.961MB for 1536016-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 16.558MB for 2724712-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 19.158MB for 2724712-byte allocation
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
[Mono] [0xb945f918] worker starting
Thread started: <Thread Pool> #8
[Mono] [0xba4f20e0] worker starting
Thread finished: <Thread Pool> #7
[Mono] [0xb945f918] worker finishing
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 4 mFalseSizeCnt:0
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 5 mFalseSizeCnt:0
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[GestureDetector] [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 7 mFalseSizeCnt:0
[webclipboard] clipservice: [email protected]
[webkit] BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {423615d0}
[webview] registerForStylusPenEvent onAttachedToWindow
[webview] registerForStylusPenEvent START
[webview] registerForStylusPenEvent END
Thread started: <Thread Pool> #9
[Mono] [0xbcd08d90] worker starting
[MediaPlayer-JNI] native_setup
[MediaPlayer] constructor
[MediaPlayer] setListener
[MediaPlayer] path is null
[filemap] mmap(0,1068406440) failed: Out of memory
[asset] create map from entry failed
[MediaPlayer] Couldn't open file on client side, trying server side
[MediaPlayer] setVideoSurfaceTexture
[MediaPlayer-JNI] setAudioStreamType: 3
[MediaPlayer] MediaPlayer::setAudioStreamType
[MediaPlayer] setVideoSurfaceTexture
[MediaPlayer] prepareAsync
[MediaPlayer] message received msg=100, ext1=1, ext2=-2147483648
[MediaPlayer] error (1, -2147483648)
Thread started: <Thread Pool> #10
[MediaPlayer] callback application
[MediaPlayer] back from callback
[Mono] [0xbd0a4958] worker starting
[ProgressBar] setProgressDrawable mProgressDrawable = null, d = [email protected] = false
[ProgressBar] setProgress = 0
[ProgressBar] setProgress = 0, fromUser = false
[ProgressBar] mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
Thread started: <Thread Pool> #11
[Mono] [0xbd0ff870] worker starting
[MediaPlayer] Error (1,-2147483648)
[VideoView] Error: 1,-2147483648
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_get_system_property'.
[Mono] Probing 'monodroid_get_system_property'.
[Mono] Found as 'monodroid_get_system_property'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_free'.
[Mono] Probing 'monodroid_free'.
[Mono] Found as 'monodroid_free'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'monodroid_get_system_property'.
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
[SpannableStringBuilder] SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

I've made sure my encoding is correct and the video does play sometimes. For some reason I'm having trouble with this video specifically. The file is 21MB, Could this be a problem? Might compressing all my videos and making sure the width and height are correct help solve this issue? or is there a way to "release" mmap memory? Any help would be much appreciated.

Tagged:
Sign In or Register to comment.