Merge "Fix a GL error leak issue"
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index cdf8150..77b66f2 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -25,6 +25,7 @@
 #include "LayerRenderer.h"
 #include "ShadowTessellator.h"
 #include "RenderState.h"
+#include "utils/GLUtils.h"
 
 namespace android {
 
@@ -368,6 +369,12 @@
 
     clearGarbage();
     glFinish();
+
+    // glFinish() need dequeue buffer, and it is not 100% success
+    // It generates gl error sometimes, this error will be there
+    // until glGetError called. Call GLUtils::dumpGLErrors to clean
+    // the error in case it leaks to other functions
+    GLUtils::dumpGLErrors();
 }
 
 ///////////////////////////////////////////////////////////////////////////////