• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Problem with Microphone on iOS - bug or incorrect code?

Contributor ,
May 14, 2013 May 14, 2013

Copy link to clipboard

Copied

Hi All,

It appears that using the Microphone class is freezing my Flex mobile app. I provide code below but here's an overview:

  • This only happens on iOS - specifically my iPhone 4. I haven't seen this problem on Android devices.
  • My code alternates between recording and not recording - 5 seconds of one, then 5 seconds of the other, then repeat over and over.
  • I've reduce this to a "minimal case" example (see code below) that does nothing but this. It doesn't use the data that comes in from the Microphone, doesn't create or populate a ByteArray, etc.
  • The app always crashes. In some cases this happens when it's been running for only 2-3 minutes, in all cases it happens within a half hour. I've done 10 test runs and the average is 15 minutes.

My app is a language learning app, and recording and playback of the user's voice is an important feature. It allows the user to hear how well their pronunciation matches that of a native speaker. When record/playback is turned on the app repeatedly plays some audio, records the user's voice, plays it back, plays more audio, etc. In other words, it includes functionality similar to the minimal case code that I'm including here. Users often use this functionality 30 minutes or longer. So this is a problem. 

Am I doing something wrong in my code? Just checking before I report this as a bug.

You can download an FXP from here if you're interested:

http://www.brightworks.com/downloads/RecordingTest.fxp

Or, the important code is below. This is from the example app's (only) view.

Thanks,

Douglas

Douglas McCarroll

Brightworks, Inc.

320.300.0220

<?xml version = "1.0" encoding = "utf-8"?>

<s:View xmlns:fx = "http://ns.adobe.com/mxml/2009"

        xmlns:s = "library://ns.adobe.com/flex/spark"

        creationComplete = "onCreationComplete()"

        title = "Recording Test">

    <fx:Declarations>

    </fx:Declarations>

    <fx:Script>

        <![CDATA[

            private var _isRecording:Boolean;

            private var _iterationCount:uint = 0;

            private var _microphone:Microphone;

            private var _recordedSeconds:uint = 0;

            private var _timer:Timer;

            private function onCreationComplete():void

            {

                NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

            }

            private function doNextPhase(event:TimerEvent = null):void

            {

                _isRecording = !_isRecording;

                if (_isRecording)

                {

                    _iterationCount++;

                    displayOutput("Recording");

                    _microphone = Microphone.getMicrophone();

                    _microphone.rate = 44;

                    _microphone.gain = 50;

                    _microphone.setSilenceLevel(0, 2000);

                    _microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, onNewRecordingSampleData);

                }

                else

                {

                    _recordedSeconds += 5;

                    displayOutput("Pausing");

                    _microphone.removeEventListener(SampleDataEvent.SAMPLE_DATA, onNewRecordingSampleData);

                    _microphone = null;

                }

            }

            private function onNewRecordingSampleData(event:SampleDataEvent):void

            {

            }

            private function displayOutput(phase:String):void

            {

                var freeMemoryMB:int = Math.round(System.freeMemory / (1024 *1024));

                var privateMemoryMB:int = Math.round(System.privateMemory / (1024 *1024));

                var totalMemoryNumberMB:int = Math.round(System.totalMemoryNumber / (1024 *1024));

                phaseLabel.text = "Phase: " + phase;

                iterationLabel.text = "Iteration: " + _iterationCount;

                recordedSecondsLabel.text = "Recorded Seconds: " + _recordedSeconds;

                freeMemoryLabel.text = "System.freeMemory MB: " + freeMemoryMB;

                privateMemoryLabel.text = "System.privateMemory MB: " + privateMemoryMB;

                totalMemoryNumberLabel.text = "System.totalMemoryNumber MB: " + totalMemoryNumberMB;

            }

            private function startTimer():void

            {

                _timer = new Timer(5000, 0);

                _timer.addEventListener(TimerEvent.TIMER, doNextPhase);

                _timer.start();

            }

            private function onStartRecordingButtonClick():void

            {

                if ((Microphone.getMicrophone()))

                {

                    startRecordingButton.enabled = false;

                    startTimer();

                    doNextPhase();

                }

                else

                {

                    phaseLabel.text = "No Mic Available";

                }

            }

        ]]>

    </fx:Script>

    <s:VGroup height = "100%"

              width = "100%"

              paddingBottom = "20"

              paddingLeft = "20"

              paddingRight = "20"

              paddingTop = "20">

        <s:Label id = "phaseLabel"

                 width = "100%" />

        <s:Label id = "iterationLabel"

                 width = "100%" />

        <s:Label id = "recordedSecondsLabel"

                 width = "100%" />

        <s:Label id = "freeMemoryLabel"

                 width = "100%" />

        <s:Label id = "privateMemoryLabel"

                 width = "100%" />

        <s:Label id = "totalMemoryNumberLabel"

                 width = "100%" />

    </s:VGroup>

    <s:HGroup width = "100%"

              horizontalAlign = "center"

              bottom = "10">

        <s:Button id = "startRecordingButton"

                  label = "Start Recording"

                  click = "onStartRecordingButtonClick()"

                  width = "60%" />

    </s:HGroup>

