The changes in media_frame are the trickiest ones in this patch.  The bug I was seeing was in camera preview if I started to zoom in on an image and then immediately swiped to switch images I would see one image overlaid on the other and I would also sometimes get an OOM.

One of the key problems was a race condition caused by re-using an img element and trying to switch images while one image was already loading. The new onload handler was getting called when the old discarded image finshed loading even though we didn't care about that anymore.  So the first change here is that I now create a new img element each time _displayImage() is called. So there is no need to initialize it here in the constructor.