title: Asynctask (progressDialog) - Failed to set damage region EGL_BAD_ACCESS
body: <p>Help me - I am really stuck on the following issue:</p>
  
  <p>The exception is thrown outside the scope of JVM and cannot be handled unless you know the NDK.</p>
  
  <pre><code>03-23 17:48:24.463 18768-18913/se.android.appinfo E/Parcel: fcntl(F_DUPFD_CLOEXEC) failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 1, error: Too many open files
  03-23 17:48:24.464 18768-18913/se.android.appinfo I/OpenGLRenderer: Surface query width is 1440
  03-23 17:48:24.464 18768-18913/se.android.appinfo A/OpenGLRenderer: Failed to set damage region on surface 0x7edceec8c0, error=EGL_BAD_ACCESS
  03-23 17:48:24.467 18768-18913/se.android.appinfo A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 18913 (RenderThread)
  </code></pre>
  
  <p>I guess the last ones about EGL and OpenGL ES is relevant here?</p>
  
  <p>I have struggled hours and googled about it and cannot find any solutions. And this problem is new to me - this has never occurred to me - I made apps before using Asynctask and showing a progressdialog while loading.</p>
  
  <p>The crash occurs somewhere in between the mainthread and backgroundthread. It does not occur every time, maybe 50% or something. When the crash comes its when the doInBackground is done or almost done and onPostExecute is to be called.</p>
  
  <p>Please - take a notice of my source and help me if you suspect anything that throws the exception (Fatal signal).</p>
  
  <p>source - custom class extending AsyncTask</p>
  
  <pre><code> public class Async_loader extends AsyncTask &lt;String, Integer, String&gt; implements AppInfoRetriever.ProgressInterface {
  
  private Context context;
  private AppInfoRetriever appInfoRetriever;
  private ProgressDialog progressDialog;
  
  public Async_loader(Context context, AppInfoRetriever appInfoRetriever) {
  
      this.context = context;
      this.appInfoRetriever = appInfoRetriever;
      this.appInfoRetriever.setProgressInterface(this);
  
      progressDialog = new ProgressDialog(context);
      progressDialog.setCancelable(false);
      progressDialog.setIndeterminate(false);
      progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
      progressDialog.show();
  
  }
  
  public String doInBackground(String ... params) {
  
      try {
          appInfoRetriever.retrieve();
      } catch(PackageManager.NameNotFoundException nnfe) {
  
          nnfe.printStackTrace();
      }
      appInfoRetriever.splitToUserSystemApps();
  
      return "loading done";
  }
  
  @Override
  public void onProgressUpdate(final Integer ... values) {
  
      progressDialog.setProgress(values[0]);
      progressDialog.setMessage("parsing apps: " + values[0]);
  }
  
  
  public void onPostExecute(String result) {
  
  
      System.err.println(result);
      progressDialog.dismiss();
  }
  
  /**
   * Callback från AppInfoRetriever
   * @param nItems
   * @param index
   */
  @Override
  public void appLoadingProgress(int nItems, int index) {
  
      publishProgress(index);
  
   }
  }
  </code></pre>
  
  <p>Good to know: Since I want to decouple code I let the AppInfoRetriever parse the apps and while parsing sending (via an interface) information back to Async_loader. I thought this may be the problem but I've tried to lift in the code to Async_loader but no success.</p>