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

Wasm rendering totally broken in the weirdest way #3763

Closed
SUPERCILEX opened this issue Jan 25, 2022 · 6 comments
Closed

Wasm rendering totally broken in the weirdest way #3763

SUPERCILEX opened this issue Jan 25, 2022 · 6 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@SUPERCILEX
Copy link
Contributor

SUPERCILEX commented Jan 25, 2022

Bevy version

0.6.0

Operating system & version

PopOS 21.10, Chrome 99.0.4840.0

What you did

Run this project: https://github.com/SUPERCILEX/bevy-vs-pixi

Click to add some more rectangles which seems to trigger the issue sooner. Otherwise, wait long enough and rendering will break.

What you expected to happen

Correct rendering. Notice the random color flickering in the background. The frame rate also takes a sudden hit and sometimes the app irreparably freezes.

What actually happened

Video: https://youtu.be/Uu1tus3Rk3U

Note that this only happens in Wasm on the release profile.

Additional information

rustc 1.60.0-nightly (1bd4fdc94 2022-01-12)
binary: rustc
commit-hash: 1bd4fdc943513e1004f498bbf289279c9784fc6f
commit-date: 2022-01-12
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
@SUPERCILEX SUPERCILEX added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 25, 2022
SUPERCILEX added a commit to SUPERCILEX/bevy-vs-pixi that referenced this issue Jan 25, 2022
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen O-Web Specific to web (WASM) builds S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Jan 26, 2022
@superdump
Copy link
Contributor

superdump commented Jan 28, 2022

What GPU and what drivers?

@SUPERCILEX
Copy link
Contributor Author

Just to be clear, it works totally fine when I run it for x86, things only break in Chrome.

Here's the chrome://gpu dump:

