hydra-synth / atom-hydra

78 stars 29 forks source link

Cannot read property 'getTexture' of undefined #34

Open smex-commissions opened 3 years ago

smex-commissions commented 3 years ago

This code outputs perfectly fine in the web version of Hydra, however I get the error in the title trying to run this code in Atom. On 64 bit Windows 10 Expected output: image

shape(22) .modulate(osc(23)) .color(.1,.6,.8) .repeat(2,2) .scrollX(.01,.02) .scrollY(.1,.02) .pixelate(50,50) .out(o1)

osc(1,1,1) .pixelate(25,6) .scrollY(-.2) .add(o1) .out()

micuat commented 3 years ago

hmmm I had the same issue after installing atom-hydra through apm on Ubuntu. Then I tried to debug it in dev mode by

apm develop atom-hydra
atom -d /path/to/atom-hydra

and it seems I cannot reproduce the issue (it's working fine). Maybe it's related to some path issue...?

OscarSouth commented 2 years ago

I have this issue on Manjaro Linux and it's been around for quite a long time now.

It's a subtle and pervasive issue that it took me some time to recognise. Hydra will function normally when booted up and then something will put it into Cannot read property 'getTexture' of undefined 'mode', where code that ran normally just 5 minutes ago will return that message. Basically once you get that message one time, then something about Hydra will silently break and many conditions that should work normally will now give that error.

It's a real mood/flow/potential concert killer because the only solution is a full reset of hydra and if you're running TidalCycles in another Atom pane, then you will have to kill and reboot your running Tidal interpreter along with Atom, in order to get Hydra working.

I use Atom-Hydra for executing patches that are carefully debugged, but personally wouldn't use atom for hydra improvisation while this problem persists. I'll try and identify a piece of code that triggers the error reliably.

micuat commented 2 years ago

@OscarSouth I know this is not a solution, but you can run tidal on vscode so you can avoid the complete restart... or you can try the development mode I described above to see if that fixes the issue.

ojack commented 2 years ago

Hmm strange. The code works fine for me on osx. Any other examples of code that causes your computer to start having the getTexture() error?

OscarSouth commented 2 years ago

@OscarSouth I know this is not a solution, but you can run tidal on vscode so you can avoid the complete restart... or you can try the development mode I described above to see if that fixes the issue.

I'll have a look at the development mode you mentioned and report if any issues come up. I don't tend to improvise live with visuals (I'm more of a music focus performer) so once I have my hydra files finished and prepped for a show then it's not toooo big a problem personally as it's more predictable in that case.

Hmm strange. The code works fine for me on osx. Any other examples of code that causes your computer to start having the getTexture() error?

I will also keep an eye out for snippets that reliably cause this issue.

errorbesque commented 2 years ago

Hi -- with my setup I can reliably reproduce this error.

To be more specific this code (in Atom, but not in Chrome) first produces an Uncaught TypeError: arr.slice is not a function error and when I toggle the atom-hydra package I get the getPackage error and can only resolve this upon Atom restart.

(And yes I know this is a defect of the below code, but I'm most interested in figuring out if I can restart whatever glsl module (?) needs to be restarted while livecoding without having to restart Atom, if I happen to make an error that results in this outcome).

I'm going to continue to investigate it but thought I'd post my snippet here.

I'm running Atom 1.60.0 x64 on Mac OSX 10.15.7.

osc(101, 0.2, 0)
  .color(2, 0, 0)
  .mult(osc(10, .4, .01))
  .rotate(0.2)
  .modulateRotate(()=>Math.sin(time/10),.2) // this line causes the error
  .out(o0);

Subsequent attempts to run other pieces of working code result in this console error

TypeError: Cannot read property 'getTexture' of undefined
    at /Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:213
    at Array.map (<anonymous>)
    at formatArguments (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:133)
    at /Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:41
    at Array.forEach (<anonymous>)
    at generateGlsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:40)
    at generateGlsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:22)
    at Object.GlslSource.compile (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:66)
    at Object.GlslSource.glsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:60)
    at Object.GlslSource.out (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:23)
    at eval (eval at _eval (main.js? [sm]:5), <anonymous>:4:8)
    at Main._eval (main.js? [sm]:5)
    at Main.evalBlock (main.js? [sm]:43)
    at HTMLElement.atomHydraEvalBlock (atom-hydra.js? [sm]:11)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11)
    at KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11)
    at KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11) "TypeError" undefined undefined "TypeError: Cannot read property 'getTexture' of undefined
    at /Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:213:28
    at Array.map (<anonymous>)
    at formatArguments (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:133:22)
    at /Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:41:18
    at Array.forEach (<anonymous>)
    at generateGlsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:40:14)
    at generateGlsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-utils.js:22:15)
    at Object.GlslSource.compile (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:66:20)
    at Object.GlslSource.glsl (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:60:47)
    at Object.GlslSource.out (/Users/gruverr/.atom/packages/atom-hydra/node_modules/hydra-synth/src/glsl-source.js:23:19)
    at eval (eval at _eval (/Users/gruverr/.atom/packages/atom-hydra/lib/main.js:40:7), <anonymous>:4:8)
    at Main._eval (/Users/gruverr/.atom/packages/atom-hydra/lib/main.js:40:7)
    at Main.evalBlock (/Users/gruverr/.atom/packages/atom-hydra/lib/main.js:73:12)
    at HTMLElement.atomHydraEvalBlock (/Users/gruverr/.atom/packages/atom-hydra/lib/atom-hydra.js:20:47)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:352694)
    at KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1228469)
    at KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1224603)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:286682)"
ojack commented 2 years ago

oooh okay thank you! yes agreed it would ideally not crash with this error, but instead send a message.

I just checked and this is also an issue in the web editor!

starmaid commented 1 year ago

just commenting to say that this is a generic issue with any of the modulateX( texture , <anything else> ) functions, caused when you pass something that isn't a texture (like a value)