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

Windows 10 x64 issue with Fiddle and libui #32

Closed
AndyObtiva opened this issue Sep 29, 2021 · 25 comments
Closed

Windows 10 x64 issue with Fiddle and libui #32

AndyObtiva opened this issue Sep 29, 2021 · 25 comments

Comments

@AndyObtiva
Copy link
Collaborator

AndyObtiva commented Sep 29, 2021

I tried libui on Windows 10 x64 after installing Ruby 3.0.2 x64 via Ruby Windows Installer (and running gem install glimmer-dsl-libui to install gem + dependencies) and I keep getting this error upon loading libui:

$ ruby -r glimmer-dsl-libui -e "require 'examples/basic_window'"
e:/Ruby30-x64/lib/ruby/3.0.0/fiddle.rb:49:in `initialize': No such
file or directory (Fiddle::DLError)
        from e:/Ruby30-x64/lib/ruby/3.0.0/fiddle.rb:49:in `new'
        from e:/Ruby30-x64/lib/ruby/3.0.0/fiddle.rb:49:in `dlopen'
        from e:/Ruby30-x64/lib/ruby/3.0.0/fiddle/import.rb:86:in
`block in dlload'
        from e:/Ruby30-x64/lib/ruby/3.0.0/fiddle/import.rb:77:in `collect'
        from e:/Ruby30-x64/lib/ruby/3.0.0/fiddle/import.rb:77:in `dlload'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui/ffi.rb:12:in
`<module:FFI>'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui/ffi.rb:7:in
`<module:LibUI>'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui/ffi.rb:6:in
`<top (required)>'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui.rb:21:in
`require_relative'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui.rb:21:in
`<module:LibUI>'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libui-0.0.10/lib/libui.rb:6:in
`<top (required)>'
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
`require'
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
`require'
        from e:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/glimmer-dsl-libui-0.1.4/lib/glimmer-dsl-libui.rb:31:in
`<top (required)>'
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in
`require'
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in
`rescue in require'
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in
`require'
<internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
`require': cannot load such file -- glimmer-dsl-libui (LoadError)
        from <internal:e:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in
`require'

I double checked the dll file path and the dll file does exist.

I installed both the Ruby MSYS and MING toolchains by the way. I did see an odd error in the beginning:

mkdir: cannot change permissions of ‘/dev/shm’: Permission denied 
mkdir: cannot change permissions of ‘/dev/mqueue’: Permission denied

I am not sure if they are related at all.

Do you have any idea what is going on?

@kojix2
Copy link
Owner

kojix2 commented Sep 30, 2021

Hi!
Thank you for your report!

I double checked the dll file path and the dll file does exist.

I thought I might have forgotten to include the dll in the gem in the 0.0.10 release, but when I unzipped the gem file (actually a zip file), the dll file was included. Then I removed existing libui gem and installed the libui gem from the remote rubygem server on Windows, and it worked. So it is not that I forgot to put in the dll.

And I see some of your glimmer-dsl-libui examples worked on Windows.
Great work!

image

@AndyObtiva
Copy link
Collaborator Author

Thanks for confirming that it works on Windows. Something must be wrong with my Windows setup (I installed it on my Mac via VirtualBox). It is Windows 10 Pro (OS Built 19043.1237). I will keep digging. Perhaps, I will try with a real Windows PC too once I get ahold of one over the weekend.

@kojix2
Copy link
Owner

kojix2 commented Sep 30, 2021

But I don't know what's wrong with your libui installation.
Perhaps you may be using 32bit Ruby and libui will not work. In that case, you need to download libui.dll manually.
See https://github.com/kojix2/LibUI#development

@rubyFeedback
Copy link
Collaborator

I tested this on my windows 10 laptop, via the ruby one click installer, in a cmd.exe shell.

I could install libui 0.0.10 just fine; the examples also work (I noticed that I broke one of
my own examples recently in my gem ... when I have more time I have to fix tons of
things in my libui-related gem ... right now I focus a bit more on ruby-gtk3 again. I
alternate a lot!).

I have not tested it in msys2/mingw. However had, that error actually seems familiar
to me. msys2/mingw is quite complicated (for me), but I think this may be an issue
more pertaining to msys2 perhaps.