Version Information
Data exported	2022-01-28T22:55:56.463Z
Chrome version	Chrome/99.0.4840.0
Operating system	Linux 5.15.15-76051515-generic
Software rendering list URL	https://chromium.googlesource.com/chromium/src/+/c9a107f4a7715fb7dc53d2f0f45d5fe6285d2034/gpu/config/software_rendering_list.json
Driver bug list URL	https://chromium.googlesource.com/chromium/src/+/c9a107f4a7715fb7dc53d2f0f45d5fe6285d2034/gpu/config/gpu_driver_bug_list.json
ANGLE commit id	31942507f384
2D graphics backend	Skia/99 04151728ac473ac17384589d0492f8f899a535ff
Command Line	/usr/bin/google-chrome-unstable --enable-crashpad --flag-switches-begin --enable-gpu-rasterization --enable-zero-copy --ignore-gpu-blocklist --enable-features=CanvasOopRasterization --flag-switches-end --origin-trial-disabled-features=CaptureHandle
Driver Information
Initialization time	216
In-process GPU	false
Passthrough Command Decoder	true
Sandboxed	true
GPU0	VENDOR= 0x10de, DEVICE=0x1f12 *ACTIVE*
GPU1	VENDOR= 0x8086, DEVICE=0x9bc4
Optimus	true
AMD switchable	false
Driver vendor	Nvidia
Driver version	470.86
GPU CUDA compute capability major version	0
Pixel shader version	1.00
Vertex shader version	1.00
Max. MSAA samples	8
Machine model name	
Machine model version	
GL_VENDOR	Google Inc. (NVIDIA Corporation)
GL_RENDERER	ANGLE (NVIDIA Corporation, NVIDIA GeForce RTX 2060 with Max-Q Design/PCIe/SSE2, OpenGL 4.5.0 NVIDIA 470.86)
GL_VERSION	OpenGL ES 2.0.0 (ANGLE 2.1.17709 git hash: 31942507f384)
GL_EXTENSIONS	GL_ANGLE_base_vertex_base_instance GL_ANGLE_base_vertex_base_instance_shader_builtin GL_ANGLE_client_arrays GL_ANGLE_depth_texture GL_ANGLE_framebuffer_blit GL_ANGLE_framebuffer_multisample GL_ANGLE_get_serialized_context_string GL_ANGLE_get_tex_level_parameter GL_ANGLE_instanced_arrays GL_ANGLE_memory_size GL_ANGLE_multi_draw GL_ANGLE_multiview_multisample GL_ANGLE_program_cache_control GL_ANGLE_provoking_vertex GL_ANGLE_request_extension GL_ANGLE_robust_client_memory GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_ANGLE_texture_external_update GL_ANGLE_texture_rectangle GL_ANGLE_translated_shader_source GL_APPLE_clip_distance GL_ARB_sync GL_CHROMIUM_bind_generates_resource GL_CHROMIUM_bind_uniform_location GL_CHROMIUM_color_buffer_float_rgb GL_CHROMIUM_color_buffer_float_rgba GL_CHROMIUM_copy_texture GL_CHROMIUM_framebuffer_mixed_samples GL_CHROMIUM_lose_context GL_CHROMIUM_sync_query GL_EXT_blend_func_extended GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_disjoint_timer_query GL_EXT_draw_buffers GL_EXT_draw_elements_base_vertex GL_EXT_float_blend GL_EXT_frag_depth GL_EXT_gpu_shader5 GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_multi_draw_indirect GL_EXT_multisample_compatibility GL_EXT_occlusion_query_boolean GL_EXT_read_format_bgra GL_EXT_robustness GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_semaphore GL_EXT_semaphore_fd GL_EXT_shader_io_blocks GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_texture_buffer GL_EXT_texture_compression_bptc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc_srgb GL_EXT_texture_cube_map_array GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_decode GL_EXT_texture_storage GL_EXT_unpack_subimage GL_KHR_debug GL_KHR_parallel_shader_compile GL_NV_depth_buffer_float2 GL_NV_fence GL_NV_framebuffer_blit GL_NV_pack_subimage GL_NV_pixel_buffer_object GL_NV_read_depth GL_NV_read_stencil GL_NV_robustness_video_memory_purge GL_NV_shader_noperspective_interpolation GL_OES_compressed_EAC_R11_signed_texture GL_OES_compressed_EAC_R11_unsigned_texture GL_OES_compressed_EAC_RG11_signed_texture GL_OES_compressed_EAC_RG11_unsigned_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_ETC2_RGB8_texture GL_OES_compressed_ETC2_RGBA8_texture GL_OES_compressed_ETC2_punchthroughA_RGBA8_texture GL_OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture GL_OES_compressed_ETC2_sRGB8_alpha8_texture GL_OES_compressed_ETC2_sRGB8_texture GL_OES_depth24 GL_OES_depth32 GL_OES_depth_texture GL_OES_draw_elements_base_vertex GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_get_program_binary GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_shader_image_atomic GL_OES_shader_io_blocks GL_OES_standard_derivatives GL_OES_surfaceless_context GL_OES_texture_3D GL_OES_texture_border_clamp GL_OES_texture_buffer GL_OES_texture_cube_map_array GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_texture_stencil8 GL_OES_vertex_array_object GL_WEBGL_video_texture
Disabled Extensions	GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent
Disabled WebGL Extensions	
Window system binding vendor	Google Inc. (NVIDIA Corporation)
Window system binding version	1.5 (ANGLE 2.1.17709 git hash: 31942507f384)
Window system binding extensions	EGL_EXT_create_context_robustness EGL_KHR_create_context EGL_KHR_get_all_proc_addresses EGL_ANGLE_create_context_webgl_compatibility EGL_CHROMIUM_create_context_bind_generates_resource EGL_EXT_pixel_format_float EGL_KHR_surfaceless_context EGL_ANGLE_display_texture_share_group EGL_ANGLE_display_semaphore_share_group EGL_ANGLE_create_context_client_arrays EGL_ANGLE_program_cache_control EGL_ANGLE_robust_resource_initialization EGL_ANGLE_create_context_extensions_enabled EGL_ANDROID_blob_cache EGL_ANDROID_recordable EGL_ANGLE_create_context_backwards_compatible EGL_KHR_create_context_no_error EGL_NOK_texture_from_pixmap EGL_NV_robustness_video_memory_purge EGL_KHR_reusable_sync EGL_KHR_mutable_render_buffer
XDG_CURRENT_DESKTOP	pop:GNOME
XDG_SESSION_TYPE	x11
GDMSESSION	pop
Ozone platform	x11
Direct rendering version	unknown
Reset notification strategy	0x8252
GPU process crash count	3
gfx::BufferFormats supported for allocation and texturing	R_8: not supported, R_16: not supported, RG_88: not supported, RG_1616: not supported, BGR_565: not supported, RGBA_4444: not supported, RGBX_8888: not supported, RGBA_8888: not supported, BGRX_8888: not supported, BGRA_1010102: not supported, RGBA_1010102: not supported, BGRA_8888: not supported, RGBA_F16: not supported, YVU_420: not supported, YUV_420_BIPLANAR: not supported, P010: not supported
Compositor Information
Tile Update Mode	Zero-copy
Partial Raster	Enabled
GpuMemoryBuffers Status
R_8	Software only
R_16	Software only
RG_88	Software only
RG_1616	Software only
BGR_565	Software only
RGBA_4444	Software only
RGBX_8888	Software only
RGBA_8888	Software only
BGRX_8888	Software only
BGRA_1010102	Software only
RGBA_1010102	Software only
BGRA_8888	Software only
RGBA_F16	Software only
YVU_420	Software only
YUV_420_BIPLANAR	Software only
P010	Software only
Display(s) Information
Info	Display[0] bounds=[1280,0 1280x1440], workarea=[1280,0 1280x1440], scale=3, rotation=0, panel_rotation=0 external.
Color space (all)	{primaries:BT709, transfer:IEC61966_2_1, matrix:RGB, range:FULL}
Buffer format (all)	BGRA_8888
SDR white level in nits	100
HDR relative maximum luminance	1
Bits per color component	8
Bits per pixel	24
Refresh Rate in Hz	59
Info	Display[2] bounds=[0,0 1280x1440], workarea=[0,0 1280x1440], scale=3, rotation=0, panel_rotation=0 external.
Color space (all)	{primaries:BT709, transfer:IEC61966_2_1, matrix:RGB, range:FULL}
Buffer format (all)	BGRA_8888
SDR white level in nits	100
HDR relative maximum luminance	1
Bits per color component	8
Bits per pixel	24
Refresh Rate in Hz	59
Video Acceleration Information
Encoding	
Vulkan Information
Device Performance Information

@SUPERCILEX
Copy link
Contributor Author

Also, I disabled all my chrome flags (just to check) and the bug is still there. Is there any other info I can provide?

@SarthakSingh31
Copy link
Contributor

The random color flickering and irrecoverable freezes don't seem to happen on the default allocator leading me to believe that wee_alloc is doing something weird.

The performance is still pretty bad on the default allocator because bevy_prototype_lyon doesn't utilize batching yet, creating a lot of draw calls for the browser. On my browser ~70% of the time is spent inside the browser inbuilt tools (i. e. WebGL2RenderingContext::*) when try to render 16000 rectangles.

Call tree screenshot

Call tree screenshot

@SUPERCILEX
Copy link
Contributor Author

SUPERCILEX commented Jan 30, 2022

Wow, thank you for finding that! I used wee because of this guide: https://bevy-cheatbook.github.io/platforms/wasm/size-opt.html#use-the-wee-alloc-memory-allocator. Should that recommendation maybe be removed? Or is it possible that Bevy has a memory corruption bug that doesn't manifest with the normal allocator? In the meantime, I filed rustwasm/wee_alloc#105.

@SUPERCILEX
Copy link
Contributor Author

Closing since this is really a wee alloc issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Web Specific to web (WASM) builds S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

4 participants