rhomobile / rhodes

The Rhodes framework is a platform for building locally executing, device-optimized mobile applications for all major smartphone devices.
http://tau-platform.com/
MIT License
1.05k stars 237 forks source link

Ruby Enumerator#next broken iOS #423

Open jtara opened 9 years ago

jtara commented 9 years ago

Using Rhodes 5.0.2 (from RMS 5.0.2).

Enumerator#next terminates app with no logging.

    test_enum = [1,2,3].to_enum
    app_info "test_enum = #{test_enum.inspect}"
    current_test = test_enum.next   # Ka-pow! Rhodes bombs!
    app_info "current_test = #{current_test.inspect}"  # we do not get here

(Yes, I know I need an exception handler to detect the end when looping through. But no loop above. current_test should be set to 1.)

Works in Ruby 1.9.2-p290 (same version as Rhodes) on OSX desktop irb.

This is on iOS simulator. Need to test on device to see if it bombs there as well, and see if anything in system log.

jtara commented 9 years ago

I think it may be related to this:

https://www.ruby-forum.com/topic/196086

That's a discussion about jRuby. But it mentions an implementation detail of #next:

  1. On the first call to #next, a fiber or generator is spun up to start the call to each, similar to this: f = Fiber.new { collection.each {|i| Fiber.yield i} }
  2. For each element next returns, the fiber/generator is invoked to produce the next result def next f.resume end
  3. When the enumeration completes (or at any time) you can rewind and start from the beginning.

I'd guess that Rhodes doesn't implement Fibers.

If that's the case, Enumerator#next needs to be documented as not implemented.

I wonder what else in Ruby is depending on fibers?

vmusulainen commented 6 years ago

It's reproduced on rhodes v.5.5.0.51 & 6.0.0