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

lua: make more compatible with lua 5.3 #1914

Closed
wants to merge 2 commits into from
Closed

lua: make more compatible with lua 5.3 #1914

wants to merge 2 commits into from

Conversation

radistmorse
Copy link

Lua 5.3 introduced stricter integer typisation which leaded to some
errors in osc modules. pushnumber was changed to pushinteger where
applicable, math.floor was used to forcibly convert floats to ints,
an explicit typecast to lua_Integer was introduced in places where
the error might occure with lua compiled with 32bit ints, and
finally, one special corner case in get_screen_size which leaded
to division by zero was taken care of.

This solves the "OSD not showing" bug with lua 5.3

Lua 5.3 introduced stricter integer typisation which leaded to some
errors in osc modules. pushnumber was changed to pushinteger where
applicable, math.floor was used to forcibly convert floats to ints,
an explicit typecast to lua_Integer was introduced in places where
the error might occure with lua compiled with 32bit ints, and
finally, one special corner case in get_screen_size which leaded
to division by zero was taken care of.
@hroncok hroncok mentioned this pull request May 4, 2015
@ghost
Copy link

ghost commented May 4, 2015

Looks mostly fine, but there are problems. In a lot of places you slice off 64 bit integers. While Lua 5.1/2 will preserve about 52 bits of the 64 bit integers, your patch cuts them down to 32 bit (at least on 32 bit architectures, where lua_Integer is 32 bits for some reason). Also, I have doubt you caught all places. (It's not easy because the whole language suddenly changed.)

But most severely, osc.lua seems to require changes. I'm not sure how much of it needs to be changed due to mpv Lua API behaving differently, and how much due to the language changing itself. Who is going to fix all the userscripts that have been written so far? Compiling mpv with Lua 5.3 instead of 5.1/2 would mean breaking them all. This is unreasonable.

All in all, I don't think this is worth the trouble just because one distro thinks everyone should now switch to Lua 5.3.

I've also just noticed that someone else already tried this in #1516 (with similar problems).

@@ -527,7 +533,10 @@ static int script_wait_event(lua_State *L)
pushnode(L, prop->data);
break;
case MPV_FORMAT_DOUBLE:
lua_pushnumber(L, *(double *)prop->data);
if (is_int(*(double *)prop->data))
lua_pushinteger(L, *(lua_Integer *)prop->data);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense. You can't derefence a double* as luaInteger*.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, my bad

@radistmorse
Copy link
Author

About cutting down ints to 32 bits, yes it's bad, but actually, when we are talking about IDs, I don't see how dropping 12 bits is better than dropping 32. Even dropping 1 bit will screw the things up.

Otherwise, the patch doesn't really introduce any 5.3-specific fixes. A strict typisation is always a good thing, and the fact that lua doesn't make a difference between int and double doesn't mean that you should use floats everywhere without any thoughts.

As for the corner case in get_screen_size, I think division by zero IS an error and should be fixed, even if lua 5.2 doesn't show it as such.

About osc.lua: I looked into it. It seemed fine. There WERE problems, like when you try to change the track it would convert "1" to "1.0" and hence fail, but this patch takes care of it.

@ghost
Copy link

ghost commented May 4, 2015

I think division by zero IS an error

No it's not. Why would you think that?

@radistmorse
Copy link
Author

No it's not. Why would you think that?

Because it happens in window size calculation. Window sizes can't be inf's, it's illogical.

@jdek
Copy link
Contributor

jdek commented Jan 29, 2017

This has been stalled for more than a year, no reason to keep it open. It can be reopened in the future if we decide to move to Lua 5.3.

@jdek jdek mentioned this pull request Jan 29, 2017
@Akemi Akemi closed this Jan 29, 2017
@radistmorse
Copy link
Author

Or can you perhaps merge it to some additional branch? I was actually thinking about removing my mpv repo.

@jdek
Copy link
Contributor

jdek commented Jan 29, 2017

@radistmorse merge both commits, git format-patch, and post it here as a comment (as the changes aren't huge). Then will be able to delete your fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants