code: public void updateSessionIfNeeded(Session session) {
      if (viewportChanged) {
        int displayRotation = display.getRotation();
        session.setDisplayGeometry(displayRotation, viewportWidth, viewportHeight);
        viewportChanged = false;
      }
    }
docs: Updates the session display geometry if a change was posted either by {@link
  #onSurfaceChanged(int, int)} call or by {@link #onDisplayChanged(int)} system callback. This
  function should be called explicitly before each call to {@link Session#update()}. This
  function will also clear the 'pending update' (viewportChanged) flag.
  
  @param session the {@link Session} object to update if display geometry changed.