boydm / scenic_driver_nerves_rpi

Scenic render-only driver for the Raspberry Pi under Nerves
Apache License 2.0
22 stars 12 forks source link

Having issues with dynamic textures #14

Open oortlieb opened 4 years ago

oortlieb commented 4 years ago

Relevant versions: elixir 1.10.0-otp-22 erlang 22.0.7 scenic 0.10.2 scenic_driver_nerves_rpi 0.10.1 nerves 1.5.4 nerves_system_rpi3 1.10.2

I'm trying to show a full-screen photo using a dynamic texture. On my dev machine, everything works fine -- a window pops open, and my photo is there. When I run the program on my Pi devices (3, Zero), the screen stays black even as the logs indicate that the program is running normally.

I have a small example that demonstrates the problem. When run on my dev machine, the function below updates the window to a random color when the process receives this message. When I run it on a Raspberry Pi device, it looks like everything is running normally, but the screen remains black.

  def handle_info(:update, state) do
    width = 400
    height = 600
    texture = Scenic.Utilities.Texture.build!(:rgba, width, height)
    color = Enum.random([:red, :green, :blue, :yellow, :orange])

    0..height-1 |> Enum.each fn row ->
      0..width-1 |> Enum.each fn col ->
        texture |>
          Scenic.Utilities.Texture.put!(col, row, color)
      end
    end

    { :ok, hash } = Scenic.Cache.Dynamic.Texture.put("hash", texture)

    graph = Graph.build() |> rectangle({ width, height }, fill: { :dynamic, hash })

    { :noreply, state, push: graph }
  end

I've tried to use Scenic.Cache.Dynamic.Texture.subscribe to maybe receive more information from the cache, but haven't been able to get that to work. Otherwise, I'm currently stumped!

sandromehic commented 4 years ago

I can confirm the issue. I have the following version, and am using a custom nerves system done by me (everything else works). Trying to render anything dynamic gives just black texture.

elixir 1.10.2-otp-22 erlang 22.2.8 scenic 0.10 scenic_driver_nerves_rpi 0.10 nerves 1.6.0

I can try and help with the issue, but I would need some indication as to where to look.

oortlieb commented 4 years ago

I've only spent a little bit of time trying to debug the issue, and haven't made much progress so far. In my most recent debugging session, I looked for issues on the elixir side of things -- I added some log statements to lib/rpi/port.ex and lib/rpi/cache.ex to see if I could find anything abnormal. I was unable to uncover any issues.

I was going to attempt to get into the c_src directory next, but I'm not exactly sure how to go about debugging at that level (this is my first project using elixir/nerves).

Hanspagh commented 3 years ago

Did you ever manage to get this to work? I am having the same problem now.

boydm commented 3 years ago

I am reworking the dynamic textures code now as part of v.11 (It's the last big work item), although I haven't brought the RPI I driver over yet. I think this will go away, but lets make sure to check when the new version arrives. I'll do a beta version before properly publishing it. It will need a bunch of docs work before it is ready, but I want to get the new code out sooner than later.