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

What Ruby version or gems is required for Uia work? #14

Closed
leoniv opened this issue Aug 5, 2018 · 13 comments
Closed

What Ruby version or gems is required for Uia work? #14

leoniv opened this issue Aug 5, 2018 · 13 comments

Comments

@leoniv
Copy link
Contributor

leoniv commented Aug 5, 2018

Hi! Great work. I'm playing with Uia but i have got "Segmentation fault":

C:/msys64/mingw32/lib/ruby/gems/2.5.0/gems/uia-0.6/lib/uia/library/win32.rb:31: [BUG] Segmentation fault
ruby 2.5.1p57 (2018-03-29 revision 63029) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0033 p:---- s:0176 e:000175 CFUNC  :enum_child_windows
c:0032 p:0039 s:0169 E:001da0 METHOD C:/msys64/mingw32/lib/ruby/gems/2.5.0/gems/uia-0.6/lib/uia/library/win32.rb:31
c:0031 p:0016 s:0161 E:0002dc METHOD C:/msys64/mingw32/lib/ruby/gems/2.5.0/gems/uia-0.6/lib/uia/finder.rb:80
c:0030 p:0159 s:0154 e:000153 METHOD C:/msys64/mingw32/lib/ruby/gems/2.5.0/gems/uia-0.6/lib/uia/finder.rb:25
c:0029 p:0006 s:0149 e:000148 METHOD C:/msys64/mingw32/lib/ruby/gems/2.5.0/gems/uia-0.6/lib/uia.rb:20
c:0028 p:0013 s:0144 e:000143 BLOCK  test/test_helper.rb:12 [FINISH]
c:0027 p:0035 s:0141 e:000140 METHOD test/test_helper.rb:22
c:0026 p:0023 s:0133 E:002180 METHOD test/test_helper.rb:12
c:0025 p:0005 s:0129 e:000128 BLOCK  test/test_helper.rb:35 [FINISH]

Failure rises while find application window:

    def run_app
      @app = ChildProcess.build('notepad').start
-->      wait_until { Uia.find_element title: /блокнот/i }
      @app
    end

Gems:

ffi (1.9.25 x86-mingw32)
uia (0.6)

Thanks.
Leonid.

@leviwilson
Copy link
Member

leviwilson commented Aug 5, 2018 via email

@leviwilson
Copy link
Member

I will try to take a look later on this afternoon and see if I can see what might be going on. It's been a while since I have maintained this gem but what you are trying should absolutely work.

@leoniv
Copy link
Contributor Author

leoniv commented Aug 6, 2018

Unicode does not matter. I call #find_element with ascii title like so:

    def run_app
      @app = ChildProcess.build(PATH).start
      wait_until { Uia.find_element title: /MainFormWindow/i }
      @app
    end

but fault appears also.

I suppose it's ffi bug. I've replaced callback pointer to zero and "segmentation fault" error doesn't appear, but uia doesn't work too (:

    def find_window(parent, &block)
      found_window = nil
      window_callback = FFI::Function.new(:bool, [:long, :pointer], {convention: :stdcall}) do |handle, _|
        found_window = handle if block.call handle
        !found_window
      end
#      Win32.enum_child_windows parent, window_callback, 0
      Win32.enum_child_windows parent, 0, 0
      found_window
    end

Have you any idea?
Thanks a lot for your time.

@leviwilson
Copy link
Member

You're using the 32-bit version of ruby, correct? Not the x64?

@leoniv
Copy link
Contributor Author

leoniv commented Aug 6, 2018

Of course ruby 2.5.1p57 (2018-03-29 revision 63029) [i386-mingw32]

@leoniv
Copy link
Contributor Author

leoniv commented Aug 9, 2018

Solved (conditionally)

Cause of this is bug in the ffi gem.

Error is present in the ffi x86-mingw32 from v1.9.21 up to last v1.9.25 and reproduces in the Rubies:

  • ruby 2.0.0p648 (2015-12-16 revision 53162) [i386-mingw32]
  • ruby 2.3.7p456 (2018-03-28 revision 63024) [i386-mingw32]
  • ruby 2.4.4p296 (2018-03-28 revision 63013) [i386-mingw32]
  • ruby 2.5.1p57 (2018-03-29 revision 63029) [i386-mingw32]

Ruby v2.1 and v2.2 haven't tested.

From v1.9.4 up to 1.9.18, ffi working fine in the same Ruby versions as above, excluded Ruby v2.5. ffi less than v1.9.21 does not compatible with Ruby 2.5.

Conclusion. For perfectly using uia gem required:

  • mingw32 Ruby from v2.0 up to v2.4
  • ffi x86-mingw32 gem from v1.9.4 up to 1.9.18

Set this dependencys in your gemspec or Gemfile and enjoy.

For @leviwilson best regards and thanks for great work.

@leviwilson
Copy link
Member

@leoniv thank you so much for finding that! I didn't think to bump that b/c I thought v1.9.4 was good to go (there was an issue like that before.

Good catch! Would you like to potentially send a pull request to lock it to those versions of FFI and we can close this issue? Thanks!

@leviwilson
Copy link
Member

ffi/ffi#302 was the original issue that I had bumped to v1.9.4

@leviwilson
Copy link
Member

#7

@leoniv
Copy link
Contributor Author

leoniv commented Aug 9, 2018

I'm understand what is happening less and less more ))

Bug is not in the ffi source bug in the ffi gem build!

I have built ffi v1.9.25 form sources at my laptop and it perfectly works without any fails.

Have you ideas what to do in this case?

May be whrites about it trobles in to the msys2 project? Who build gems for prodaction? My be problem on the my laptop only?

@leviwilson
Copy link
Member

leviwilson commented Aug 9, 2018 via email

@leoniv
Copy link
Contributor Author

leoniv commented Aug 9, 2018

I will to do so.
I suppose this issue can be closed whitout lock. I will write about this problem in the uia README if you don't mind.

Thanks for your time again.
Good luck.

@leoniv leoniv closed this as completed Aug 9, 2018
@leoniv
Copy link
Contributor Author

leoniv commented Aug 11, 2018

ffi/ffi#649

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