sunjay / turtle

Create Animated Drawings in Rust
http://turtle.rs
Mozilla Public License 2.0
562 stars 53 forks source link

panicked at 'Windows can only be created on the main thread on macOS #27

Closed adals closed 6 years ago

adals commented 7 years ago
turtle adelalharbi$ RUST_BACKTRACE=1 cargo run --example rust
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/examples/rust`
thread '<unnamed>' panicked at 'Windows can only be created on the main thread on macOS', /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/macos/window.rs:306:16
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: winit::platform::platform::window::Window2::new
   6: winit::platform::platform::Window::new
   7: winit::window::<impl winit::WindowBuilder>::build
   8: glutin::platform::platform::Context::new
   9: glutin::GlWindow::new
  10: glutin_window::GlutinWindow::new
  11: <glutin_window::GlutinWindow as window::BuildFromWindowSettings>::build_from_window_settings
  12: window::WindowSettings::build
  13: <piston_window::PistonWindow<W> as window::BuildFromWindowSettings>::build_from_window_settings
  14: window::WindowSettings::build
  15: turtle::renderer::Renderer::run
  16: turtle::turtle_window::TurtleWindow::new::{{closure}}
adals commented 7 years ago

rustc -V rustc 1.21.0 (3b72af97e 2017-10-09)

sunjay commented 7 years ago

Thank you for reporting this! It is non-trivial to fix this problem, but I am working on it! I'll report back once it's fixed. Appreciate you letting me know!

adals commented 6 years ago

FYI, maybe it will help

Win8:turtle adelalharbi$ RUST_BACKTRACE=full cargo run --example maze
warning: file found to be present in multiple build targets: /Users/adelalharbi/Codes/Rust/turtle/examples/rust.rs
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/examples/maze`
thread '<unnamed>' panicked at 'Windows can only be created on the main thread on macOS', /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/macos/window.rs:306:16
stack backtrace:
   0:        0x10dd3ab73 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h6f26156f36f91c7c
                               at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:        0x10dd37430 - std::sys_common::backtrace::_print::h0b677b64a478c8cb
                               at src/libstd/sys_common/backtrace.rs:69
   2:        0x10dd3c6f3 - std::panicking::default_hook::{{closure}}::h2a99d1ab84807307
                               at src/libstd/sys_common/backtrace.rs:58
                               at src/libstd/panicking.rs:381
   3:        0x10dd3c3f2 - std::panicking::default_hook::h540d2e3ab8360bf0
                               at src/libstd/panicking.rs:397
   4:        0x10dd3cc02 - std::panicking::begin_panic::had0530100710df8d
                               at src/libstd/panicking.rs:577
   5:        0x10dc3b805 - std::panicking::begin_panic::h8fe3a707ba42b395
                               at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:538
   6:        0x10dc2d818 - winit::platform::platform::window::Window2::new::ha2b102a00b2a736b
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/macos/window.rs:306
   7:        0x10dc33ab7 - winit::platform::platform::Window::new::hcd72ddeee42e38fc
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/macos/mod.rs:32
   8:        0x10dc38ba0 - <T as core::convert::From<T>>::from::hb143731a32efc860
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/window.rs:119
   9:        0x10dc266fd - glutin::platform::platform::Context::new::h5d9d44c60f82505f
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.10.1/src/platform/macos/mod.rs:48
  10:        0x10dc21388 - <T as core::convert::From<T>>::from::h62f2df6c61e77250
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/glutin-0.10.1/src/lib.rs:322
  11:        0x10dc125db - glutin_window::context_builder_from_settings::ha3c0f7c2a50db388
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.42.0/src/lib.rs:105
  12:        0x10dc15593 - glutin_window::GlutinWindow::fake_capture::heb75870c8b2aca30
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.42.0/src/lib.rs:440
  13:        0x10dbeb453 - window::WindowSettings::build::h003c328b36d89ae2
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-window-0.30.0/src/lib.rs:387
  14:        0x10dbeb5c2 - <piston_window::PistonWindow<W> as window::BuildFromWindowSettings>::build_from_window_settings::haaee920c4df374da
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/piston_window-0.73.0/src/lib.rs:152
  15:        0x10dbeb483 - window::WindowSettings::build::h2089d8afa0628012
                               at /Users/adelalharbi/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-window-0.30.0/src/lib.rs:387
  16:        0x10db5e7a9 - turtle::renderer::Renderer::run::hc1691cb601b0219c
                               at src/renderer.rs:71
  17:        0x10dbec0bb - turtle::turtle_window::TurtleWindow::new::{{closure}}::h830f6bfb5500eb78
                               at src/turtle_window.rs:80
  18:        0x10db75294 - std::sys_common::backtrace::__rust_begin_short_backtrace::hadfff858df02a9a7
                               at /Users/travis/build/rust-lang/rust/src/libstd/sys_common/backtrace.rs:134
  19:        0x10db4f9e4 - std::thread::Builder::spawn::{{closure}}::{{closure}}::h64c5f945b0b7f258
                               at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:400
  20:        0x10db71e34 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h58d4e1af4573fdfb
                               at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:296
  21:        0x10dbe8eba - std::panicking::try::do_call::h38f172b3fffc6e83
                               at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:480
  22:        0x10dd495dc - panic_unwind::dwarf::eh::read_encoded_pointer::hb58e97d57b98c61e
                               at src/libpanic_unwind/lib.rs:99
  23:        0x10dbe8d99 - std::panicking::try::hf619b36a28a30346
                               at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:459
  24:        0x10db7534f - std::panic::catch_unwind::hb73cec42148bdd48
                               at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:361
  25:        0x10db4f80f - std::thread::Builder::spawn::{{closure}}::hdb64969d2c572bbb
                               at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:399
  26:        0x10db5a775 - <F as alloc::boxed::FnBox<A>>::call_box::h521d3a38de9024da
                               at /Users/travis/build/rust-lang/rust/src/liballoc/boxed.rs:726
  27:        0x10dd3bb2b - std::sys::imp::thread::Thread::new::thread_start::h647fefd3ca6a8131
                               at /Users/travis/build/rust-lang/rust/src/liballoc/boxed.rs:736
                               at src/libstd/sys_common/thread.rs:24
                               at src/libstd/sys/unix/thread.rs:90
  28:     0x7fff6448c6c0 - _pthread_body
  29:     0x7fff6448c56c - _pthread_start
