Something about Tables broke in recent Snapshot
See original GitHub issueExcuse the vague report, I’m trying to debug on my own and figure it out to no avail.
Situation: My app was updated the other day, I had to update some Gradle dependencies, recompile, and upload to Google Play. (So the LibGDX Snapshot probably updated.) Nothing else was changed. The next day I received reports from only a couple users showing me what is in the below screenshots. Some buttons in my app’s menu are the wrong size, huge and broken in some cases.
I installed on all of my 7 test devices, no issue. I cannot reproduce this. Seemingly nobody else is reporting this issue either. I thought it a fluke, but today a couple more reported to me as well.
Even odder, a reinstall of the app fixes it, as these users have told me. The way the UI is built is absolutely not dependent with any persistent/saved properties where a reinstall would fix it. This is very bizarre.
Screenshots (notice the left-side, the top buttons are either “too big” or “take up the whole screen big”, also you’ll notice another button is seemingly shifted out of the menu horizontally as well).
I notice a common factor in the code where these buttons are added to the ScrollPane’s Table:
_undoButton = createToolTextButton(App.bundle.format("undo"), Module.getNormalButtonStyle());
add(_undoButton).align(Align.right).height(_undoButton.getHeight() * 0.75f);
public static TextButton createToolTextButton(String text, TextButtonStyle textButtonStyle)
{
TextButton textButton = new TextButton(text, textButtonStyle);
textButton.getLabel().setWrap(true);
textButton.getCell(textButton.getLabel()).pad(0, 4, 0, 4);
return textButton;
}
I modify the height by taking the height of the Button and scaling it down 0.75f. This code has been in place for years but likely something is either wrong or this is now deprecated behavior?
Similarly, the button which is shifted out of view horitontally has width-edit code:
_importStickfigureButton = createToolImageTextButton2(App.bundle.format("importStickfigure"), Module.getLargeStickfigureButtonStyle());
importTable.add(_importStickfigureButton).width(_importStickfigureButton.getWidth() * 0.75f);
And the Table object these buttons are added to is initialize like:
public void initialize(Drawable tableGrayBackground)
{
// Setup the table.
if (tableGrayBackground != null)
setBackground(tableGrayBackground);
pad(20, 0, 20, 0);
defaults().space(0).spaceRight(10).spaceBottom(10).pad(0).align(Align.center).expandX().uniformX();
}
I notice commits were made recently to scene2d recently (https://github.com/libgdx/libgdx/commits/master/gdx/src/com/badlogic/gdx/scenes/scene2d/ui), specifically about layout() stuff (41e65e25cfd24ec72aaf01fbf1aa39e1001019b2).
I’d have to believe something is wrong in one of these recent commits. I apologize again for the vague issue report where I can’t pinpoint the exact problem, but hoping maybe the source of this problem is more apparent to one of you guys?
I’m still confused as to why this affects a very small percentage of users, and a reinstall fixes it.
Version of LibGDX and/or relevant dependencies
1.9.12-SNAPSHOT
Please select the affected platforms
- [ X] Android
- iOS
- HTML/GWT
- Windows
- Linux
- MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (22 by maintainers)
Top GitHub Comments
Aye, it could very well have something to do with the recent changes. FWIW, I use Table extensive in a large app (Spine) and have done a recent release to thousands of users without layout issues, but it could be you are using it differently. My app has 1:1 pixel:stage units, which is pretty big difference.
Since your viewport setup likely doesn’t map 1:1, you may not want to use Table rounding at all. Eg say an actor is 10.5 tall in stage units and you have Table round to 11 stage units, when displayed on the screen both the 10.5 and 11 are unlikely to be mapped to an integer pixel. Since the rounding doesn’t help you avoid texture filtering, there’s not much point to doing it. Still, if the issue is with rounding we should of course figure out why it happens.
No idea, this is pretty mysterious. Maybe your UI is slightly different when refreshly installed? I wonder if just running it multiple times would have “fixed” it.
@MrStahlfelge It’s rare for others to pull a PR and try it out, especially for small to medium sized changes. Eg, a PR would not have helped avoid this Table issue. Generally a PR is appropriate for changes where discussion is needed about if it should be done at all or how it should be done. If I think a change needs that then I’ll make a PR, as I’ve done in the past. Otherwise, I am already the gatekeeper for the parts of libgdx I maintain. It is unreasonable to run from
master
and expect there to never be problems. Let’s please stop derailing this and other issues with this discussion.True and I would like to test it. Though I looked at the code for rounding in Table and I don’t see anything there that would cause such wild values. Secondly, the spaceRight(10 * assetScaling) resulting in a crash due to it evaluating to <0 at random values also indicates something more voodoo-y at work. I just suspect LibGDX is fine and it was a fault on my end. But true @ what you say about the rounding thing, maybe even a static value would do the trick.