I do not know how your error can be solved, but I think that error may not happen always.
I remember I uninstalled mingw once, and then set it up again, because I had no idea what
was going on anymore on windows. I think, but I am not sure, I did not install the msys2
environment from the ruby one click installer, and only used the msys2 installer + 64 bit.

What I can, however had, say is that libui 0.0.10 works on my win10 laptop. One main reason
why I use libui on windows is because I actually needed that for an elder relative who does not
know how to work with computers very well. One small backup utility I wrote just so that backing
up data is simpler. I just verified that the same code works on libui 0.0.10 - and it does!

So I think this issue is most likely more pertaining to something in the setup and msys2/mingw.

@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Oct 8, 2021

I haven't had a chance to try a real Windows PC, but I uninstalled Ruby and tried to reinstall without msys as version 3.0.2, 2.7.4, 2.6.8 to no avail. Loading libui always resulted in that Fiddle error claiming the dll is not there when in fact it is there.

My Windows 10 installation in VirtualBox is definitely x64.

Here are the specs;
Edition Windows 10 Pro
Version 21H1
Installed on ‎9/‎14/‎2021
OS build 19043.1237
Experience Windows Feature Experience Pack 120.2212.3530.0

Device name DESKTOP-OG3UV1I
Processor Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz 2.49 GHz
Installed RAM 6.00 GB
Device ID F086567A-34D5-48A3-8116-B7F09E19B97F
Product ID 00330-80000-00000-AA089
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display

And, my Ruby definitely is x64 too. For example, here is what the 2.6 version says when I run ruby --version:

ruby 2.6.8p205 (2021-07-07 revision 67951) [x64-mingw32]

I will see if I get a chance in the near future to try on a real Windows PC instead of VirtualBox on the Mac.

But, at least the specs above might give you a way to reproduce the problem by downloading the same exact version of Windows 10 from Microsoft and running on VirtualBox on the Mac.

@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Oct 11, 2021

OK, I finally got a chance to try in a real Windows PC, and it worked, but I discovered many issues with Glimmer DSL for LibUI and its examples on Windows, which need to be fixed.

@kojix2
Copy link
Owner

kojix2 commented Oct 12, 2021

Hi
I have also tried Virtualbox.

I am using Windows 10 (64-bit) on Ubuntu,

  • Windows 10 Education
  • Version 21H1
  • Installed on 2020/10/22
  • OS build 19043.1237
  • Experience Windows Feature Experience Pack 120.2212.3530.0

installed Ruby 3.0.2 (64-bit) with RubyInstaller, and updated pacman and all gem packages to the latest as of 2021-10-12.

ridk exec pacman -Syu
gem update --all

