Skip to content

Meshes flicker when retrieving mutable reference from AssetServer before adding new mesh #19409

Open
@Affinator

Description

@Affinator

Bevy version

0.16

Relevant system information

2025-05-28T13:21:01.933062Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA RTX A2000 Laptop GPU", vendor: 4318, device: 9656, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "553.62", backend: Vulkan }
2025-05-28T13:21:02.086063Z  INFO bevy_render::batching::gpu_preprocessing: GPU preprocessing is fully supported on this device.

What you did

I upgraded from 0.15 to 0.16. This worked without flicker before.

What went wrong

I wrote a clustered terrain generator for a strategy game (WIP). The terrain can be changed during gameplay.
After a cluster has been updated, I retrieve the meshes of the adjacent terrain clusters to average the normals at the borders between the clusters.

Starting with 0.16 just retrieving the mesh (independent if I change the mesh or not) to modify it by
if let Some(other_mesh) = meshes.get_mut(other_mesh_handle) {[....]}
creates a flickering mesh. It looks like that another mesh is displayed for a single frame, before the correct mesh is displayed again.

Additional information

screencap.mp4

In this example I am not altering the adjacent meshes. I am just retrieving a mutable borrow from the AssetServer.
If I only retrieve an immutable borrow the flicker disappears.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Needs-ReproductionNeeds an up-to-date or minimal reproduction

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions