phronmophobic / membrane.term

A terminal emulator in pure clojure
Eclipse Public License 1.0
53 stars 1 forks source link

Crash when 24-bit color requested #6

Closed lread closed 2 years ago

lread commented 2 years ago

As promised, a repro (now fixed in master).

Environment

macOS 10.15.7 bat 0.18.3 installed via homebrew

Repro

From clone of membrane.term repo, in main branch at a8140cd6638c0d4b5c9523c0b497028b30150456, launch an interactive terminal session:

> clojure -X com.phronemophobic.membrane.term/run-term :width 90 :height 30
log4j:WARN No appenders could be found for logger (com.pty4j.util.ExtractedNative).
log4j:WARN Please initialize the log4j system properly.

From within the membrane.term terminal, run:

bat deps.edn

Expected Behavior

I should see colorized deps.edn output in membrane.term.

Actual Behavior

The membrane.term window closed and the following error showed in my launching terminal:

#error {
 :cause class clojure.lang.PersistentVector cannot be cast to class java.lang.Number (clojure.lang.PersistentVector is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
 :via
 [{:type java.lang.ClassCastException
   :message class clojure.lang.PersistentVector cannot be cast to class java.lang.Number (clojure.lang.PersistentVector is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
   :at [com.phronemophobic.membrane.term$wrap_color invokeStatic term.clj 85]}]
 :trace
 [[com.phronemophobic.membrane.term$wrap_color invokeStatic term.clj 85]
  [com.phronemophobic.membrane.term$wrap_color invoke term.clj 83]
  [com.phronemophobic.membrane.term$term_line$fn__16694 invoke term.clj 109]
  [clojure.core$map$fn__5880$fn__5881 invoke core.clj 2746]
  [clojure.core$filter$fn__5907$fn__5908 invoke core.clj 2810]
  [clojure.core$map_indexed$fn__8567$fn__8568 invoke core.clj 7300]
  [clojure.lang.PersistentVector reduce PersistentVector.java 343]
  [clojure.core$transduce invokeStatic core.clj 6885]
  [clojure.core$into invokeStatic core.clj 6901]
  [clojure.core$into invoke core.clj 6889]
  [com.phronemophobic.membrane.term$term_line invokeStatic term.clj 102]
  [com.phronemophobic.membrane.term$term_line invoke term.clj 101]
  [clojure.lang.AFn applyToHelper AFn.java 154]
  [clojure.lang.AFn applyTo AFn.java 144]
  [clojure.core$apply invokeStatic core.clj 667]
  [clojure.core$memoize$fn__6894 doInvoke core.clj 6342]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [com.phronemophobic.membrane.term$term_view$fn__16705 invoke term.clj 152]
  [clojure.core$map_indexed$fn__8567$fn__8568 invoke core.clj 7300]
  [clojure.lang.PersistentVector reduce PersistentVector.java 343]
  [clojure.core$transduce invokeStatic core.clj 6885]
  [clojure.core$into invokeStatic core.clj 6901]
  [clojure.core$into invoke core.clj 6889]
  [com.phronemophobic.membrane.term$term_view invokeStatic term.clj 146]
  [com.phronemophobic.membrane.term$term_view invoke term.clj 137]
  [com.phronemophobic.membrane.term$run_term$fn__16727 invoke term.clj 314]
  [membrane.skia.GlfwSkiaWindow repaint_BANG_ skia.clj 1749]
  [membrane.skia$eval16323$fn__16324$G__16315__16326 invoke skia.clj 1214]
  [membrane.skia$eval16323$fn__16324$G__16314__16329 invoke skia.clj 1214]
  [clojure.core$run_BANG_$fn__8813 invoke core.clj 7717]
  [clojure.core.protocols$iter_reduce invokeStatic protocols.clj 49]
  [clojure.core.protocols$fn__8162 invokeStatic protocols.clj 75]
  [clojure.core.protocols$fn__8162 invoke protocols.clj 75]
  [clojure.core.protocols$fn__8110$G__8105__8123 invoke protocols.clj 13]
  [clojure.core$reduce invokeStatic core.clj 6830]
  [clojure.core$run_BANG_ invokeStatic core.clj 7712]
  [clojure.core$run_BANG_ invoke core.clj 7712]
  [membrane.skia$run_helper invokeStatic skia.clj 1913]
  [membrane.skia$run_helper invoke skia.clj 1867]
  [membrane.skia$run_sync$fn__16653 invoke skia.clj 1815]
  [membrane.skia.DispatchCallback callback skia.clj 923]]}

Diagnosis

This was membrane.term not understanding that a color delivered by asciinema/vt can also be an [r g b] vector. Asciinema/vt uses this format to represent a 24-bit color.

lread commented 2 years ago

Was fixed as part of 0faaa8d246b25663c02a22101617a82bdc3f680e. @phronmophobic I'll leave this issue for you to close when/as you see fit.

phronmophobic commented 2 years ago

That explains why I couldn't reproduce it!