Skip to main content
Participating Frequently
December 19, 2011
Question

AIR app on Android for live chat crashes

  • December 19, 2011
  • 1 reply
  • 1279 views

No matter which streaming server I use, I regularly have a crash. My scenario is:

One side is on browser on PC, the other side is on android air app. Application is receiving a live stream and publishing a live stream at the same time, using two different Netstreams. Half of the time the application crashes. Crashes are rearly occuring during chat, but most of the time after a chat session is ended, and some time after netstreams are closed. There is no exceptions.

If I run the same AIR application on Windows Desktop, no problem occurs.

My application also records video and views recorded video. No problem occurs there. So, play("recorded.flv") and publish("someFLV", "record") has no problems.

When it comes to live streaming, problem occurs.

I use netstream.buffer = 0 for publishing live content, and netstream.buffer with its default value for playing live content.

When chat ends, I detach camera and microphone from netstream, remove eventlisteners from netstream, remove camera from Video object, set microphone and camera to null.

I tried closing and not closing netstreams, but nothing changed.

I tried sound only and video only streams on both sides, but nothing changed.

I compiled with AIR on Android 2.6 and 3.0, but nothing changed.

I tried compiling with Flash Builder Burrito and Flash Builder 4.5, but nothing changed.

I investigated Android adb logcats, but nothing useful is traced.

Application just crashes without any message or warning.

Is there a bug for playing and receiving live content at the same time on AIR on Android?

This topic has been closed for replies.

1 reply

Participating Frequently
December 29, 2011

For those who are interested in this crash, I'll give a few more experiments and hope for an answer.

I investigated a few adb logcat deeper and noticed something about AIR runtime:

1. The crash does not happen all time, but randomly. Followings will explain the reason.

2. If I try sound-only streams, and if app crashes after disposing resources, logcat has messages related to Android microphone. After painful research, I found that logs mean: "someone requested microphone data, but it didn't consume microphone data fast enough."

3. If I try video-only streams, and if app crashes after disposing resources, logcat has messages related to Android camera. After painful research, I found that logs mean: "someone requested camera data, but it didn't consume microphone data fast enough."

So, maybe, only maybe, because AIR doesn not support multi-threading, when we dispose a microphone or a netstream, AIR stops receiving microphone data immediately, but until our calling function ends its execution, AIR does not notify Android OS about dispose. So, in Android's point of view, it sends microphone data but nobody consumes that data, thus nobody empties Android's buffer. Hence Android OS thinks that something is wrong and kills AIR application. That may explain why we get crash randomly: If Android's microphone, or camera, buffer is nearly empty when we dispose, buffer is not get filled until we fully dispose resources and everything is fine. But if the buffer is nearly full when we call dispose, buffer gets filled to its maximum until we finish our disposing and Android OS suspects about buffer and AIR app is killed with a signal 11, a segmentation fault.

This is only a theory, and I found one evidence that supports the theory: Android developers are suggested not to use camera and microphone resources directly. Instead, they are advised to create another thread to consume camera and microphone and use that thread for their needs. That is impossible in AIR as AIR don't have multi-threading.

Well, is there anybody now who has an idea?

Participant
January 15, 2012

Did you find any solution or answer?