cine-io / cineio-broadcast-android

The cine.io Android Broadcast SDK
https://www.cine.io/products/broadcast
MIT License
52 stars 32 forks source link

The app crashes if I start capturing, then exit the app, and open it again #9

Open lgorse opened 9 years ago

lgorse commented 9 years ago

Here is the flow that consistently crashes the app - can you reproduce it?

lgorse commented 9 years ago

This hasn't been addressed yet but here's the error log:

 Process: com.example.lgorse.cineios_test, PID: 7781
    java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
            at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
            at java.util.ArrayList.get(ArrayList.java:308)
            at io.cine.android.streaming.FFmpegMuxer.releaseOutputBufer(FFmpegMuxer.java:244)
            at io.cine.android.streaming.FFmpegMuxer.writeSampleData(FFmpegMuxer.java:165)
            at io.cine.android.streaming.AndroidEncoder.drainEncoder(AndroidEncoder.java:128)
            at io.cine.android.streaming.TextureMovieEncoder.handleFrameAvailable(TextureMovieEncoder.java:264)
            at io.cine.android.streaming.TextureMovieEncoder$EncoderHandler.handleMessage(TextureMovieEncoder.java:409)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at io.cine.android.streaming.TextureMovieEncoder.run(TextureMovieEncoder.java:219)
            at java.lang.Thread.run(Thread.java:841)
trshafer commented 9 years ago

Hey Laurent,

Thanks for bringing this back to our attention. The situation is much worse unfortunately. I'm having a hard time getting the app to stay working for more than 5 seconds on lollipop. All of our issues are coming because of our ffmpeg build. I imagine the two issues are related.

lgorse commented 9 years ago

Bummer!

Is this something you guys are looking at actively, or is it a back burner project right now?

On Tue, Mar 31, 2015 at 11:43 AM, Thomas Shafer notifications@github.com wrote:

Hey Laurent,

Thanks for bringing this back to our attention. The situation is much worse unfortunately. I'm having a hard time getting the app to stay working for more than 5 seconds on lollipop. All of our issues are coming because of our ffmpeg build. I imagine the two issues are related.

— Reply to this email directly or view it on GitHub https://github.com/cine-io/cineio-broadcast-android/issues/9#issuecomment-88203958 .


Laurent Gorse MBA, class of 2013 Stanford Graduate School of Business 650.644.9188 lgorse@stanford.edu gsb.stanford.edu|Facebook: StanfordGSB http://facebook.com/StanfordGSB |Twitter: @StanfordBiz http://twitter.com/StanfordBiz

trshafer commented 9 years ago

At this exact moment, we are focusing our efforts on backend fault tolerance and high availability.

lgorse commented 9 years ago

OK so on our end we are not releasing for another 3 weeks, and in any case never on Lollipop.

I think we'll need to loop back with you guys about this bug at some point as it may require deeper knowledge of the API than we have - we'll cross that bridge when we get to it.

Does that make sense and is that how you'd envision pairing with us on this?

On Tue, Mar 31, 2015 at 12:00 PM, Thomas Shafer notifications@github.com wrote:

At this exact moment, we are focusing our efforts on backend fault tolerance and high availability.

— Reply to this email directly or view it on GitHub https://github.com/cine-io/cineio-broadcast-android/issues/9#issuecomment-88209798 .


Laurent Gorse MBA, class of 2013 Stanford Graduate School of Business 650.644.9188 lgorse@stanford.edu gsb.stanford.edu|Facebook: StanfordGSB http://facebook.com/StanfordGSB |Twitter: @StanfordBiz http://twitter.com/StanfordBiz

sirvon commented 9 years ago

hey @Igorse have you tried implementing tokbox's offering? if no, why did u choose cineio? hmu on sirvon@sirvon.com, if u don't feel comfortable talking here.

lgorse commented 9 years ago

@growlsworth is this a friend of yours?

In any case here is another error that has to do with the muxer. It has started to pop up and I'm not sure what I would have done differently to cause it to appear:

 Process: com.example.lgorse.cineios_test, PID: 14291
    java.lang.OutOfMemoryError
            at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
            at java.nio.MemoryBlock.allocate(MemoryBlock.java:125)
            at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:72)
            at io.cine.android.streaming.FFmpegMuxer.writeSampleData(FFmpegMuxer.java:151)
            at io.cine.android.streaming.AndroidEncoder.drainEncoder(AndroidEncoder.java:128)
            at io.cine.android.streaming.TextureMovieEncoder.handleFrameAvailable(TextureMovieEncoder.java:264)
            at io.cine.android.streaming.TextureMovieEncoder$EncoderHandler.handleMessage(TextureMovieEncoder.java:409)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at io.cine.android.streaming.TextureMovieEncoder.run(TextureMovieEncoder.java:219)
            at java.lang.Thread.run(Thread.java:841)
sirvon commented 9 years ago

I'm currently getting the same error after a few seconds of broadcasting.

this issue #2 is also dealing with the same error since months ago...

lgorse commented 9 years ago

Hey @sirvon I saw Tokbox but they are only on WebRTC and I'm interested in broadcasting. I like Cine.io a lot because they're an end-to-end solution. This issue with the Muxer has been dangling for a while and I'm hoping they'll focus on getting it fixed really soon.

Usually they are responsive and try to help - this is more an exception than a rule, though it is a blocker for me right now.

sirvon commented 9 years ago

i like cineio too but this issue is slowing down progress... ustream is about to go beta with a broadcasting sdk tokbox DOES have broadcasting, its in beta. the mechanism is done server side, they'll switch your setup after you have 20+ concurrent users.

tighten up cineio!!

oleg-t commented 9 years ago

After quite a bit of debugging, I found that when I send the app to the background while streaming the muxer does not get shutdown, which caused a crash when the app is re-opened.

In onPause() call https://github.com/cine-io/cineio-broadcast-android/blob/master/cineio-broadcast-android-sdk/src/main/java/io/cine/android/BroadcastActivity.java#L280 the camera gets released, the renderer is notified, and the GL view is paused. This causes the handleWriteSampleData not to be called. https://github.com/cine-io/cineio-broadcast-android/blob/master/cineio-broadcast-android-sdk/src/main/java/io/cine/android/streaming/FFmpegMuxer.java#L172

I can see that allTracksFinished() still returns false (as it should) when audio stream signals the end of stream: https://github.com/cine-io/cineio-broadcast-android/blob/master/cineio-broadcast-android-sdk/src/main/java/io/cine/android/streaming/FFmpegMuxer.java#L229

In a working scenario, the video stream also arrives to that line 229, and shutdown() if called. However, when sending the app to background, it never happens. So, the muxer is not shutdown.

If I comment out the following in the onPause() call

    releaseCamera();
    mGLView.queueEvent(new Runnable() {
        @Override
        public void run() {
            // Tell the renderer that it's about to be paused so it can clean up.
            mRenderer.notifyPausing();
        }
    });
    mGLView.onPause();

then the shutdown() is called, but of course everything else breaks, because the camera is not released, and so on.

I’m not an expert in this domain, so I cannot offer a solution. I've tested with our own fork of the SDK and with your sample app (CineIoExampleApp).

Let me know if there is something I can clarify more about my findings.

This issue is blocking our release. Please advise. Hope to hear from you soon!!