Fork me on GitHub
#membrane
<
2021-03-23
>
phronmophobic18:03:40

I pulled in the changes last night. Works great. I then got side tracked investigating crashes when you try to open, close, then open a new window. It's definitely possible since I do that all the time with skia. There were some https://github.com/JetBrains/skija/issues/62#issuecomment-804621280 I found in skija, but it seems like lwgl's glfw integration also doesn't support opening multiple windows. I build everything at the repl, so that would drive me crazy. @jjttjj, Can you open multiple windows with skija on Windows? Is that something that would help your workflow?

jjttjj18:03:58

I can open multiple windows currently on windows with skija, it works for me now with membane.skija/run (if i do it in a future). I do also hit the occasional jvm crash though when closing windows or shortly after

phronmophobic18:03:33

Ah ok. Well, hopefully those crashes will be fixed in the next release.

jjttjj18:03:41

cool! yeah I'm used to them and they aren't a big deal 🙂 it doesn't seem to happen every time.

phronmophobic18:03:14

I was able to reliably trigger it by opening a window, closing it, and the calling (System/gc)

phronmophobic18:03:38

I think (hope) those crashes will be fixed. There may be others.

jjttjj18:03:16

Oh interesting, I'm not on windows now but I'll test that out in a bit when I get to my main computer

phronmophobic18:03:43

No hurry. I also have a Windows Virtual Box vm that I sometimes check.

jjttjj18:03:40

Thanks for pulling in the changes too! I know they're kinda underwhelming but i was thinking it's maybe worth getting the changes in incrementally

phronmophobic18:03:18

Thanks for the patch!

jjttjj18:03:44

Unrelated but I've had in the back of my mind the idea of trying to implement a generic layout element thing in membrane, something like hoplon/ui https://github.com/jumblerg/ui

phronmophobic18:03:50

That would be neat. vertical-layout and horizontal-layout are very bare bones.

jjttjj18:03:06

I used that briefly awhile ago and it was always a nice way to code up layouts to me. I'm guessing it would just involve a pane function that would generate some data bottom up and then rendered by some higher level construct (to allow children to be rendered in terms of their parent). The hard part probably is managing the state changes though, as always

phronmophobic18:03:46

It seems like the layout could be a pure function

phronmophobic18:03:07

similar to vertical-layout

jjttjj19:03:12

Oh yeah, looking at that now and it seems like a great starting point, don't now why I didn't think of that

phronmophobic19:03:40

another option is to make it a component:

(defn do-my-layout [props drawables]
  ;; layout element with ui/translate or similar
  
  )

(defrecord MyLayout [props drawables]
  IOrigin
  (-origin [this]
    [0 0])

  IChildren
  (-children [this]
    (do-my-layout props drawables))

  IBounds
  (-bounds [this]
    (bounds (do-my-layout props drawables))))

(defn my-layout [props & drawables]
  (MyLayout. props drawables))
;; use
(my-layout {:vertical true :left 20} (ui/label "hi")})

phronmophobic19:03:14

One idea I've had, but haven't needed to implement is making standard caches available: • A per-frame cache that gets blown away after every frame • A cache that evicts data that wasn't used when drawing the previous frame

phronmophobic19:03:43

One of the main reasons I haven't is that it hasn't been necessary for the UIs I've built so far.

jjttjj19:03:54

Thanks that code sketch is useful!

phronmophobic19:03:15

Memoizing layout functions works really well since everything is value based

jjttjj19:03:21

What would be put in those caches? I'm not immediately seeing it

phronmophobic19:03:27

The result of do-my-layout. If the child elements are changing every frame, then memoizing doesn't help, but if the child elements usually stay the same every frame, then memoizing will save a lot of duplicate effort recalculating layouts every frame

jjttjj19:03:54

Oh yeah, that makes sense