Android App with Go Library Causes OpenGL Errors


I am working on an Android application developed in Kotlin that integrates a third-party library written in Go. This library has been compiled as an AAR file and integrated through Gradle's build.gradle.kts.

The Go library exposes a class named MyGoClass containing various methods. However, whenever I invoke any method within MyGoClass, my Logcat shows error messages similar to these:

11:12:44.543 GoLog E s_glBindAttribLocation: bind attrib 0 name inPosition
11:12:44.543 GoLog E s_glBindAttribLocation: bind attrib 1 name inColor
11:12:44.543 GoLog E s_glBindAttribLocation: bind attrib 2 name inCircleEdge

These errors arise in tests on emulator (Android Studio, emulator Pixel 7) under specific circumstances:

Example Scenarios Scenario 1: Error During Initial Rendering and First Click Event When drawing a button and clicking it for the very first time, the following code reproduces the issue:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            GoImportLibraryTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    MyGoClass.test()
                    Button(
                        onClick = {
                            Toast.makeText(applicationContext, "Hello, this is a Toast!",
                                Toast.LENGTH_SHORT).show()
                        },
                        modifier = Modifier.padding(innerPadding)
                    ) {}
                }
            }
        }
    }
}

Scenario 2: Error Only on First Click After Moving Method Call Inside OnClick Listener If I move the invocation of MyGoClass.test() inside the onClick event listener, then the error appears only on the initial button press:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            GoImportLibraryTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Button(
                        onClick = {
                            MyGoClass.test()
                            Toast.makeText(applicationContext, "Hello, this is a Toast!",
                                Toast.LENGTH_SHORT).show()
                        },
                        modifier = Modifier.padding(innerPadding)
                    ) {}
                }
            }
        }
    }
}

Note: These examples use MyGoClass merely as a placeholder. I have tried multiple libraries, and they exhibit the same behavior. All libraries were compiled using gomobile -target=android.

What could be causing these OpenGL-related errors, and what steps can I take to resolve them?

Thank you!

1
Jul 16 at 6:48 AM
User Avatarhe1ex-tG
#android#go#opengl-es#gomobile

No answer found for this question yet.