</s:View>

TOPICS
Development

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 12, 2013 Jun 12, 2013

The issue has been solved with 3.8.0.730 !

http://forums.adobe.com/message/5399512#5399512 😉

Thanks Adobe!

Votes

Translate

Translate
Adobe Employee ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

We have been able to reproduce the issue. Could you please open a new bug report on this over at bugbase.adobe.com? When adding the bug please add the SDK , iOS version you are using? Once added, please post back with the bug URL/number so that other can affected.

Regards,

Nimit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

> We have been able to reproduce the issue.

Great!  

> please open a new bug report

Done...

https://bugbase.adobe.com/index.cfm?event=bug&id=3560896

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2013 May 16, 2013

Copy link to clipboard

Copied

We are exeperiencing the same exact bug! It's very critical for us as we are working on a karaoke project for a client! I have voted for the bug. Please fix as soon as possible! Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 30, 2013 May 30, 2013

Copy link to clipboard

Copied

I'm bumping this thread in hopes that others who are having problems with their app freezing when the use the Microphone class in AIR for iOS/iPhone will notice, and vote for the bug that I've filed.

https://bugbase.adobe.com/index.cfm?event=bug&id=3560896

This is a big problem. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 05, 2013 Jun 05, 2013

Copy link to clipboard

Copied

hello,

We have the same issue here. We have tried with AIR 3.5 and it seems not to freeze with this version (3.5.0.600 to be precise).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

I don't have 3.5.0.600, but I have 3.5.0.1060. I've tried it and it appears to, if anything, make the problem worse. 

Also, in any case, I have to use 3.6 so that I can target iPhone 5 (see http://forums.adobe.com/thread/1198630). Perhaps, if one is only targeting iPad, one can use 3.5 as a workaround, but otherwise 3.5 isn't really an option, right?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

well this might be good news after all 😉 The issue could have been added between AIR 3.5.0.600 and 3.5.0.1060 then!

You have to use AIR 3.7 to submit an app to the App Store because it uses iOS SDK 6.1 which is mandatory now.

See http://globz.com/tmp/AIR_iOS_sdk.jpg for the AIR/iOS SDKs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2013 Jun 12, 2013

Copy link to clipboard

Copied

The issue has been solved with 3.8.0.730 !

http://forums.adobe.com/message/5399512#5399512 😉

Thanks Adobe!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 13, 2013 Jun 13, 2013

Copy link to clipboard

Copied

LATEST

Thanks, globzie, for mentioning this. I've now subscribed to the "announcements" forum, but I wasn't aware of the fix.

And, I'm happy to report that this fix is also working for me.  

Thanks Adobe!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines