Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use optcarrot #1063

Closed
bbuchalter opened this issue Feb 3, 2018 · 9 comments
Closed

Unable to use optcarrot #1063

bbuchalter opened this issue Feb 3, 2018 · 9 comments
Assignees

Comments

@bbuchalter
Copy link

Due in part to the helpful work being done in #1054 I was able to get truffleruby loaded locally on macOS 10.13.3. Via the documentation I reached Playing optcarrot and attempted to play per the instructions after installing mplayer via brew install mplayer.

The game would load, but pressing ENTER would cause an exception.

See the following for more details:

brian|master=:~/src/optcarrot$ ruby -v
truffleruby 0.30.2, like ruby 2.3.5 <Java HotSpot(TM) 64-Bit Server VM 1.8.0_151-b12 with Graal> [darwin-x86_64]
brian|master=:~/src/optcarrot$ ruby bin/optcarrot --video mplayer --input term examples/Lan_Master.nes
/Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `errno_error': Broken pipe (Errno::EPIPE)
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `new'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `handle'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `write_string'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `write'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/mplayer_video.rb:42:in `tick'
	from /Users/brian/src/optcarrot/lib/optcarrot/nes.rb:50:in `step'
	from /Users/brian/src/optcarrot/lib/optcarrot/nes.rb:83:in `run'
	from bin/optcarrot:6:in `<main>'
brian|master=:~/src/optcarrot$ gst
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

If this is not the right location to file this issue, I'd be happy to move it elsewhere. Thanks very much for all the work the truffleruby team has done and aims to do!

@eregon eregon self-assigned this Feb 3, 2018
@eregon
Copy link
Member

eregon commented Feb 3, 2018

Is mplayer in $PATH?
Can you show the output of mplayer -h and which mplayer?

There is a bug in the instructions, it's missing a --audio=none.
But more importantly, now that we support enough of FFI,
it is nicer to play with SDL2, which can be done with:

path/to/graalvm/bin/ruby bin/optcarrot --sdl2 --audio=none examples/Lan_Master.nes 

I'll update the instructions.

eregon added a commit that referenced this issue Feb 3, 2018
* We now support FFI which is much more convenient to play.
* See #1063.
eregon added a commit that referenced this issue Feb 3, 2018
* We now support FFI which is much more convenient to play.
* See #1063.
@eregon
Copy link
Member

eregon commented Feb 3, 2018

@bbuchalter Can you try with the updated instructions at Playing Optcarrot?

@bbuchalter
Copy link
Author

brian|master=:~/src/optcarrot$ ruby bin/optcarrot --sdl2 --audio=none examples/Lan_Master.nes
/Users/brian/src/graalvm-0.30.2/Contents/Home/jre/languages/ruby/lib/truffle/ffi/library.rb:119:in `block in ffi_lib': dlopen(SDL2, 2): image not found (LoadError)
	UnsatisfiedLinkError com.oracle.truffle.nfi.NFIContext.loadLibrary(Native Method)
	com.oracle.truffle.nfi.NFIContext.loadLibrary(NFIContext.java:143)
	com.oracle.truffle.nfi.NFILanguage$LoadLibraryNode.execute(NFILanguage.java:82)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:248)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:237)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:227)
	org.graalvm.compiler.truffle.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:212)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:196)
	org.graalvm.compiler.truffle.OptimizedDirectCallNode.callProxy(OptimizedDirectCallNode.java:65)
	org.graalvm.compiler.truffle.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:59)
	org.truffleruby.interop.InteropNodes$EvalNode.evalCached(InteropNodes.java:781)
		caused by <no message> TruffleStackTrace.
dlopen(libSDL2.dylib, 2): image not found
	UnsatisfiedLinkError com.oracle.truffle.nfi.NFIContext.loadLibrary(Native Method)
	com.oracle.truffle.nfi.NFIContext.loadLibrary(NFIContext.java:143)
	com.oracle.truffle.nfi.NFILanguage$LoadLibraryNode.execute(NFILanguage.java:82)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:248)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:237)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:227)
	org.graalvm.compiler.truffle.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:212)
	org.graalvm.compiler.truffle.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:196)
	org.graalvm.compiler.truffle.OptimizedDirectCallNode.callProxy(OptimizedDirectCallNode.java:65)
	org.graalvm.compiler.truffle.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:59)
	org.truffleruby.interop.InteropNodes$EvalNode.evalCached(InteropNodes.java:781)
		caused by <no message> TruffleStackTrace
	from /Users/brian/src/graalvm-0.30.2/Contents/Home/jre/languages/ruby/lib/truffle/ffi/library.rb:72:in `map'
	from /Users/brian/src/graalvm-0.30.2/Contents/Home/jre/languages/ruby/lib/truffle/ffi/library.rb:72:in `ffi_lib'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/sdl2.rb:7:in `SDL2'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/sdl2.rb:5:in `Optcarrot'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/sdl2.rb:3:in `<top (required)>'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/sdl2_video.rb:1:in `require_relative'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver/sdl2_video.rb:1:in `<top (required)>'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver.rb:43:in `require_relative'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver.rb:43:in `load_each'
	from /Users/brian/src/optcarrot/lib/optcarrot/driver.rb:33:in `load'
	from /Users/brian/src/optcarrot/lib/optcarrot/nes.rb:12:in `initialize'
	from bin/optcarrot:6:in `new'
	from bin/optcarrot:6:in `<main>'
