Flash Player Memory Leak in IE 11 with ExternalInterface

Issue #10497410 • Assigned to Crispin C.

Details

Author
Ron H.
Created
Jan 11, 2017
Privacy
This issue is public.
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

I work for a publisher of web delivered materials used by teachers and students in K-12 classrooms. A lot of our districts/schools run older hardware and OS due to budget and IT staffing shortfalls. We consequently see a lot of classrooms continuing to use Windows 7, and of those, quite a few continuing to run IE 11 (thousands of sessions daily). We have an existing flash application (SWF) embedded in our website capable of attaching to a microphone and streaming audio up to the a media server (think students recording what they read for review/grading later on). While we have many customers running legacy browser versions, a larger percentage do run newer versions of browsers, OS, hardware, etc. Since those newer versions of browsers have begun to phase out flash, we’ve rewritten the microphone SWF application to be a JavaScript based application (UserMedia, AudioContext, ScriptProcessor, etc).

A hurdle we ran into was that IE 11 doesn’t support this JS approach (Edge on Win 10 is the first browser to support these JS objects). So, we’ve coded up a simple Flash pollyfill that connects through ActionScript to the microphone, and uses the SampleDataEvent in conjunction with the ExternalInterface class to send pass the sound data to a common JS audio handler. We fall back to the pollyfill for browsers that don’t support the JS approach (e.g. IE 11, Safari).

Our pollyfill approach seems to have uncovered a memory leak with the flash player in IE 11. After around 10 minutes of recording, the flash player crashes. Using the developer tools memory profiling tab in IE 11, it appears flash continues to consume memory without garbage collecting. Specifically, I believe the memory leak has to do with any data passed via ExternalInterface. If I pass null instead of the sampled data array, memory climbs and reduces – proper garbage collection.

Here are some very slimmed down code samples that help isolate the problem:

ActionScript

package {
    import flash.display.MovieClip;
    import flash.events.SampleDataEvent;
    import flash.external.ExternalInterface;
    import flash.media.Microphone;

    public class MemLeakTest extends MovieClip {
        private var microphone:Microphone;

        public function MemLeakTest() {
            super.stop();

            microphone = Microphone.getMicrophone();
            microphone.setSilenceLevel(0, 1000000);
            microphone.gain = 65;
            microphone.rate = 44;
            microphone.setUseEchoSuppression(true);
            microphone.setLoopBack(false);
            microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, captureAudioSample);
        }

        private function captureAudioSample(sampleDataEvent:SampleDataEvent) {
            var samples:Array = new Array();
            while(sampleDataEvent.data.bytesAvailable) {
                samples.push(sampleDataEvent.data.readFloat());
            }
            ExternalInterface.call("processAudio", samples);
        }
    }
}

HTML/JavaScript

<html>
<head>
  <script type="text/javascript" src="swfobject-2.2.js"></script>

  <script type="text/javascript">
    var processAudio = function (samples) {
      //Nothing done, but still a memory leak.
    };

    swfobject.embedSWF("mem-leak-test.swf", "swf", "215", "138", "23");
  </script>
</head>

<body>
  <div>Memory Leak Test</div>
  <div>
    <div id="swf"></div>
  </div>
</body>
</html>

I realize the perspective of many in our industry is that Flash has one foot in the grave (I personally agree in general with that), but this functionality in IE 11 is important to many, many classrooms. It would be a shame if we had to go back to these schools and tell them that they had to use a different browser on Win 7 – and a bigger shame for those that can’t do even that because of limited IT resources, internal rules etc.

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Ibrahim O.”

    Changed Assigned To from “Ibrahim O.” to “Crispin C.”

You need to sign in to your Microsoft account to add a comment.

Sign in