Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:52:34+00:00 2026-05-23T19:52:34+00:00

While there are many samples around about using OpenGL ES on Android all of

  • 0

While there are many samples around about using OpenGL ES on Android all of them seems to be incorrect (even ones come with Android SDK/NDK) in respect to initialization/termination of EGL. And source of problem is just in Android application model which make correct using of EGL weird.

The real problem that EGL initialized per OS’s process while all Android samples and even GLSurfaceView (actually most of samples just use it) involve the EGL initialization/termination per Component (Activity or WallpaperService). And this is completely wrong due to the fact that all components are running in same process! There is no problem if application consist of just one component but this is an issue if there are multiple components in application and they are using OpenGL ES each.

Just consider the situation when two application’s components which use the OpenGL ES runs at same time and one of them finished. On finishing such component will call the eglTerminate() (Look in GLSurfaceView source code to see what I am talking about) and this will terminate the EGL for whole process! And any EGL calls from another already running component will fail starting from this moment!

I have check for tons of examples and all of them initialize and terminate EGL per component basis (actually no one I have seen do something different than GLSurfaceView do, most of them just copy of GLSurfaceView internals).

And now I am interesting in find a "proper" way to get working (with respect to initialization/termination) with EGL on Android.

The "proper" way should provide:

  1. EGL initialization when any first component using EGL is started
  2. EGL termination when last component using EGL is finished
  3. Multithreading. There is should not be restriction on EGL manipulation only from main application thread.

Please note that (2) is essential to minimize the system resources usage by application when there is no active entities which use the EGL/OpenGL ES.

Any ideas? Or maybe I have overlooked something about the EGL on Android?

Update

There is another interesting related issue:

Due to the fact that only one active rendering context is allowed per thread, only one Component at same time may use OpenGL ES from main thread normally. Having more than one Component which use the OpenGL ES in main thread running at same time will lead to problems because last component calling eglMakeCurrent() will implicitly "substitute" all other Components’ contexts by his own one (and this actually will completely broke the components logic).

Update 2 (final)

It was revealed (thanks to Romain Guy) that Android actually has an internal workaround for EGL initialization/termination issue in a form of explicit (it is against the EGL specification and not mentioned in the Android documentation) "reference counting" inside the eglInitialize() and eglTerminate().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:52:34+00:00Added an answer on May 23, 2026 at 7:52 pm

    eglTerminate() and eglInitialize() are reference counted so it’s okay for each “component” to invoke them. On Android 3.0 in particular, it is very common to have several OpenGL contexts in the same app, and there is no problem whatsoever with EGL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While there are many good online and offline tools for testing regular expressions, I
While there are many guides for Browser Helper Objects, i have a hard time
I'm new at javascript and while there are many more complex solutions, I don't
There has been many Questions recently about drawing PDF's. Yes, you can render PDF's
While there are 100 ways to solve the conversion problem, I am focusing on
While there are a handful of great programs for ISV Startups (BizSpark, Emplower ISV,
While there are multiple ways to reverse bit order in a byte, I'm curious
I am building a multithreaded system that works like this: While there are entities:
What are some key UI design tips that every developer should know? While there
I've switch from VB.NET to C# several months ago, while there are a lot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.