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

[master branch] Could not initialize Lua when luajit < 2.1.0 installed on macOS Catalina #7512

Closed
jnozsc opened this issue Mar 7, 2020 · 9 comments
Labels

Comments

@jnozsc
Copy link
Contributor

jnozsc commented Mar 7, 2020

mpv version and platform versions

master branch, Mac OS X 10.15.33

Reproduction steps

this behavior happens after d852ad2

and only happens when both luajit and lua@5.1 are installed from Homebrew

brew install luajit
brew install lua@5.1

Expected behavior

in my mpv.conf, I added one line as

script-opts=osc-layout=box

from tag release/0.32.0 or any commit before d852ad2

I can get the OSC show up when I move my cursor

Screen Shot 2020-03-07 at 08 30 21

Actual behavior

But when I build from d852ad2 or any commit after this commit on master branch. The OSC could never show up

Screen Shot 2020-03-07 at 08 31 19

Log file

https://0x0.st/iT9G.txt

The issue will be closed for ignoring the issue template.

My thought

This issue ONLY happens when BOTH luajit and lua@5.1 are installed from Homebrew.

Before d852ad2 , the build script will pick up lua@5.1 first, after this commit, it will pick up luajit

I try to uninstall luajit from my local and build from master again, the OSC comes back.

I try to revert this commit on my local and build it again with both luajit and lua@5.1 installed, the OSC works well.

I am not sure whether it is a compatible issue or a configuration issue.

A quick fix is revert this commit d852ad2 , or at least move lua@5.1 on the top of luajit . I can create this PR if necessary.

A long term solution seems like require some time to investigate further.

cc @wm4

@jnozsc jnozsc added the core:waf label Mar 7, 2020
@CounterPillow
Copy link
Contributor

So to sum it up: Your OSC isn't working with luajit, but working with every other version of lua?

Can you post a log file of the player generated with --log-file?

@jnozsc
Copy link
Contributor Author

jnozsc commented Mar 7, 2020

Thanks for this sum up, I install lua@5.1 from Homebrew. Homebrew only provide lua@5.1 and lua(5.3), which may not back compatible.

here is the link for the log file you mentioned (both luajit and lua@5.1 are installed)
https://0x0.st/iTpa.txt

it seems I get some message as Could not initialize Lua

@jeeb
Copy link
Member

jeeb commented Mar 7, 2020

Yes, that seems like a borked lua setup. Which is either a build system issue, or just broken libraries. Also that should be broken whether or not you set that script option I would guesstimate.

Well, the build system should be able to pick just one. The fact that you have both installed only means that in theory either one of them could get picked. The commit you point towards switches the priority to 5.2 and luajit over 5.1. Which makes sense. You can still override the selection to lua 5.1 specifically should you want that.

  • You can validate which got pulled on the library side on macOS with otool -L ~/path/to/your/mpv (as long as the library is a shared one).
  • You can fully clean your git repository and configre & build from a clean build root. In case it is any leftovers from lua 5.1 in a build that is now getting built with luajit.
  • If nothing else depends on lua 5.1, attempt removing it just for testing purposes.

On the mpv development channel there's at least one person utilizing luajit with mpv, and for him both with and without that option work (specifically on macOS).

@jnozsc
Copy link
Contributor Author

jnozsc commented Mar 7, 2020

Thank Jeeb

Here are some update

otool -L /usr/local/bin/mpv | grep lua
	/usr/local/opt/luajit/lib/libluajit-5.1.2.dylib (compatibility version 2.0.0, current version 2.0.5)

then I remove my local repo folder, git clone into a new folder and build again from master branch HEAD, I still have the same issue.

I run otool -L command again, still same luajit 2.0.5

I try to install luajit 2.1 beta to figure out whether it is a version issue or my local environment issue, but I can not install version 2.1 for now

Update:

I manage to install luajit 2.1.0 beta on my local, and build mpv again.
The OSC is back
and mpv is using luajit 2.1.0 beta

 otool -L mpv | grep lua
	@executable_path/lib/libluajit-5.1.2.dylib (compatibility version 2.1.0, current version 2.1.0)

So the current status is on my machine, which is macOS 10.15.3, luajit 2.1.0 beta works, but luajit 2.0.5 stable version does not work.

I am totally fine with this result, but I wonder whether luajit 2.0.5 is broken for me only or others. This may be a luajit or homebrew issue, not mpv issue.

Anyway, thank all for helping me figure out my workaround

@jeeb
Copy link
Member

jeeb commented Mar 7, 2020

Great that you were able to poke around and have something work. For the record, the person on IRC is also utilizing luajit master/2.1 branch.

So yes, it could just be that luajit's current release is borked on macOS (or how Homebrew builds it, I lay no blame on either side). Given that I heard random issues about luajit on macOS before I wouldn't be surprised with that luajit release having issues, although this is most likely the first time I've heard that it wouldn't load at all.

@jnozsc
Copy link
Contributor Author

jnozsc commented Mar 7, 2020

Thanks again for confirming this info.

Since the developer is using master/2.1 branch,
may I suggest to bump this line

( 'luajit', 'luajit >= 2.0.0' ),

to

 ( 'luajit', 'luajit >= 2.1.0' ),

I modify this line from my local and build it again, mpv is using @executable_path/lib/libluajit-5.1.2.dylib (compatibility version 2.1.0, current version 2.1.0) and the OSC works fine.

I can create the PR if you guys are busy

@jeeb
Copy link
Member

jeeb commented Mar 7, 2020

The problem is that macOS is the only one having issues. Blanket heightening the version doesn't really make sense.

