How to reduce time until simulator window opens? (now 2 min !)


#1

Recently the time until the simulator opens gets longer and longer even though I have not added much more programming.
Meanwhile I have to wait for 2 Minutes.

Using Atom as an editor, I did realize that the above mentioned time increased when renaming folders within the app / screens section of the editor…

My MacBook Pro mid 2012 with 2,6 GHz and 16 GB DDR3 RAM is not the fastest, but hardware should. bot be the problem.

When pressing ‘rake’ In iTerm2 these lines are being displayed within seconds…

Generating Data Model plus123
Loading schemas/0001_initial.rb
Writing resources/plus123.xcdatamodeld/0001 initial.xcdatamodel/contents
Build ./build/iPhoneSimulator-11.0-Development
Build /Users/daniel0/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/motion-yaml-1.4/lib/YAMLKit
Build /Users/daniel0/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/cdq-1.0.8/lib/…/vendor/cdq/ext

Then it takes almost two minutes until these lines appear:

  Link ./build/iPhoneSimulator-11.0-Development/plus123.app/plus123

Compile ./resources/plus123.xcdatamodeld
Create ./build/iPhoneSimulator-11.0-Development/plus123.app/Info.plist
Copy ./resources/plus123.momd/VersionInfo.plist
Copy ./resources/plus123.momd/0001 initial.omo
Copy ./resources/plus123.momd/0001 initial.mom
Create ./build/iPhoneSimulator-11.0-Development/plus123.app.dSYM
Copy ./build/iPhoneSimulator-11.0-Development/plus123.app.dSYM
Simulate /Users/daniel0/rubymotion/plus123/build/iPhoneSimulator-11.0-Development/plus123.app
(main)> Type pm_live to enable ProMotion’s live reload system.

And shortly afterwards the simulator window opens.

I do not run the latest RubyMotion version as occasionally I had run into severe problems when upgrading.
At the moment in the Rakefile it says: 'app.sdk_version = “11.0”

Recently I had run, hoping that this would resolve the problem …

  • bundle exec rake clean
  • bundle exec bundle install
  • bundle exec rake pod:install

But it didn’t

I’d be very grateful for help!

Thanks,
Daniel


#2

Hi @dotvo,

I had a similar behavior like you’ve described. I found out (by canceling the rake script) that it must have something to do with the dependency.rb file of rubymotion. It seem that my dependencies are not perfectly setup. Because I have too much files in my project already - I’ve ended up by changing the file directly. Maybe this helps you with your problem as well:

File is stored in `/Library/RubyMotion/lib/motion/project/dependency.rb

# new code added by me
require 'digest'

def write_cache(result, dependencies, def_path, ref_path)
  cached[cache_key(def_path, ref_path)] = result
end

def cache_key(def_path, ref_path)
  Digest::MD5.hexdigest("#{def_path},#{ref_path}")
end

def cached
  @cached ||= {}
end

def cached_value(def_path, ref_path)
  cached[cache_key(def_path, ref_path)]
end

def store_cache
  # TODO maybe store files for the next rake
end

# I've added the cache check to prevent loops
def cyclic?(dependencies, def_path, ref_path)
  cache = cached_value(def_path, ref_path)
  return cache if cache != nil

  deps = dependencies[def_path]
  if deps
    if deps.include?(ref_path)
      return true
    end
    deps.each do |file|
      if cyclic?(dependencies, file, ref_path)
        return true
      end
    end
  end
  write_cache(false, dependencies, def_path, ref_path)

  false
end

Hope that helps, maybe someone can explain how to prevent the loops in the first place :slight_smile:

Torben


#3

Hi @torben,

thanks for putting this down!
As this is far beyond my understanding of scripts I will get in touch with a friend who hopefully understands it all and possibly could change the script of the dependency.rb.

I’ll be informing about what happens.

Thanks again,
Daniel


#4

@John Garhardt on slack may be able to help with this too. DM me there if you want to do some realtime trouble shooting.

The inner workings of dependency.rb were discussed during this meetup. It may be worth watching: http://www.rubymotion.tv/posts/14-rubymotion-meetup-june-2018


#5

Hi @torben,

we are not sure how to apply the code you sent.
Would you mind explaining?

Our guess is: the content of the file is supposed to be copied into a new file "auto-build.rb. Then ‘ruby auto-build.rb’ has to be written into the terminal. Right?
.


#6

For now I’d say don’t worry about auto building. After our G+ session, I think the issue for start up you are having are related to the new links you’ve provided to your image controls. The request is hanging for the specific URL you are passing in. Please double check the url, and make sure it’s returning correctly before updating the links in your app. (DM me on Slack if needed).


#7