private void render() {
    if (mPendingRenders > 0) mPendingRenders--;

    // Waiting for the content view contents to be ready avoids compositing
    // when the surface texture is still empty.
    if (mCurrentContentView == null) return;
    ContentViewCore contentViewCore = mCurrentContentView.getContentViewCore();
    if (contentViewCore == null || !contentViewCore.isReady()) {
      return;
    }

    boolean didDraw = nativeComposite(mNativeContentViewRenderView);
    if (didDraw) {
      mPendingSwapBuffers++;
      if (mSurfaceView.getBackground() != null) {
        post(
            new Runnable() {
              @Override
              public void run() {
                mSurfaceView.setBackgroundResource(0);
              }
            });
      }
    }
  }