Mirroring causes low frame rate and longer delay

In order to draw the mirror every frame, the function onPreDraw() in MirroringFrameLayout triggers the invalidate() every frame. It drags down the frame rate from 30fps to 15fps, and causes the longer delay ~200ms. It will work when the frame rate is not sensitive to some apps. But when the video behind the mirror view is 15fps, it is noticeable.

In my own case, I figured out there can be different methods to trigger the mirror update. Ideally, the mirror will only be updated once the source view updates. This will still cause frame rate drop when updating. But since my draw view is only updated when users draw something, so frame rate drop occurs occasionally.

Not sure if there is a generic solution to this frame rate issue.

public boolean onPreDraw() {
if (mirror != null) {
if (bmp == null) {
else {



Most of the mirror code is several years old at this point. I was struggling to get it to work, particularly in cases where we do not have much control over the source (e.g., WebView). I am not surprised that its performance is not great.

I will try to budget some time to look into this some more.

Hi Mark,

I found this might be useful to the mirror feature. Not yet done full research.

I will try to set aside some time to run some experiments. Thanks for pointing this out!

1 Like

I tested it. It certainly solves the delay and low frame rate issue. So the performance is better.

However, in my case, I wanted my original complicated view/layout to render just once off-screen to a bitmap, then display it to both main screen and HDTV at the same time. This approach almost works. But after I dispatch the touch events from main screen to the off-screen layout, I realized that Android frameworks handle the off-screen layout differently. If not visible, or not attached to windows, it just skips lots of work. I felt I opened another can of worms. Some touch events are OK, some not. I gave up this method.