glimmer-dsl- libui works. Please see the screenshot. (Indeed, as you said, some of the samples don't seem to work as expected. However, there was no error that the dll was not found.

image

@AndyObtiva
Copy link
Collaborator Author

I fixed most of the Windows issues in Glimmer DSL for LibUI v0.2.13 except a few that seemed caused by libui, which I reported under API Gotchas

Since this GitHub issue does not happen outside of VirtualBox running on a X64 Mac, I will close for now, but it could be reopened in the future if someone else encounters it (especially if under other circumstances).

That said, please keep in mind that Windows 11 was recently released as well as Mac ARM (Aarch64) and Linux Aarch64. I wonder how LibUI will fare in these new environments.

@kojix2
Copy link
Owner

kojix2 commented Oct 18, 2021

I see.
Mac ARM (Aarch64) may be the cause of this issue. I hadn't thought of that.
While libui hasn't been updated in a few years, companies like Apple are using newer CPUs, so hopefully LibUI will work on those platforms as well.

@AndyObtiva
Copy link
Collaborator Author

My machine is not Mac ARM (Aarch64). It is an old MacBook Pro 2015 x64, so that is not my issue for sure. I only mentioned that as a side-note to keep in mind for the future of LibUI. I heard all Mac ARM (Aarch64) have a backwards compatibility layer to continue to work with x86-64 software, but it would be interesting if libui (C library) would support ARM directly in the future like you said.

@kojix2
Copy link
Owner

kojix2 commented Oct 18, 2021

I read it wrong. Sorry.

@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Oct 28, 2021

Good news! I got examples/basic_transform.rb working in Windows just like Mac and Linux. It turned out to be an ordering issue for transforms on Windows (if you put skew and translate after rotate and scale, it ends up looking just like on Mac and Linux)

glimmer-dsl-libui-windows-basic-transform

Thankfully, I got everything fixed on Windows (except for minor gotchas that I noted).

@kojix2
Copy link
Owner

kojix2 commented Oct 28, 2021

Great!

@rubyFeedback
Copy link
Collaborator

I ran into that issue too just today after I reinstalled my win10 laptop. Very strange.

I'll try the manual way in a moment.

@kojix2
Copy link
Owner

kojix2 commented Dec 3, 2021

@rubyFeedback
I have run LibUI on Windows, and have never had LibUI not work, either on a virtual box or on a real Windows computer. However, both Andy and shavy have experienced this problem on Windows. I think this error is very common. I can't help but wonder if other users are experiencing the same situation. I think there is some unknown reason why LibUI is not working on Windows.

@rubyFeedback
Copy link
Collaborator

Heya kojix2,

I think I may be able to add some info actually.

So my laptop has some issue ... I think this is not directly related to windows per se, but something to do with the chipset.
It kind of becomes super-slow sometimes and "lags". I even have this sometimes on linux, but not as bad as on linux.

Anyway, I actually noticed that I used a Windows Home installation. So, on that laptop I installed Fedora, which works fine. And on my second desktop machine I now have installed Windows Pro (or Enterprise, but either way NOT the home version). And on that same machine (running an Intel chipset, and NOT Windows Home), I just tested libui + fiddle, and on a first installation it works. \o/

No problem on that computer.

I can not say whether this has something to do with Microsoft Home windows (perhaps some dll is missing or different there), or whether it has to do with the chipset in use, but I wanted to just give that feedback here in the event that someone else runs into such an error. So the two parts I would recommend others to look out for is:

(a) Home version versus pro/enterprise windows

AND

(b) chipset in use (I think some chipsets cause more issues, just as my lenovo laptop shows. I never have these issues on my desktop computers ... one of them I bought just recently and no issue there either, but the old chipset from 2014 had issues; booting sometimes stopped for no reason at all. I don't know whether this may impact fiddle or not, but perhaps the information may be useful for someone in the future)

@kojix2
Copy link
Owner

kojix2 commented Dec 4, 2021

@rubyFeedback
Thanks for the reply.
I find it hard to believe that Home and Pro are different. If you run into the same situation again, download the compiled examples from the libui release and see if they work. if the libui examples don't work, the problem is probably unrelated to Ruby.

I will reopen this issue.

To:all
If you are reading this and can't get LibUI to work on Windows, please post your environment here. (Or start a new issue).

@kojix2 kojix2 reopened this Dec 4, 2021
@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Dec 5, 2021

@kojix2 I tried your suggestion to run binary C libui examples in the Windows environment that I had trouble with in the past (Windows 10 Pro x64 running in VirtualBox on top of Mac Catalina x64 or Big Sur x64) [Windows 10 on a real machine had no issues]

The examples ran successfully. I was able to run histogram and control gallery from these groups:

This must be a Ruby issue then?

@kojix2
Copy link
Owner

kojix2 commented Dec 5, 2021

Thanks @AndyObtiva

Then it might be a Ruby problem. At least, we might be able to do something about it.
Fiddle maintainer, @kou, said that the DLLs that libui.dll depends on may not exist in some Windows environments.

The DLLs used by libui.dll include MSVCP140.dll and VCRUNTIME140.dll. Are these DLLs included in RubyInstaller? If not, I think you will get a load error.

List of DLLs on which libui.dll depends

$ objdump -p vendor/libui.dll | grep -i dll
vendor/libui.dll:     ファイル形式 pei-x86-64
    DLL
DllCharacteristics    00000160
 vma:            Hint    Time      Forward  DLL       First
    DLL Name: USER32.dll
    DLL Name: KERNEL32.dll
    DLL Name: GDI32.dll
    DLL Name: UxTheme.dll
    DLL Name: d2d1.dll
    DLL Name: DWrite.dll
    DLL Name: ole32.dll
    DLL Name: MSVCP140.dll
    DLL Name: VCRUNTIME140.dll
    DLL Name: api-ms-win-crt-math-l1-1-0.dll
    DLL Name: api-ms-win-crt-runtime-l1-1-0.dll
    40142       63  _seh_filter_dll
    DLL Name: api-ms-win-crt-convert-l1-1-0.dll
    DLL Name: api-ms-win-crt-stdio-l1-1-0.dll
    DLL Name: api-ms-win-crt-string-l1-1-0.dll
    DLL Name: api-ms-win-crt-utility-l1-1-0.dll
    DLL Name: api-ms-win-crt-heap-l1-1-0.dll
名前                 000000000003ca0e libui.dll

He also said that dll problems can be investigated with Dependency, but I am not familiar with this. I know you are busy, but you could check it out if you would like to.

@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Dec 5, 2021

My mind is blown!!!

I ran Dependencies (https://github.com/lucasg/Dependencies/releases/download/v1.11.1/Dependencies_x64_Release_.without.peview.exe.zip), loaded libui.dll with it, and it said it loaded fine:
dependencies-libui-dll

Next, I tried running glimmer-dsl-libui meta-example, and IT WORKED!!!

glimmer-dsl-libui-windows-meta-example

I don't know how! I am worried that Dependencies might have brought over the dlls that are missing (if any)! I don't know. Oh well! So much for this issue. If I encounter on another machine or virtual machine, I will report again.

But, there might be another reason. I've installed .NET Framework 3.5.1 and WiX Toolset at one point. I wonder if that helped though I might have done so before I initially tested LibUI.

At least, I've resolved the issue on VirtualBox for the first time though. That is very good news!

@Delikt
Copy link

Delikt commented Jan 26, 2022

Hi, i got a solution for my Issue #48 - maybe this fix also this Error:

#48 (comment)

@kojix2
Copy link
Owner

kojix2 commented Jan 28, 2022

This issue is closed because it was confirmed that there is a case of missing dlls when libui does not work on Windows.
A link to issue #48 and comments will be included in the README.

However, there may still be other people who cannot get libui to work on Windows. If so, please create a new issue as this is a different issue.

@kojix2 kojix2 closed this as completed Jan 28, 2022
@AndyObtiva
Copy link
Collaborator Author

AndyObtiva commented Jan 28, 2022

One thing I neglected to mention originally was that I also installed something called the WiX Toolset (I added to my previous comment), which enables building Windows installers for applications. It might have as well brought the Visual C++ Redistributable with it. I wouldn’t be surprised if it did.

That said, to be honest, I don’t think this issue is resolved if it is confirmed that dll’s are sometimes missing. After all, the fix expects developers to install a developer toolkit (the VC++ redistributable). That means, they cannot just install the LibUI Ruby gem and expect it to work (one of the strongest selling points of LibUI).

Also, the issue is a bit unpredictable since it seems LibUI does work out of the box on some Windows systems of non-developers.

I think more attention needs to be spent on ensuring the LibUI Ruby gem works out of the box on Windows. For example, by trying to include more binaries for Windows just in case they are missing. Keep in mind that Ruby developers use a dynamic programming language because they seek convenience above all else. They usually don’t care about memory and speed so much as long as they are reasonably within the limits of their machine. The developers who care so much about things other than convenience don’t use Ruby to begin with. They just resort to C, C++, Objective C, Swift, Java or Crystal instead. But when using Ruby, it is for tasks that are not too memory, disk, or performance sensitive. And, that constitutes more than 80% of software engineer business tasks these days. That’s why Rails is so successful despite obviously not being as optimal as using Java or C++ in performance. Anyways, in summary, it is very important to keep convenience as one of the top goals in any Ruby library.

Thank you for keeping LibUI alive and as convenient as it is for use. I look forward to continued attention to supporting productivity with it.

@kojix2
Copy link
Owner

kojix2 commented Jan 28, 2022

I can think of a solution in two directions.

(1) To raise an error when Fiddle detects a missing DLL and display it in LibUI to prompt the user to install Visual C++ Redistributable. However, according to kou, Fiddle is unable to detect missing DLLs due to Windows limitations. Therefore, this method is not possible at the moment. But there may be a way we don't know of.

(2) To include frequently missing libraries in gem. This is also an issue of the C libui and depends on what the future release of libui-ng will be. There might be a way to use a custom libui.dll with Ruby's LibUI, but I don't want to do that because it would be too complicated for me

I totally agree with you about the culture of Ruby and the benefits of the ecosystem. It certainly feels that way.

@kojix2 kojix2 mentioned this issue Jan 28, 2022
@kojix2
Copy link
Owner

kojix2 commented Feb 5, 2022

I reported it to Upstream...
libui-ng/libui-ng#67

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

4 participants