brian|master=:~/src/optcarrot$ which mplayer
/usr/local/bin/mplayer
brian|master=:~/src/optcarrot$ mplayer -h
Usage:   mplayer [options] [url|path/]filename

Basic options: (complete list in the man page)
 -vo <drv>        select video output driver ('-vo help' for a list)
 -ao <drv>        select audio output driver ('-ao help' for a list)
 vcd://<trackno>  play (S)VCD (Super Video CD) track (raw device, no mount)
 -alang/-slang    select DVD audio/subtitle language (by 2-char country code)
 -ss <position>   seek to given (seconds or hh:mm:ss) position
 -nosound         do not play sound
 -fs              fullscreen playback (or -vm, -zoom, details in the man page)
 -x <x> -y <y>    set display resolution (for use with -vm or -zoom)
 -sub <file>      specify subtitle file to use (also see -subfps, -subdelay)
 -playlist <file> specify playlist file
 -vid x -aid y    select video (x) and audio (y) stream to play
 -fps x -srate y  change video (x fps) and audio (y Hz) rate
 -pp <quality>    enable postprocessing filter (details in the man page)
 -framedrop       enable frame dropping (for slow machines)

Basic keys: (complete list in the man page, also check input.conf)
 <-  or  ->       seek backward/forward 10 seconds
 down or up       seek backward/forward  1 minute
 pgdown or pgup   seek backward/forward 10 minutes
 < or >           step backward/forward in playlist
 p or SPACE       pause movie (press any key to continue)
 q or ESC         stop playing and quit program
 + or -           adjust audio delay by +/- 0.1 second
 o                cycle OSD mode:  none / seekbar / seekbar + timer
 * or /           increase or decrease PCM volume
 x or z           adjust subtitle delay by +/- 0.1 second
 r or t           adjust subtitle position up/down, also see -vf expand

 * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *

MPlayer 1.3.0-4.2.1 (C) 2000-2016 MPlayer Team
brian|master=:~/src/optcarrot$ ruby -v
truffleruby 0.30.2, like ruby 2.3.5 <Java HotSpot(TM) 64-Bit Server VM 1.8.0_151-b12 with Graal> [darwin-x86_64]

Also, I had tried with mplayer and ``--audio=none` per the blog post and got the same behavior.

@eregon
Copy link
Member

eregon commented Feb 3, 2018

dlopen(libSDL2.dylib, 2): image not found

So you need to install SDL2 (the GUI library) with your package manager.

@eregon
Copy link
Member

eregon commented Feb 3, 2018

brew install sdl2 should do it with Homebrew.

@bbuchalter
Copy link
Author

Ahh, yes, of course. Forgive me. OK, after installing, I see the following:

brian|master=:~/src/optcarrot$ ruby bin/optcarrot --sdl2 --audio=none examples/Lan_Master.nes
validation for Optcarrot::SDL2::AudioSpec parameter not yet implemented
validation for Optcarrot::SDL2::AudioSpec parameter not yet implemented
options {:blocking=>true} ignored for attach_function :QuitSubSystem
options {:blocking=>true} ignored for attach_function :Delay
options {:blocking=>true} ignored for attach_function :OpenAudioDevice
options {:blocking=>true} ignored for attach_function :PauseAudioDevice
options {:blocking=>true} ignored for attach_function :CloseAudioDevice
2018-02-03 12:10:09.171 java[95553:3957985] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
2018-02-03 12:10:12.707 java[95553:3957985] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.

But no GUI appears. It looks like a java processes is consuming some CPU, but that's about it.

@eregon
Copy link
Member

eregon commented Feb 3, 2018

The warnings (validation ..., options ...) are expected.
But the last two lines seems some kind of incompatibility between macOS and SDL2 or Java.
I don't know about this specific problem and have no macOS to try it.

Searching on Google, I found mltframework/mlt#246 and others which seem to indicate macOS no longer supports some kind of GUI rendering on a thread different than the main thread.

@chrisseaton tells me -XstartOnFirstThread might help (https://stackoverflow.com/a/28150108/388803).

Could you try with:

ruby -J-XstartOnFirstThread bin/optcarrot --sdl2 --audio=none examples/Lan_Master.nes

?

If it still doesn't work, the command you pasted should also work on MRI.
So you could check if it works on MRI and that should indicate if it's Java/TruffleRuby-specific or not.

@bbuchalter
Copy link
Author

ruby -J-XstartOnFirstThread bin/optcarrot --sdl2 --audio=none examples/Lan_Master.nes worked as expected. Probably worth making a special note for macOS in Playing OptCarrot.

Thanks for working through this with me and all your work for open source!

@eregon
Copy link
Member

eregon commented Feb 3, 2018

Great!
I'll add a note there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants