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

XmlReader.java gets stuck in infinite loop on nVidia Android hardware due to ART optimizations #3351

Closed
Unsanctioned opened this issue Aug 13, 2015 · 7 comments

Comments

@Unsanctioned
Copy link

The tight loops inside XmlReader.java end up being optimized by the ART on nVidia hardware - Shield TV and possibly others - such that changes to the loop variables are lost.

The problem occurs with the variables _upper and _lower in the while(true) loops at lines 130 and 152.

A workaround is to access those variables at the bottom of the loop in a debug log message between lines 141-142 and between 163-164.

@MobiDevelop
Copy link
Member

Sounds to me like an issue which should be reported to the Android team.

@Unsanctioned
Copy link
Author

I would agree, except for a couple of pieces of information:

  1. In the dozen devices I've tested, this only seems to affect the nVidia Shield TV - which suggests it's an issue for nVidia to fix rather than Android.

  2. nVidia's response is: "(The software team) believe it's a valid optimization that ART is doing much like a C compiler would do in the same instance."

That doesn't leave much option for having it fixed outside of libgdx. For my own needs, I'll likely be hacking a local version of XmlParser.java that works around the issue.

@xoppa
Copy link
Member

xoppa commented Aug 14, 2015

Can you include a link to the nvidia (and android?) response? Afaik the XmlReader class is generated by Ragel, so it is probably not a good idea to modify that class directly. Otherwise, I guess a simple solution would be to use while (_upper >= _lower)

@Unsanctioned
Copy link
Author

The response was in an email thread with their developer support team. The response was:

"I did ask some of the SW people about that and they believe it's a valid optimization that ART is doing much like a C compiler would do in the same instance. They suggest you explicitly use the variables which it sounds like you are doing as the WAR."

@davebaol
Copy link
Member

I'd close this issue for the reasons below:

  • It's clearly a device-specific issue
  • that device is not so common
  • you could ask the ragel team to generate more usual code (like the one suggested by @xoppa ) here, here and here. If they release a new version we will use it for sure.

@xoppa
Copy link
Member

xoppa commented Oct 3, 2015

I don't agree that an optimization which clearly alters the functionality is valid (at least not if you cant disable it somehow). But I guess there isn't much we can do about that. Going to close this for above reasons. Please send a pull request when this is fixed in ragel.

@xoppa xoppa closed this as completed Oct 3, 2015
@Unsanctioned
Copy link
Author

I very much agree that the optimization itself is incorrect. As much as anything, I wanted an issue listed here in case others run into it and go looking for solutions. My workaround ended up being replacing XmlParser.java with a locally-modified version, and inserting that into a local replacement for TmxMapLoader.

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