-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenGL texture upload segfault (GLES Android) #251
Comments
Can you provide a reproducer? The row stride is set by |
First I thought that I can easily reproduce it by simply changing your So I digged deeper and found the reason. In our code we use OpenCV for all image related operations which include loading and saving. In your samples you use other third party libs (libjpeg, libpng etc).
Even though you set the row stride by it still fails on Android (probably also iOS but I don't have a device here) with a segfault in
As I've had this issue already in the past on mobile platforms I knew that it has to be the Still, this issue is not present on the desktop - that's why I assume that GL and GLES behaves differently in this regard. |
One thing I should have added to my previous answer is the explanation why it's not enough in this case to set the
So the row-length is set to 592 bytes but the image has a stride of 589 bytes and therefore it makes totally sense that it crashes with a segfault. By setting
The thing I don't understand is why it doesn't happen on the desktop as well. |
Row stride must be aligned by 4 bytes to be consistent with other backends. A debug check that validates parameters is missing, I will add it. |
I've found a bug in your texture upload mechanism for OpenGL on Android. Basically you set the packing alignment to a fixed value of 4 with
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
. This can be problematic for 1 or 3 channel textures if the stride of the image is not a multiple of 4 bytes. You should basically check if the stride is a multiple of 8, 4, 2 or 1 and set it accordingly.I'm not sure if this is GL implementation dependent (as it works on my desktop using OpenGL but not with OpenGL ES on Android). Maybe
GL_UNPACK_ROW_LENGTH
that you already use is ignored by GLES and therefore it doesn't work on Android. AFAIKGL_UNPACK_ALIGNMENT
is used by all implementations.The text was updated successfully, but these errors were encountered: