Issue Description
The application crashes when a user, such as a student, enters a room on an Android tablet. Reinstalling the app does not fix the crash. The issue consistently occurs when attempting to render video using TextureView through the SDK's CreateTextureView method.
Platform and SDK Context
Platform: Android
Device: tablet
SDK: Agora RTC SDK v3.4.5.190
Error Message
The application crashes with the following stack trace:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void io.agora.rtc.video.GLTextureView$GLThread.surfaceCreated()' on a null object referenceRoot Cause Analysis
The crash occurs because the device reports an incorrect OpenGL ES version to the system.
When the app checks info.reqGlEsVersion, this specific device returns a value of 0. As a result, the SDK's internal check (ViETextureView.IsSupported) returns false, causing CreateTextureView to fall back and create a GLTextureView instead of a ViETextureView. On this particular device, creating a GLTextureView directly fails to initialize properly, leaving mGLThread as null. When the surface is created, it attempts to invoke surfaceCreated() on this null thread reference, resulting in a NullPointerException.
Solution and Resolution Steps
Do Not Rely on CreateTextureView on the Affected Device
Avoid using the SDK's
CreateTextureViewhelper method on the device. Using it triggers the incorrect fallback logic toGLTextureViewand causes the crash.Create ViETextureView Directly
Modify your application implementation to explicitly instantiate a
ViETextureViewinstead of relying onCreateTextureView. This bypasses the OpenGL ES version check fallback and preventsmGLThreadfrom being null.Optionally Create a Standard TextureView Directly
If applicable to your project architecture, you can also completely bypass the SDK's custom views by directly creating and passing a standard Android
TextureViewfrom your own custom implementation.Test on the Device
After modifying the view creation logic, deploy and test the app on the affected device to verify that the video rendering initializes correctly and the classroom entry flow no longer crashes.
Prevention and Best Practice
Avoid relying solely on
info.reqGlEsVersionto determineTextureViewsupport on devices, as some OEM operating systems may report an incorrect OpenGL ES version.For known affected or problematic devices, instantiate
ViETextureViewdirectly or use a device-specific workaround to prevent the SDK from automatically degrading toGLTextureViewin these edge cases.