Skip to content
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

[WIP] 2D GLES3 project without (3D) Camera node crashes (Sky-related?) #32823

Closed
follower opened this issue Oct 14, 2019 · 3 comments
Closed

Comments

@follower
Copy link
Contributor

follower commented Oct 14, 2019

[This bug report is a "Work In Progress" due to a large amount of supporting data that needs to be attached/explained & somewhat convoluted & uncertain underlying cause--and GitHub not having a "save as draft" option. :) ]

Godot version: v3.2.alpha2.official

OS/device including version: Mac OS X 10.9.5 / OpenGL ES 3.0 Renderer: NVIDIA GeForce GT 650M OpenGL Engine

Issue description:

A 2D GLES3 project without a (3D) Camera node crashes (after up to ~ 30 seconds has elapsed) in the GPU driver--seemingly due to a null pointer?--perhaps caused by procedural sky in default Godot environment? (The editor frequently also crashes when modifying the project & running under GLES3.)

  • The same MRP project runs without crashing under GLES2--but does cause some warnings to appear.

  • A workaround is to add a (3D) Camera node to the scene. I've seen apparently conflicting results in relation to whether the node needs to be visible or can be hidden.

  • Modifying default_env.tres to have a "Background Mode" of "Clear Color" may also prevent the crash.

  • Underlying issue seems it may be related to a shader accessing an uninitialized cube-map texture normally used for GIProbe and/or reflection?

[TODO: Add render quality setting observations.]

Godot traceback log:

$ /Users/USER/Downloads/Godot-v3.2-alpha2_osx.64.app/Contents/MacOS/Godot --video-driver GLES3 --path /Users/USER/Projects/godot/3.2-alpha2-gles3-2d-no-camera-issue res://ColorRect.tscn
arguments
0: /Users/USER/Downloads/Godot-v3.2-alpha2_osx.64.app/Contents/MacOS/Godot
1: --video-driver
2: GLES3
3: --path
4: /Users/USER/Projects/godot/3.2-alpha2-gles3-2d-no-camera-issue
5: res://ColorRect.tscn
Current path: /Users/USER/Downloads/Godot-v3.2-alpha2_osx.64.app/Contents/Resources
Godot Engine v3.2.alpha2.official - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GT 650M OpenGL Engine
Registered camera FaceTime HD Camera (Built-in) with id 1 position 0 at index 0
 
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] 1   libsystem_platform.dylib            0x00007fff939735aa _sigtramp + 26
[2] 2   ???                                 0x0000000000000000 0x0 + 0
[3] 3   GeForceGLDriver                     0x00001234402b9706 gldReadTextureData + 688435
[4] 4   GeForceGLDriver                     0x00001234401dd19b GeForceGLDriver + 1954203
[5] 5   GeForceGLDriver                     0x00001234401e2f4a GeForceGLDriver + 1978186
[6] 6   GeForceGLDriver                     0x00001234402e0760 gldReadTextureData + 848269
[7] 7   libGPUSupportMercury.dylib          0x00007fff92759f8e gldUpdateDrawFramebuffer + 168
[8] 8   GLEngine                            0x00007fff90c0c407 gleUpdateDrawFramebufferState + 525
[9] 9   GLEngine                            0x00007fff90c0d60c gleDoDrawDispatchCoreGL3 + 104
[10] 10  GLEngine                            0x00007fff90bc1d9a gleDrawArraysOrElements_Entries_Body + 116
[11] 11  GLEngine                            0x00007fff90bbb29b glDrawArrays_GL3Exec + 194
[12] RasterizerCanvasGLES3::canvas_render_items(RasterizerCanvas::Item*, int, Color const&, RasterizerCanvas::Light*, Transform2D const&) (in Godot) + 89212
[13] VisualServerCanvas::render_canvas(VisualServerCanvas::Canvas*, Transform2D const&, RasterizerCanvas::Light*, RasterizerCanvas::Light*, Rect2 const&) (in Godot) + 1915
[14] VisualServerViewport::_draw_viewport(VisualServerViewport::Viewport*, ARVRInterface::Eyes) (in Godot) + 2819
[15] VisualServerViewport::draw_viewports() (in Godot) + 992
[16] VisualServerRaster::draw(bool, double) (in Godot) + 323
[17] Main::iteration() (in Godot) + 1028
[18] OS_OSX::run() (in Godot) + 634
[19] main (in Godot) + 811
[20] 20  libdyld.dylib                       0x00007fff8d8275fd start + 1
[21] 21  ???                                 0x0000000000000006 0x0 + 6
-- END OF BACKTRACE --
Abort trap: 6

[TODO: Add details from OS crash log.]

Steps to reproduce: [TODO: Describe how to add ColorRect node with default color to project is enough to trigger the crash.]

Minimal reproduction project: 3.2-alpha2-gles3-2d-no-camera-issue.zip

(The issue has also been observed "in the wild" when running this Seedlings-osx-0.6.5-a.zip demo.)

Edit: Note also that I previously encountered what appears to be the same crash back in March: #27222 (comment) (I have some vague recollection of GLES3 & Godot 3.something not working, then working, then not working again around that time.)

Minimal workaround example project: 3.2-alpha2-gles3-2d-no-camera-issue-workaround.zip

OpenGL debugging with apitrace

As I've had success with using apitrace in the past to debug convoluted OpenGL issues, I again used apitrace to get some more insight into what is happening.

First I generated an OpenGL trace file of the time proceeding the crash with the apitrace tool (that I had built on a previous occasion):

