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

32-bit Support for _AdjustLaunchApp(...) #123

Closed
alexeSGN opened this issue Feb 13, 2018 · 12 comments
Closed

32-bit Support for _AdjustLaunchApp(...) #123

alexeSGN opened this issue Feb 13, 2018 · 12 comments

Comments

@alexeSGN
Copy link

The implementation of _AdjustLaunchApp specifies longs, which are 32 bit on older iOS devices, whereas Unity longs are converted to Int64s via il2cpp. This was causing string mangling and invalid values for long info1 and the other values after that in this method (NaN for delayStart) from 4.12.

We believe these should be long longs or int64_t in order to support older 32-bit devices correctly, while being correct for 64 bit as per https://developer.apple.com/library/content/documentation/Darwin/Conceptual/64bitPorting/MakingCode64-BitClean/MakingCode64-BitClean.html.

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

@alexeSGN

Thanks for reporting. We will test long longs and make an update if everything seems fine.

Are you saying that usage of long data type in the parameter list caused weird behaviour with strings (const char*s)? Can you elaborate on the reason behind it?

Also, are you able right now to reproduce problem where longs are not reaching iOS bridge method with proper values and if yes, with which device/OS version are you managing to achieve that?

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

Also, are you seeing this issue happening with latest 4.12.2 version? If yes and if you can reproduce it, does simple switch of long parameters inside of _AdjustLaunchApp to int64_t type solve the issue?

@alexeSGN
Copy link
Author

We were able to repro on our 5S with the original 4.12 version code. The long data is set to -1 by default, so the binary representation of this is 0xffffffffffffffff, so all the longs themselves LOOK correct when only considering 32 bits (0xffffffff), however a double does not support 0xffffffffffffffff, treating that as >infinity. We also saw the strings pointed to garbage after the conversion to _AdjustLaunchApp, but looked fine in our Bulk_Assembly call.

We are able to run with long longs (current release), and int64_t builds for us using the base 4.12 method. I will look into updating to 4.12.2 once I am finished tracking down an Android crash.

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

Thanks for the explanation. I am curious to see if you are seeing issues with 4.12.2 as well. Also another question - you said you have noticed that const char* pointers pointed to junk - did you make any custom fix on your side for that and if yes, what did you do?

@alexeSGN
Copy link
Author

Once you fix the 32 -> 64 bit size of the Unity longs, the PInvoke maps the strings correctly, so our change fixed what other users reported as #119 and #118. We didn't need to reorder the strings as your 4.12.2 changes did. Putting the strings first fixes those crashes, but obfuscates the fact that the longs are overrunning through each other and mangling delayStart (NaN) and the other is[...]CallbackImplemented parameters.

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

Awesome information, thank you so much. So to recap - switching our data types in AdjustUnity.mm from long (32-bit in Obj-C) to int64_t in order to accommodate Unity long values (64-bit) would solve PInvoke mapping issues and pretty much issues that you and guys from 118/119 issues noticed? You mentioned callback implemented parameters, so conversion of all ints to int64_t should be done as well, right?

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

And also, Android crash you mentioned you are solving - is it related to our plugin and if yes, can you share some more detail on that?

@alexeSGN
Copy link
Author

The Unity longs are il2cpped to int64_t. You just need to change the longs; your is[...]CallbackImplemented parameters are mapped to int32_t in il2cpp, and standard ints on 32 & 64 bit C methods for iOS should be 4 bytes either way, so those are fine as is.

The Android crash may be related, but I will follow up once we track down whether it's a build step failure on our end, or an sdk issue.

@uerceg
Copy link
Contributor

uerceg commented Feb 13, 2018

👍Thanks and looking forward to hear from you on Android issue. Update with these suggested changes will be live as soon as possible. Will still wait for your Android crash investigation to see if there's anything else that maybe needs to be changed.

@alexeSGN
Copy link
Author

We are not able to reproduce with 4.12.2 for now, so these Android crashes were most likely a local build issue.

@uerceg
Copy link
Contributor

uerceg commented Feb 14, 2018

Great. I will prepare PR and ping you in here once ready to check the proposed changes and see if there’s anything to be added in addition to them.

@uerceg uerceg mentioned this issue Feb 16, 2018
@uerceg
Copy link
Contributor

uerceg commented Feb 16, 2018

@alexeSGN

v4.12.3 is now live: https://github.com/adjust/unity_sdk/releases/tag/v4.12.3 and should solve this issue. Feel free to reopen the issue if you still encounter the issue.

Thank you one more for reporting and for your help on this issue.

Cheers.

@uerceg uerceg closed this as completed Feb 16, 2018
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

2 participants