[Mesa-dev] [PATCH 5/5] egl/android: Change order of EGLConfig generation

Chad Versace chadversary at chromium.org
Tue Jun 20 17:24:45 UTC 2017


On Tue 20 Jun 2017, Emil Velikov wrote:
> On 17 June 2017 at 03:37, Chad Versace <chadversary at chromium.org> wrote:
> > Many Android apps (such as Google's official NDK GLES2 example app), and
> > even portions the core framework code (such as SystemServiceManager in
> > Nougat), incorrectly choose their EGLConfig.  They neglect to match the
> > EGLConfig's EGL_NATIVE_VISUAL_ID against the window's native format, and
> > instead choose the first EGLConfig whose channel sizes match those of
> > the native window format while ignoring the channel *ordering*.
> >
> > We can detect such buggy clients in logcat when they call
> > eglCreateSurface, by detecting the mismatch between the EGLConfig's
> > format and the window's format.
> >
> > As a workaround, this patch changes the order of EGLConfig generation
> > such that all EGLConfigs for HAL pixel format i precede those for HAL
> > pixel format i+1. In my (chadversary) testing on Android Nougat, this
> > was good enough to pacify the buggy clients.
> > ---
> >  src/egl/drivers/dri2/platform_android.c | 32 +++++++++++++++++++++++++-------
> >  1 file changed, 25 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> > index fcf29bce713..c294691f291 100644
> > --- a/src/egl/drivers/dri2/platform_android.c
> > +++ b/src/egl/drivers/dri2/platform_android.c
> > @@ -1039,23 +1039,41 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
> >     unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
> >     int config_count = 0;
> >
> > -   for (int i = 0; dri2_dpy->driver_configs[i]; i++) {
> > -      for (int j = 0; j < ARRAY_SIZE(visuals); j++) {
> > +   /* The nesting of loops is significant here. Also significant is the order
> > +    * of the HAL pixel formats. Many Android apps (such as Google's official
> > +    * NDK GLES2 example app), and even portions the core framework code (such
> > +    * as SystemServiceManager in Nougat), incorrectly choose their EGLConfig.
> > +    * They neglect to match the EGLConfig's EGL_NATIVE_VISUAL_ID against the
> > +    * window's native format, and instead choose the first EGLConfig whose
> > +    * channel sizes match those of the native window format while ignoring the
> > +    * channel *ordering*.
> > +    *
> > +    * We can detect such buggy clients in logcat when they call
> > +    * eglCreateSurface, by detecting the mismatch between the EGLConfig's
> > +    * format and the window's format.
> > +    *
> > +    * As a workaround, we generate EGLConfigs such that all EGLConfigs for HAL
> > +    * pixel format i precede those for HAL pixel format i+1. In my
> > +    * (chadversary) testing on Android Nougat, this was good enough to pacify
> > +    * the buggy clients.
> 
> Huge thanks for the extensive comment Chad. At the same time - how unfortunate.
> I doubt that you/others will have a chance to address the said bugs?

There is a chance to fix these bugs in the core Android codebase. But
many buggy apps, of course, are out of our control.

> Humble request - can we please make this 1/5 and Cc mesa-stable?

Sure, I will re-order the series to place this patch first.


More information about the mesa-dev mailing list