./build/apitrace trace --verbose /Users/USER/Downloads/Godot-v3.2-alpha2_osx.64.app/Contents/MacOS/Godot -- --video-driver GLES3 --path /Users/USER/PATH/3.2-alpha2-gles3-2d-no-camera-issue res://ColorRect.tscn

Then I used the qapitrace GUI viewer tool to analyze the trace:

./build/qapitrace /Users/USER/PATH/3.2-alpha2-gles3-2d-no-camera-issue/Godot.trace

apitrace trace observations

This screenshot shows the "suspicious" cube map surfaces I observed early on in a GLES3 run that crashes, note the seemingly "random noise" values:

godot-apitrace-mrp-gles3-suspicious-surfaces-crash--cubemap

A zoomed version of one of the suspicious cube map surfaces:

godot-apitrace-mrp-gles3-suspicious-surfaces-crash--cubemap--zoom-enhance

The apparently "clean" cube map surfaces visible when the 3D Camera node GLES3 workaround is used:

godot-apitrace-mrp-workaround-gles3-surfaces-logs--cubemap

The associated sky texture that also appears in the trace when the GLES3 camera workaround is used:

godot-apitrace-mrp-workaround-gles3-surfaces-logs--sky

The "correct?" skybox cube map surfaces (and warning logs) that are visible in the non-crashing GLES2 traces:

godot-apitrace-mrp-gles2-surfaces-no-crash-logs

The sequence of OpenGL calls that result in the crash under GLES3:

godot-apitrace-mrp-gles3-opengl-function-calls-crash

The above function call sequence seems to correspond to this section of code:

case Item::Command::TYPE_RECT: {
Item::CommandRect *rect = static_cast<Item::CommandRect *>(c);
_set_texture_rect_mode(true);
//set color
glVertexAttrib4f(VS::ARRAY_COLOR, rect->modulate.r, rect->modulate.g, rect->modulate.b, rect->modulate.a);
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(rect->texture, rect->normal_map);
if (texture) {
bool untile = false;
if (rect->flags & CANVAS_RECT_TILE && !(texture->flags & VS::TEXTURE_FLAG_REPEAT)) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
untile = true;
}
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
Rect2 src_rect = (rect->flags & CANVAS_RECT_REGION) ? Rect2(rect->source.position * texpixel_size, rect->source.size * texpixel_size) : Rect2(0, 0, 1, 1);
Rect2 dst_rect = Rect2(rect->rect.position, rect->rect.size);
if (dst_rect.size.width < 0) {
dst_rect.position.x += dst_rect.size.width;
dst_rect.size.width *= -1;
}
if (dst_rect.size.height < 0) {
dst_rect.position.y += dst_rect.size.height;
dst_rect.size.height *= -1;
}
if (rect->flags & CANVAS_RECT_FLIP_H) {
src_rect.size.x *= -1;
}
if (rect->flags & CANVAS_RECT_FLIP_V) {
src_rect.size.y *= -1;
}
if (rect->flags & CANVAS_RECT_TRANSPOSE) {
dst_rect.size.x *= -1; // Encoding in the dst_rect.z uniform
}
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(src_rect.position.x, src_rect.position.y, src_rect.size.x, src_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::CLIP_RECT_UV, rect->flags & CANVAS_RECT_CLIP_UV);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
if (untile) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
} else {
Rect2 dst_rect = Rect2(rect->rect.position, rect->rect.size);
if (dst_rect.size.width < 0) {
dst_rect.position.x += dst_rect.size.width;
dst_rect.size.width *= -1;
}
if (dst_rect.size.height < 0) {
dst_rect.position.y += dst_rect.size.height;
dst_rect.size.height *= -1;
}
state.canvas_shader.set_uniform(CanvasShaderGLES3::DST_RECT, Color(dst_rect.position.x, dst_rect.position.y, dst_rect.size.x, dst_rect.size.y));
state.canvas_shader.set_uniform(CanvasShaderGLES3::SRC_RECT, Color(0, 0, 1, 1));
state.canvas_shader.set_uniform(CanvasShaderGLES3::CLIP_RECT_UV, false);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
storage->frame.canvas_draw_commands++;
} break;

[TODO: Add links to potentially related/informative source code including: godot/drivers/gles3/rasterizer_canvas_gles3.cpp, drivers/gles3/rasterizer_scene_gles3.cpp, drivers/gles2/rasterizer_scene_gles2.cpp, drivers/gles2/rasterizer_storage_gles2.cpp, drivers/gles3/rasterizer_storage_gles3.cpp, godot/drivers/gles3/shaders/copy.glsl, _draw_sky(), RasterizerSceneGLES3::reflection_probe_instance_postprocess_step() & RasterizerSceneGLES2::reflection_probe_instance_begin_render().]

[TODO: To be continued... :) ]

@follower
Copy link
Contributor Author

Updated main description to include screenshots of suspicious surfaces from OpenGL traces & add some breadcrumbs/links to potentially related issues & source code.

Not sure when I'll get back to writing this up but hopefully there's enough here that someone more familiar with the rendering side of things can identify the root cause of the apparent uninitialized or incorrectly referenced surfaces/textures.

@clayjohn
Copy link
Member

clayjohn commented Oct 14, 2019

I can't reproduce on Windows 10 Nvidia 1050.

I've had the MRP running for about 5 minutes and nothing has happened.

This stackoverflow question has a comment from someone with your same setup experiencing the crash

Sounds like its an NVidia driver issue. Seeing as it doesn't crash on my 1050, I'm guessing newer drivers handle this more gracefully? In which case, are you able to just update your drivers? (not sure if its possible on such an old GPU)

@clayjohn
Copy link
Member

No response. So closing. If you need further help, please comment and I can reopen. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants