Open zacharycarter opened 7 years ago
I applied that code you showed and improved it some... same issue though. I however get a slightly different error than you. LLDB keeps preventing the exception from happening so I can't run it and get a stacktrace like I had hoped. So we got a Heisenbug.
Corys-MacBook-Pro:01-Cubes Cory$ ./Cubes SDL2 version: 2.0.5 - Subsystem: SYSWM_COCOA 2017-03-11 23:55:18.701 Cubes[71859:7580284] /Users/Cory/.nimble/pkgs/bgfx-0.2.2/bgfx/../embed/bgfx/src/bgfx.cpp (2591): BGFX Init... 2017-03-11 23:55:18.701 Cubes[71859:7580284] /Users/Cory/.nimble/pkgs/bgfx-0.2.2/bgfx/../embed/bgfx/src/bgfx.cpp (1321): BGFX Creating rendering thread. 2017-03-11 23:55:18.701 Cubes[71859:7580284] /Users/Cory/.nimble/pkgs/bgfx-0.2.2/bgfx/../embed/bgfx/src/bgfx.cpp (1330): BGFX Running in multi-threaded mode 2017-03-11 23:55:18.701 Cubes[71859:7580313] /Users/Cory/.nimble/pkgs/bgfx-0.2.2/bgfx/../embed/bgfx/src/bgfx_p.h (2215): BGFX render thread start Traceback (most recent call last) Cubes.nim(155) Cubes sdl_platform.nim(69) StartExample bgfx.nim(115) Start bgfx.nim(116) Init SIGSEGV: Illegal storage access. (Attempt to read from nil?)
I actually didn't try SDL with bgfx on OS X except for just recently. I was able to get a barebones engine running on linux successfully. But then got unsuccessful results on OS X like you. If you could give me more info with the latest commit that would be awesome.
Hmm, sorry I wasn't clear enough in my original post.
That code is only necessary in order to get the official Nim SDL bindings to work. I do get the same error as you with the latest commit when using the same bindings (Vladars) as in the examples.
I'm really not sure how to get Vladar's bindings working on OSX. The problem as I see it is this : https://github.com/Vladar4/sdl2_nim/blob/952d0fe5afb62236cf4ccad4bba7b52193e85bfd/sdl2/sdl_syswm.nim#L214
I have no idea where NSWindow is supposed to come from, when that define is satisfied.
The code I posted, does work with the official SDL2 bindings or at least it gets them to work with these bindings. The only problem then is all the freezes I mentioned above.
If you'd like, I can submit a PR and get things working with the examples with the official bindings. Or we can keep working at getting Vladar's bindings working.
I actually need to catch up on some work I have and can't fix this right now. You can send a pull request and do whatever is necessary for SDL2 to work on OS X. You can also try using the official Nim bindings for SDL2 if you think you can get it working.
I will try fixing this later when I have the time.
I'm convinced something is up with the C++ emits. I don't have time to debug this at the moment either - I've created my own bindings and users will just have to dynamically link to the BGFX C API. I have things working on Arch Linux, OSX and Android. Ubuntu is causing problems due to linking order, but I'd rather tackle that challenge than try to figure out what is going on with the freezes with the C++ API.
Hopefully you or someone else gets this sorted out and I can resume using these bindings.
Hi Cory,
Zach here. Got a question for you if you have time, and reporting an issue.
I've been spending quite a bit of time playing around with these bindings and I've been encountering a lot of freezes specifically when using the SDL2 bindings.
A few notes here:
1) I cannot get Vladar's sdl2-nim bindings working with this library with your example code on OSX. Here's output from a run on:
Something like - https://gist.github.com/zacharycarter/883482ee0964b317721c8aaed011b421#file-nim-bgfx-nim-L15-L45 - gets me a little further, but I still encounter errors. I can provide thread backtraces if desired.
I have gotten the official bindings working, essentially by using the code I shared above with them, but I can generate a freeze rather trivially with with a slight modification to your example code.
Have you been using these bindings in any project with SDL2 and if so, do you have any wisdom to shed on ways to avoid these freezes. I'm not sure what they're caused by, stack corruption is a guess.
Also - I've compiled BGFX in single threaded mode to reduce complexities and that still doesn't provide a solution.
Any thoughts?
Edit -
I noticed in #2 that you mention some segfaults and those are exactly what I'm encountering, but only when using SDL2. I'm leaning less towards a problem in Nim / BGFX themselves and something in the bindings leading to some sort of stack corruption maybe?
I can try to help dive into this, as I have code that easily reproduces the problem. Not sure I'm going to be able to find much though.