@jnozsc jnozsc changed the title [master branch] OSC disappears when both lua@5.1 and luajit are installed from Homebrew [master branch] OSC disappears when luajit < 2.1.0 installed on macOS Catalina Mar 7, 2020
@jnozsc jnozsc changed the title [master branch] OSC disappears when luajit < 2.1.0 installed on macOS Catalina [master branch] Could not initialize Lua when luajit < 2.1.0 installed on macOS Catalina Mar 7, 2020
@jnozsc
Copy link
Contributor Author

jnozsc commented Mar 7, 2020

Agree. A dirty solution will looks like

        (
            "luajit",
            "luajit >= 2.1.0"
            if ctx.env.DEST_OS == "darwin"
            and tuple(ctx.env.MACOS_SDK_VERSION.split(".")) >= (10, 15, 0)
            else "luajit >= 2.0.0",
        ),

@jnozsc
Copy link
Contributor Author

jnozsc commented Apr 6, 2020

some note before I close this issue:

  1. This is an upstream issue from luajit
  2. luajit is totally silent Any thought to release luajit 2.1.0 as stable? LuaJIT/LuaJIT#563 , so there won't be a bugfix stable release soon
  3. There are some activity forks of luajit, such as moonjit and luajit2. I hope luajit2 could get a stable release. Make luajit2 into a fully supported project with releases openresty/luajit2#80
  4. I commit to homebrew mpv.rb: always build with lua@5.1 Homebrew/homebrew-core#51335 to force it building mpv with lua51, so that next release of mpv won't be broken for people who install it from homebrew
  5. For people who build the mpv by themselves, please try to use luajit >= 2.1.0 if you reproduce this issue.

Thank all

@jnozsc jnozsc closed this as completed Apr 6, 2020
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 25, 2022
See the previous commit for the full explanation. Basically, luajit 2.0
has a bad pc file on macos that causes libmpv to fail during build. The
workaround was, if the os was darwin and luajit was found, to save a
full luajit dep and a partial luajit dep with the link args removed. The
partial dep was used for compiling libmpv, and the full dep was used for
the actual mpv executable. This worked and was needed for the CI to pass
but it sucked. Since the previous commit now makes the CI grab lua 5.1,
we don't need all this crap anymore. Just delete it and treat the
dependency normally.

This does effectively mean that building libmpv with luajit 2.0 on macOS
will no longer work with the meson build. However libraries not being
built correctly is not a mpv-specific issue. The waf build will succeed
for some reason, but it has known issues and it would be better if it
just failed honestly. An upstream developer said years ago that that
macOS users should use the 2.1 branch (and there's no release of
course). In any case, no macOS user should be building mpv with luajit
2.0, so we shouldn't be going out of our way to support this.

mpv-player#7512
LuaJIT/LuaJIT#521 (comment)
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Feb 7, 2022
See the previous commit for the full explanation. Basically, luajit 2.0
has a bad pc file on macos that causes libmpv to fail during build. The
workaround was, if the os was darwin and luajit was found, to save a
full luajit dep and a partial luajit dep with the link args removed. The
partial dep was used for compiling libmpv, and the full dep was used for
the actual mpv executable. This worked and was needed for the CI to pass
but it sucked. Since the previous commit now makes the CI grab lua 5.1,
we don't need all this crap anymore. Just delete it and treat the
dependency normally.

This does effectively mean that building libmpv with luajit 2.0 on macOS
will no longer work with the meson build. However libraries not being
built correctly is not a mpv-specific issue. The waf build will succeed
for some reason, but it has known issues and it would be better if it
just failed honestly. An upstream developer said years ago that that
macOS users should use the 2.1 branch (and there's no release of
course). In any case, no macOS user should be building mpv with luajit
2.0, so we shouldn't be going out of our way to support this.

mpv-player#7512
LuaJIT/LuaJIT#521 (comment)
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Feb 7, 2022
See the previous commit for the full explanation. Basically, luajit 2.0
has a bad pc file on macos that causes libmpv to fail during build. The
workaround was, if the os was darwin and luajit was found, to save a
full luajit dep and a partial luajit dep with the link args removed. The
partial dep was used for compiling libmpv, and the full dep was used for
the actual mpv executable. This worked and was needed for the CI to pass
but it sucked. Since the previous commit now makes the CI grab lua 5.1,
we don't need all this crap anymore. Just delete it and treat the
dependency normally.

This does effectively mean that building libmpv with luajit 2.0 on macOS
will no longer work with the meson build. However libraries not being
built correctly is not a mpv-specific issue. The waf build will succeed
for some reason, but it has known issues and it would be better if it
just failed honestly. An upstream developer said years ago that that
macOS users should use the 2.1 branch (and there's no release of
course). In any case, no macOS user should be building mpv with luajit
2.0, so we shouldn't be going out of our way to support this.

mpv-player#7512
LuaJIT/LuaJIT#521 (comment)
Dudemanguy added a commit that referenced this issue Feb 7, 2022
See the previous commit for the full explanation. Basically, luajit 2.0
has a bad pc file on macos that causes libmpv to fail during build. The
workaround was, if the os was darwin and luajit was found, to save a
full luajit dep and a partial luajit dep with the link args removed. The
partial dep was used for compiling libmpv, and the full dep was used for
the actual mpv executable. This worked and was needed for the CI to pass
but it sucked. Since the previous commit now makes the CI grab lua 5.1,
we don't need all this crap anymore. Just delete it and treat the
dependency normally.

This does effectively mean that building libmpv with luajit 2.0 on macOS
will no longer work with the meson build. However libraries not being
built correctly is not a mpv-specific issue. The waf build will succeed
for some reason, but it has known issues and it would be better if it
just failed honestly. An upstream developer said years ago that that
macOS users should use the 2.1 branch (and there's no release of
course). In any case, no macOS user should be building mpv with luajit
2.0, so we shouldn't be going out of our way to support this.

#7512
LuaJIT/LuaJIT#521 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants