Giter VIP home page Giter VIP logo

Comments (4)

gVirtu avatar gVirtu commented on August 15, 2024

I did some additional experimentation, so far I've asserted that push_graph is generating the correct graph, it inserts this into ets:

%{                                                                               
  0 => %{                                                                                       
    data: {Scenic.Primitive.Group, [1]},                                                        
    styles: %{clear_color: {255, 255, 255, 255}}                                                
  },                                                                                            
  1 => %{                                                                                       
    data: {Scenic.Primitive.Rectangle, {62, 114}},                                              
    id: :parrot,                                                                                 
    styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 4}}},                
    transforms: %{translate: {319.0, 243.0}}                                                     
  }                                                                                              
}

But then Scenic.Driver.Glfw.Graph.handle_cast(:update_clear_color, ...) gets root_group equal to:

%{data: {Scenic.Primitive.Group, [1]}, transforms: %{}}

Thus falling back to the default clear_color or {0, 0, 0, 255}. I'm not sure where the styles information is lost just yet.

from scenic.

gVirtu avatar gVirtu commented on August 15, 2024

From my understanding so far, a graph is stored in ETS sometime before push_graph (the reference ending in 189393 in the logs below), which contains the reference to the graph that actually contains the scene data (the one that ends in 189406 below). When the :update_clear_color message arrives at the destination, the graph_key to fetch points to the wrapper graph, which contains no style data.

Log:

SET {:graph, #Reference<0.3473474407.829423617.189393>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, transforms: %{}}, 1 => %{data: {Scenic.Primitive.SceneRef, {:graph, #Reference<0.3473474407.829423617.189406>, nil}}}}
Sending this to driver: {:cache_put, "UfHCVlANI2cFbwSpJey64FxjT-0"}
pushing: %Scenic.Graph{
  add_to: 0,
  ids: %{_root_: [0], parrot: [1]},
  next_uid: 2,
  primitives: %{
    0 => %{
      __struct__: Scenic.Primitive,
      data: [1],
      module: Scenic.Primitive.Group,
      parent_uid: -1,
      styles: %{clear_color: :white}
    },
    1 => %Scenic.Primitive{
      data: {62, 114},
      id: :parrot,
      module: Scenic.Primitive.Rectangle,
      parent_uid: 0,
      styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0}}},
      transforms: %{translate: {319.0, 243.0}}
    }
  }
}
pushed [true]: %{
  0 => %{
    data: {Scenic.Primitive.Group, [1]},
    styles: %{clear_color: {255, 255, 255, 255}}
  },
  1 => %{
    data: {Scenic.Primitive.Rectangle, {62, 114}},
    id: :parrot,
    styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 0}}},
    transforms: %{translate: {319.0, 243.0}}
  }
}
SET {:graph, #Reference<0.3473474407.829423617.189406>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, styles: %{clear_color: {255, 255, 255, 255}}}, 1 => %{data: {Scenic.Primitive.Rectangle, {62, 114}}, id: :parrot, styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 0}}}, transforms: %{translate: {319.0, 243.0}}}}
pushed [true]: %{
  0 => %{
    data: {Scenic.Primitive.Group, [1]},
    styles: %{clear_color: {255, 255, 255, 255}}
  },
  1 => %{
    data: {Scenic.Primitive.Rectangle, {62, 114}},
    id: :parrot,
    styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 0}}},
    transforms: %{translate: {319.0, 243.0}}
  }
}
SET {:graph, #Reference<0.3473474407.829423617.189406>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, styles: %{clear_color: {255, 255, 255, 255}}}, 1 => %{data: {Scenic.Primitive.Rectangle, {62, 114}}, id: :parrot, styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 0}}}, transforms: %{translate: {319.0, 243.0}}}}
pushed [true]: %{
  0 => %{
    data: {Scenic.Primitive.Group, [1]},
    styles: %{clear_color: {255, 255, 255, 255}}
  },
  1 => %{
    data: {Scenic.Primitive.Rectangle, {62, 114}},
    id: :parrot,
    styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 2}}},
    transforms: %{translate: {319.0, 243.0}}
  }
}
SET {:graph, #Reference<0.3473474407.829423617.189406>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, styles: %{clear_color: {255, 255, 255, 255}}}, 1 => %{data: {Scenic.Primitive.Rectangle, {62, 114}}, id: :parrot, styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 2}}}, transforms: %{translate: {319.0, 243.0}}}}
Sending this to driver: {:set_root, {:graph, #Reference<0.3473474407.829423617.189393>, nil}}
GET {:graph, #Reference<0.3473474407.829423617.189406>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, styles: %{clear_color: {255, 255, 255, 255}}}, 1 => %{data: {Scenic.Primitive.Rectangle, {62, 114}}, id: :parrot, styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 2}}}, transforms: %{translate: {319.0, 243.0}}}}
Sending this to driver: :update_clear_color
GET {:graph, #Reference<0.3473474407.829423617.189393>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, transforms: %{}}, 1 => %{data: {Scenic.Primitive.SceneRef, {:graph, #Reference<0.3473474407.829423617.189406>, nil}}}}
GET {:graph, #Reference<0.3473474407.829423617.189406>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, styles: %{clear_color: {255, 255, 255, 255}}}, 1 => %{data: {Scenic.Primitive.Rectangle, {62, 114}}, id: :parrot, styles: %{fill: {:image, {"UfHCVlANI2cFbwSpJey64FxjT-0", 0, 0, 0, 0, 0, 2}}}, transforms: %{translate: {319.0, 243.0}}}}

Got update_clear_color:
GET {:graph, #Reference<0.3473474407.829423617.189393>, nil} => %{0 => %{data: {Scenic.Primitive.Group, [1]}, transforms: %{}}, 1 => %{data: {Scenic.Primitive.SceneRef, {:graph, #Reference<0.3473474407.829423617.189406>, nil}}}}
root_group: %{data: {Scenic.Primitive.Group, [1]}, transforms: %{}}
Old clear_color = {0, 0, 0, 255}, New clear_color = {0, 0, 0, 255}
Stack trace: {:current_stacktrace,
 [
   {Process, :info, 2, [file: 'lib/process.ex', line: 662]},
   {Scenic.Driver.Glfw.Graph, :handle_cast, 2,
    [file: 'lib/glfw/graph.ex', line: 85]},
   {Scenic.Driver.Glfw, :handle_cast, 2, [file: 'lib/glfw.ex', line: 135]},
   {Scenic.ViewPort.Driver, :handle_cast, 2,
    [file: 'lib/scenic/view_port/driver.ex', line: 198]},
   {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 637]},
   {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 711]},
   {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
 ]}
Sending this to driver: :update_clear_color

For reference:

SET key => value -- Insert graph, in ViewPort.Tables
GET key => value -- Get graph, in ViewPort.Tables
Sending this to driver: msg -- Messages unhandled by the viewport that are passed down to the driver
pushing: graph -- Input for `push_graph`
pushed [true]: graph -- Resulting graph from `handle_cast({:push_graph, raw_graph, sub_id, true} ... )`

It seems this issue is more related to scenic_glfw_driver than scenic, so I've taken a shot at a straightforward fix.

from scenic.

boydm avatar boydm commented on August 15, 2024

Wow. Thank you for digging in to this!

from scenic.

boydm avatar boydm commented on August 15, 2024

I merged your changes in to the glfw driver. Closing this issue.

from scenic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.