protected void finalize() throws Throwable {
   try {
     if (mBuffer != null) GeckoAppShell.freeDirectBuffer(mBuffer);
     mBuffer = null;
   } finally {
     super.finalize();
   }
 }
  /** Attaches the root layer to the layer controller so that Gecko appears. */
  @Override
  public void setLayerController(LayerController layerController) {
    super.setLayerController(layerController);

    layerController.setRoot(mTileLayer);
    if (mGeckoViewport != null) {
      layerController.setViewportMetrics(mGeckoViewport);
    }

    GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
    GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
    GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this);

    sendResizeEventIfNecessary();
  }