sunjay commented 6 years ago

Hi! I am actively working on a fix for this issue. Over the last two weeks, I have done the majority of the work in order to get this working on all platforms. I do not have easy access to a computer running MacOS. If you have some time, could you help me out and test to see if it is fixed?

Here are the commands you would need to run:

  1. If you haven't already, clone this repository:
    git clone https://github.com/sunjay/turtle.git
    cd turtle
  2. Then run cargo run --example rust (you should still be at the master branch at this point)
  3. Make sure it still fails and you still see the same panic that you saw before
  4. Checkout the fixed branch with git checkout multiprocess
  5. Run cargo run --example rust (everything should work now)
  6. Run cargo test --features test (everything should pass)
  7. Try out the other examples as much as you feel like, they should all work now as long as one of them worked

Please let me know if 5 or 6 result in any errors and panics. Try closing the window in the middle of a run to see if that causes any panics. Let me know if you experience any other issues at all.

DM-Berger commented 6 years ago

Just gave this a go, all seemed good on my end.

     Running `target/debug/examples/rust`
thread '<unnamed>' panicked at 'Windows can only be created on the main thread on macOS', /Users/derek/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.8.3/src/platform/macos/window.rs:306:16
note: Run with `RUST_BACKTRACE=1` for a backtrace.
[18:47] turtle derek$ git checkout multiprocess
Branch multiprocess set up to track remote branch multiprocess from origin.
Switched to a new branch 'multiprocess'
[18:48] turtle derek$ cargo run --example rust
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling itoa v0.3.4
   Compiling dtoa v0.4.2
   Compiling serde_json v1.0.7
   Compiling turtle v1.0.0-alpha.6 (file:///Users/derek/Desktop/turtle)
    Finished dev [unoptimized + debuginfo] target(s) in 13.79 secs
     Running `target/debug/examples/rust`
[18:49] turtle derek$ cargo test --features test
   Compiling turtle v1.0.0-alpha.6 (file:///Users/derek/Desktop/turtle)
    Finished dev [unoptimized + debuginfo] target(s) in 26.93 secs
     Running target/debug/deps/turtle-40e448ce7ae6f95f

running 10 tests
test extensions::tests::to_screen_coords ... ok
test color::tests::color_equivalence ... ok
test speed::tests::speed_names ... ok
test color::tests::invalid_color1 ... ok
test speed::tests::invalid_speed ... ok
test color::tests::invalid_color2 ... ok
test speed::tests::speed_values ... ok
test speed::tests::speed_values_f64 ... ok
test turtle::tests::clear_leaves_position_and_heading ... ok
test turtle::tests::is_using_radians_degrees ... ok

test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests turtle

running 51 tests
test src/color.rs - color (line 80) ... ok
test src/color.rs - color (line 30) ... ok
test src/color.rs - color (line 12) ... ok
test src/color.rs - color (line 53) ... ok
test src/color.rs - color::Color::opaque (line 111) ... ok
test src/rand.rs - rand (line 130) ... ok
test src/rand.rs - rand (line 103) ... ok
test src/color.rs - color::Color::transparent (line 129) ... ok
test src/rand.rs - rand (line 21) ... ok
test src/rand.rs - rand (line 31) ... ok
test src/rand.rs - rand (line 160) ... ok
test src/rand.rs - rand (line 59) ... ok
test src/rand.rs - rand (line 173) ... ok
test src/rand.rs - rand (line 8) ... ok
test src/server.rs - server::start (line 28) ... ok
test src/turtle.rs - turtle::Point (line 33) ... ok
test src/rand.rs - rand::random_range (line 207) ... ok
test src/turtle.rs - turtle::Turtle::begin_fill (line 829) ... ok
test src/turtle.rs - turtle::Turtle::clear (line 962) ... ok
test src/rand.rs - rand (line 83) ... ok
test src/turtle.rs - turtle::Turtle::background_color (line 741) ... ok
test src/turtle.rs - turtle::Turtle::backward (line 144) ... ok
test src/turtle.rs - turtle::Turtle::fill_color (line 786) ... ok
test src/turtle.rs - turtle::Turtle::forward (line 113) ... ok
test src/turtle.rs - turtle::Turtle::go_to (line 363) ... ok
test src/turtle.rs - turtle::Turtle::heading (line 439) ... ok
test src/turtle.rs - turtle::Turtle::hide (line 897) ... ok
test src/turtle.rs - turtle::Turtle::home (line 396) ... ok
test src/turtle.rs - turtle::Turtle::new (line 84) ... ok
test src/turtle.rs - turtle::Turtle::is_pen_down (line 571) ... ok
test src/turtle.rs - turtle::Turtle::is_visible (line 877) ... ok
test src/turtle.rs - turtle::Turtle::left (line 220) ... ok
test src/turtle.rs - turtle::Turtle::pen_color (line 691) ... ok
test src/turtle.rs - turtle::Turtle::pen_down (line 589) ... ok
test src/turtle.rs - turtle::Turtle::poll_event (line 1083) ... ok
test src/turtle.rs - turtle::Turtle::pen_size (line 630) ... ok
test src/turtle.rs - turtle::Turtle::pen_up (line 610) ... ok
test src/turtle.rs - turtle::Turtle::set_background_color (line 763) ... ok
test src/turtle.rs - turtle::Turtle::position (line 341) ... ok
test src/turtle.rs - turtle::Turtle::reset (line 931) ... ok
test src/turtle.rs - turtle::Turtle::set_pen_color (line 713) ... ok
test src/turtle.rs - turtle::Turtle::right (line 178) ... ok
test src/turtle.rs - turtle::Turtle::set_speed (line 285) ... ok
test src/turtle.rs - turtle::Turtle::set_pen_size (line 653) ... ok
test src/turtle.rs - turtle::Turtle::set_heading (line 484) ... ok
test src/turtle.rs - turtle::Turtle::show (line 913) ... ok
test src/turtle.rs - turtle::Turtle::speed (line 265) ... ok
test src/turtle.rs - turtle::Turtle::use_degrees (line 532) ... ok
test src/turtle.rs - turtle::Turtle::wait (line 248) ... ok
test src/turtle.rs - turtle::Turtle::wait_for_click (line 1033) ... ok
test src/turtle.rs - turtle::Turtle::use_radians (line 552) ... ok

test result: ok. 51 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
sunjay commented 6 years ago

@DM-Berger Thank you so much! That means it worked! Woohoo! :tada:

adals commented 6 years ago

Yessss it works right now thank you all

sunjay commented 6 years ago

I received an alarming warning message saying that "code was acting suspiciously" and that it might be a ransomware attack and did I want to block further activities. I chose to block further activities and I also chose to delete everything I'd downloaded from your site. No offence, but better safe than sorry.

The library definitely isn't malware. Probably something wrong with something installed on your system. May be fixed by reinstalling. :)

carlca commented 6 years ago

That comment of mine was entirely genuine. I thought I would help out a fellow coder and I downloaded your code. I got as far as running step 2: cargo run --example rust It downloaded a whole heap of dependencies and started to build them. Part of the way through, this happened:

screen shot 2017-12-04 at 01 41 21

I didn't get a screenshot of the alarming warning message mainly because I was so alarmed that things had gone bad. I see that someone else has confirmed that your code works, so that's good, but I would suggest a more scientific and professional approach than saying something vague and blame shifting like "Probably something wrong with something installed on your system". Maybe it would be an idea to try to find out why the problem occurred, in order that you can avoid it happening to others.

Anyhow my involvement with this project ends right here. Good luck! :)

sunjay commented 6 years ago

Hi @carlca, sorry for the misunderstanding. I deleted your comment because I didn't want someone reading it getting the wrong idea about this library. I am genuinely interested in why that occurred, however as I said, there isn't anything malicious here. The reason I mentioned that something on your system may not be installed correctly is because I have tested this on multiple platforms and haven't had any problems. It's likely that something may have gone wrong specifically on your system and that is what caused that warning.

If you or anyone else experiencing this would like to explore this further, please open another separate issue and we will discuss it. Otherwise, I totally understand how you wouldn't want to be involved in this project anymore given my response. My apologies again for the misunderstanding.

carlca commented 6 years ago

Hi Sunjay,

From your response I can tell that you are a genuine guy, and I’m sorry if I seemed a little hostile towards you. It would be interesting to work out what’s happening, partly because I’ve started to dabble slightly with Rust (I’m normally a Golang coder).

I’ll get back to you in the morning. It’s very late here in London, England (02:37) and I need all the beauty sleep I can get my hands on!

Cheers, Carl

On 4 Dec 2017, 02:04 +0000, Sunjay Varma notifications@github.com, wrote:

Hi @carlca, sorry for the misunderstanding. I deleted your comment because I didn't want someone reading it getting the wrong idea about this library. I am genuinely interested in why that occurred, however as I said, there isn't anything malicious here. The reason I mentioned that something on your system may not be installed correctly is because I have tested this on multiple platforms and haven't had any problems. It's likely that something may have gone wrong specifically on your system and that is what caused that warning. If you or anyone else experiencing this would like to explore this further, please open another separate issue and we will discuss it. Otherwise, I totally understand how you wouldn't want to be involved in this project anymore given my response. My apologies again for the misunderstanding. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sunjay commented 6 years ago

@carlca No problem. Looking forward to discussing this further. Please open a new issue when you next have a chance. :)

sunjay commented 6 years ago

This is officially fixed and will be part of the next release! Thank you @adals for reporting the issue and thank you @DM-Berger, @carlca and everyone else who took the time to test it out! One step closer to the stable release!