Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug (Case 1179839) Additively load scene replaces existing MeshFilter's mesh to static batched mesh.

Discussion in '2019.3 Beta' started by Kichang-Kim, Sep 4, 2019.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,008
    Hi, I found that additively loading scene which has static batched mesh replaces the mesh of MeshFilter in existing scene to static batched mesh in loaded scene.

    Reproducible project are sent as Case 1179839.

    This issue breaks manual asset management like this:
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,132
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,008
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Hey, that's my bug!

    I've gotten back from QA that it's a low-priority bug that probably won't be fixed. I've been nagging them to actually fix this through every channel I can.

    What's happening is that Unity is running the static batcher in an insane way in the editor that makes no sense, and doesn't happen in builds. It's preventing us from testing with static batching in the editor, as the static batching adds a minute to how long it takes to enter play mode.

    Here's how things seem to work if you enter play mode with several scenes open, and static batching enabled:
    - Unity runs static batching for the first scene.
    - Unity loads the second scene additively
    - Unity (probably) throws away the static batching it did for the first scene.
    - Unity runs static batching for the first and the second scene together as a single unit.
    - Unity loads the third scene additively
    - Unity (probably) throws away the static batching it did for the first and second scenes scene.
    - Unity runs static batching for the first, second and third scenes together as a single unit.
    - etc. etc.

    Meaning that if you have n scenes, each with mn elements, it's going to static batch n*m0 + (n-1)*m1 + (n-2)*m2 + ... + 2*mn-1 + mn objects. That's a lot.

    The worst thing is that this isn't happening in builds, so Unity is wasting a ton of time trying to optimize the scene geometry in the editor in ways that's not representative of how it's going to look in builds.
     
  5. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,008
    Hi. It seems that my issue is slightly different to your issue (but related?).

    In my case,

    1. Scene A has Mesh A
    2. Scene B has Mesh A with other meshes. And Mesh A is statically batched called Combined mesh B.
    3. Loading Scene A.
    4. Additively Loading Scene B.
    5. Scene A's Mesh A is replaced to Scene B's Combined mesh B.
    6. Unloading Scene B and manually destroying Combined mesh B.
    7. Mesh A of Scene A is missing!

    And occurred in actual build (on device) too.

    I gathered all references to meshes in scene by using IProcessSceneWithReport for manual memory management, so it may be related to this issue too:
    https://forum.unity.com/threads/cas...load-scene-from-assetbundle-in-editor.739523/
     
    Last edited: Oct 1, 2019