@Override
 public void onAttachedToWindow() {
   super.onAttachedToWindow();
   if (mHardwareView == null || mHardwareView.isReadyToRender()) {
     mAwContents.onAttachedToWindow();
     mAttachedContents = true;
   } else {
     mHardwareView.setReadyToRenderCallback(
         new Runnable() {
           @Override
           public void run() {
             assert !mAttachedContents;
             mAwContents.onAttachedToWindow();
             mAttachedContents = true;
           }
         });
   }
 }