title: eglQuerySurface gives wrong size
body: <p>When I rotate my device and my app recieves <code>APP_CMD_CONFIG_CHANGED</code>, I attempt to update my OpenGL viewport with the following:</p>
  
  <pre><code>EGLint width;
  EGLint height;
  eglQuerySurface(display,surface,EGL_WIDTH,&amp;width);
  eglQuerySurface(display,surface,EGL_HEIGHT,&amp;height);
  
  glViewport(0,0,width,height);
  
  MY_LOG_MACRO2("New window size: %d x %d",width,height);
  </code></pre>
  
  <p>This works about 20% of the time.  The other 80% of the time the width and height are the previous values.  In other words, most of the time when I turn my device to landscape mode, the portrait size is logged.  And when I go back to portrait, the landscape size is logged.</p>
  
  <p>I haven't had much luck with getting the size from the <code>ANativeWindow</code> either.</p>
  
  <p>What should I be doing to get correct window size after rotation?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>By waiting a few frames after <code>APP_CMD_CONFIG_CHANGED</code>, the size is always correct.  Querying the size every frame, without regard for <code>APP_CMD_CONFIG_CHANGED</code>, and checking if it has changed seems to work as well but feels wrong.</p>