gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Visual plugin is loaded multiple times

Open srmainwaring opened this issue 1 year ago • 0 comments

Environment

  • OS Version: macOS Big Sur 11.6.2

  • Source or binary build? build: source, branch: gz-sim7, commit: d90fab283c7b4c26ffa8a5af9fff055ff21718b1

  • If this is a GUI or sensor rendering bug, describe your GPU and rendering system. Otherwise delete this section.

    • Rendering plugin: [ogre2].
      • [ x ] running on real hardware
      • [ x ] GPU is concurrently used for other tasks
        • [ x ] desktop acceleration
    • Rendering system info:
2022-08-13 15:45:06.469 system_profiler[80028:24179151] Device PreExisted [000000010000096a] AMD Radeon Pro W5700X
Graphics/Displays:

    AMD Radeon Pro W5700X:

      Chipset Model: AMD Radeon Pro W5700X
      Type: GPU
      Bus: PCIe
      Slot: Slot-1
      PCIe Lane Width: x16
      VRAM (Total): 16 GB
      Vendor: AMD (0x1002)
      Device ID: 0x7310
      Revision ID: 0x0000
      ROM Revision: 113-D1860W-213
      VBIOS Version: 113-D186A2XT-019
      Option ROM Version: 113-D186A2XT-019
      EFI Driver Version: 01.01.200
      Metal Family: Supported, Metal GPUFamily macOS 2
      Displays:
        Cinema HD:
          Display Type: LCD
          Resolution: 2560 x 1600
          UI Looks like: 2560 x 1600
          Framebuffer Depth: 30-Bit Color (ARGB2101010)
          Display Serial Number: CY628129UG1
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Rotation: Supported
          Automatically Adjust Brightness: Yes
          Connection Type: DVI or HDMI
          Adapter Firmware Version: 2.21

Description

  • Expected behaviour: a single copy of the visual plugin is constructed and configured.
  • Actual behaviour: multiple copies of the visual plugin are constructed and configured.

Bisection indicates that change is due to #1352, and in particular src/gui/plugins/scene_manager/GzSceneManager.cc. Reverting this file restores the previous behaviour.

Steps to reproduce

  1. Edit src/systems/shader_param/ShaderParam.cc and add the following messages in ShaderParam::Configure after the entity has been captured (L238-240).
  gzmsg << "ShaderParam: configuring\n";
  gzmsg << "ShaderParam: entity: " << this->dataPtr->entity << "\n";
  gzmsg << "ShaderParam: visualName: " << this->dataPtr->visualName << "\n";
  1. Rebuild and run the shader_params example
gz sim -v4 -r shader_param.sdf

Output

Output from VSCode Debug Console filtering on ShaderParam

Warning [Utils.cc:129] [/sdf/plugin[@name="gz::sim::systems::ShaderParam"]:<data-string>:L1]: XML Element[plugin], child of element[sdf], not defined in SDF. Copying[plugin] as children of [sdf].
[GUI] [Msg] ShaderParam: configuring
[GUI] [Msg] ShaderParam: entity: 6
[GUI] [Msg] ShaderParam: visualName: sphere_visual
[GUI] [Dbg] [GuiRunner.cc:375] Loaded system [gz::sim::systems::ShaderParam] for entity [6] in GUI
[GUI] [Msg] ShaderParam: configuring
[GUI] [Msg] ShaderParam: entity: 6
[GUI] [Msg] ShaderParam: visualName: sphere_visual
[GUI] [Dbg] [GuiRunner.cc:375] Loaded system [gz::sim::systems::ShaderParam] for entity [6] in GUI
[GUI] [Msg] ShaderParam: configuring
[GUI] [Msg] ShaderParam: entity: 6
[GUI] [Msg] ShaderParam: visualName: sphere_visual
[GUI] [Dbg] [GuiRunner.cc:375] Loaded system [gz::sim::systems::ShaderParam] for entity [6] in GUI
[GUI] [Msg] ShaderParam: configuring
[GUI] [Msg] ShaderParam: entity: 6
[GUI] [Msg] ShaderParam: visualName: sphere_visual
[GUI] [Dbg] [GuiRunner.cc:375] Loaded system [gz::sim::systems::ShaderParam] for entity [6] in GUI
Warning [Utils.cc:129] [/sdf/plugin[@name="gz::sim::systems::ShaderParam"]:<data-string>:L1]: XML Element[plugin], child of element[sdf], not defined in SDF. Copying[plugin] as children of [sdf].

Impact

The changed behaviour breaks downstream visual plugins that expect to be loaded and initialised only once per entity.

Findings so far

  • When the ECM is queried for components::Visual, components::SystemPluginInfo in GzSceneManager::Update, the visual (entity: 6 in this example) has a SystemPluginInfo component that contains 2 entries for the visual plugin rather than the expected one.

  • This can be verified by inspecting sdf::Plugins convertedPlugins in L146,

  • Or alternatively by displaying the DebugString of the msgs::SerializedStepMap message in GuiRunner::OnStateQt.

  • => it seems the ECM state from the server is being populated with an additional copy of the plugin component.

  • An extra pair of visual plugins are loaded because GzSceneManager::Update emits events for both the new VisualPlugins event and the deprecated VisualPlugin event. Disabling the deprecated event leaves just the pair pf plugins coming from the Plugins vector in the ECM.

Ongoing investigations

  • Locating where the duplicate copy of the plugin details is entered into the ECM msgs::SerializedStepMap on the server.

srmainwaring avatar Aug 13 '22 21:08 srmainwaring