Skip to content

Bug after clang optimization on android ndk r22b+. #47

@perminovVS

Description

@perminovVS

In the release build on Android(-O1 -O2 -O3), a large lag periodically occurs for several seconds, after a while it repeats.

Having spent a lot of time localizing the problem, it came down to the methods: CCRakNetSlidingWindow::ShouldSendACKs and CCRakNetUDT::ShouldSendACKs.

	// iphone crashes on comparison between double and int64 http://www.jenkinssoftware.com/forum/index.php?topic=2717.0
	if (rto==(CCTimeType) UNSET_TIME_US)
	{
		// Unknown how long until the remote system will retransmit, so better send right away
		return true;
	}

To solve this, I simply disable optimization for this section.

#pragma clang optimize off
// ----------------------------------------------------------------------------------------------------------------------------
bool ShouldSendACKs(CCTimeType curTime, CCTimeType estimatedTimeToNextTick)
{
	CCTimeType rto = GetSenderRTOForACK();
	(void) estimatedTimeToNextTick;

	// iphone crashes on comparison between double and int64 http://www.jenkinssoftware.com/forum/index.php?topic=2717.0
	if (rto==(CCTimeType) UNSET_TIME_US)
	{
		// Unknown how long until the remote system will retransmit, so better send right away
		return true;
	}

	return curTime >= oldestUnsentAck + SYN;
}
#pragma clang optimize on

The problem is in the versions:
Android NDK r22b, r23, r24, r25, r26, r27

If anyone else is using RakNet on modern platforms, I hope it helped you!
Good luck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions