E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY) API 24 or higher

Nooby12345 picture Nooby12345 · Sep 6, 2017 · Viewed 8.3k times · Source

I am getting this error when I use a device with an API that is 24 or higher:

E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)

XML code = (activity_main.xml)

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="charliedek.test.MainActivity">

    <WebView
        android:id = "@+id/webView"
        android:layout_width="368dp"
        android:layout_height="495dp"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp" />
</android.support.constraint.ConstraintLayout>

Java code = (MainActivity.java)

package charliedek.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String myurl="file:///android_asset/index.html";
        WebView view = (WebView) this.findViewById(R.id.webView);
        view.getSettings().setJavaScriptEnabled(true);
        view.loadUrl(myurl);
    }
}

HTML code = (index.html)

<html>
    <body>
        <button><a href = "second.html"> Go To Second Page</a></button>
    </body>
</html>

HTML code = (second.html)

<html>
    <body>
        <button><a href = "index.html"> Go To First Page</a></button>
    </body>
</html>

The app crashes whenever the button is clicked! Any help would be appreciated.

Answer

darclander picture darclander · Dec 25, 2020

After reading through different documentations and questions with a similar issue to yours it seems like WebView was one cause of the problem where users simply removed the implementation which resolved their error. In this github thread a user had this solution:

I had the same issue when I tried to load webview on Dialog. If I load webview on activity, it works well.

This github issue thread also seems to go through similar issues.

This stackoverflow question also had a problem with WebView which was resolved by:

After a few weeks, I found out this https://developer.android.com/about/versions/android-5.0-changes.html#BehaviorWebView which explains the changes of api 21. Take a look at the WebView part that says:

If your application works with API level 21 or later:

  • The system locks mixed content and third-party cookies by default. To allow mixed content and third-party cookies, use the methods
    setMixedContentMode() and setAcceptThirdPartyCookies(), respectively.

So, I only added these configurations into WebViewand it worked perfectly.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

    webSettings.setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW);
    CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);

}

And according to what I have read and the issue is related to WebView is the first step to go. But it seems like the issue you have with the API version 24 or above is very similar to the topics I linked to. So my suggestion would be to try the answer found in the stackoverflow question and if that does not work maybe read through the solutions from the github issues.