Let's fix: the chat lag

Voice your bugs/glitches encounters or workarounds you find. While this forum is unofficial, we welcome Disney developers to stop by to help.
User avatar
Kender
Captain
Posts: 99

Re: Let's fix: the chat lag

Post#11 » Fri Dec 23, 2016 10:50 am

1. I see no requests on the network while waiting on the chat (and no difference between cell connection or wifi connection).
2. CPU usage goes through the roof during the wait.

I suspect some silly bug in the algorithm that merges the chat history (from the chat proxy) with the requests/replays (which use the normal game api).

Any differences between devices is probablt due to CPU power. On my PC in an emulator the lag is 4-5 seconds, on my LG G2 is was 40-50 seconds. On my Nexus 6P it is around 20-25 seconds.

Differences between squads may be due to the amount of requests/replays and chat messages being merged.

The only way to get to the bottom of this is to reverse engineer the game code.
- Get Teleriks JustDecompile from http://www.telerik.com/products/decompiler.aspx and install it.
- Get the APK from https://www.apk4fun.com/apk/20610/ or https://apkpure.com/star-wars%E2%84%A2- ... starts_goo and extract it.
- Go to \assets\bin\Data\Managed\ and open Assembly-CSharp.dll with JustDecompile
- Right click Assembly-CSharp, choose Create Project and save the decompile somewhere.
- Get Visual Studio Express from https://www.visualstudio.com/en-us/prod ... ss-vs.aspx
- Open the saved project in Visual Studio and explore.
SONS_OF_DEATH http://squadsofdeath.com
Global Squad War Ranking http://squadsofdeath.com/squadranking


lma
Commodore
Posts: 107

Re: Let's fix: the chat lag

Post#12 » Fri Dec 23, 2016 3:51 pm

I think Berto is right. It is related to squad donation activity. My rebel squad is extremely active. And our lag becomes intoerable after 48 hours, so we have to leave the squad and rejoin to clear our lag. We are talking several minutes just to open up chat log. But sometimes if we've been particularly active as a squad, then the lag will be intolerable even sooner than 48 hrs. I dont think it has anything to do with the number of wars. Because if its the case then it would be gradually getting worse aftet each war. But thats not the case

EDIT. didnt see Kenders post above. Agree with him also


User avatar
Joffray
Commodore
Posts: 114

Re: Let's fix: the chat lag

Post#13 » Fri Dec 23, 2016 7:47 pm

lma wrote:I think Berto is right. It is related to squad donation activity. My rebel squad is extremely active. And our lag becomes intoerable after 48 hours, so we have to leave the squad and rejoin to clear our lag. We are talking several minutes just to open up chat log. But sometimes if we've been particularly active as a squad, then the lag will be intolerable even sooner than 48 hrs. I dont think it has anything to do with the number of wars. Because if its the case then it would be gradually getting worse aftet each war. But thats not the case

EDIT. didnt see Kenders post above. Agree with him also


This. I've been to squads with really low activity. There is little to no lag at all. Definitely associated with squad donations
Lv9, 26k medals
Alderaan-Memory
We have pizza! :D

...Retired...#armoryisop


User avatar
RebelYell
Admiral
Posts: 575

Re: Let's fix: the chat lag

Post#14 » Wed Dec 28, 2016 2:28 am

I now had a closer look at the chat lag problem. (See Kenders Post how this can be done).
I won't say that I understand the whole procedure completely but I got a good overview.

#1: Network performance?
The Disney Servers are not the problem. They deliver the chat messages fast enough.

#2: Message number!
There are two servers involved in the chat. The "chat" server which delivers text messages only and the "game" server which delivers seemingly all other (i.e. donations, war updates, etc...)

On startup, I see that the "game" server delivers a block of 1420 (!) messages to the game.
Inspecting the data, the oldest Message is almost exactly 3 days old.

#3: Opening the Chat window and Message limit:
Here it gets a bit complicated but this is how I understood the code:
When the chat window is opened (initially), many (*) of the 1420 messages are completely processed. And only after (!) processing the messages the count is checked and the message is removed again.
(* actually 1350 of the 1420 non-chat Messages were donation messages and therefore remain untrimmed.)

#4: Cause of the lag?
The lag is caused by high CPU utilization (maybe even GPU) on the client and directly related to the chat/donation activity of the squad in the last 3 days.
By the way:
The number of 1420 is actually low for our squad because we had no war in the last days and activity was probably a bit lower than usually (family demands presence on christmas, you know...)
I think that this number will often get around 3000.

#5: Why did they do it?
a) Lazy coding. "It works this way, why change it?" Optimizing the chat may introduce new errors.
b) War state updates/consistency. The messages contain also info about i.e. Factory Outpost posession and other War state changes. The exact 3 day period equals the (original) time a war takes (1d scouting, 1d war, 1d cooldown).

#6: How to do it better?
I understand that the programmers don't want the chat/game to miss certain messages. But they could at least strip older donation messages when they get past a certain limit. Obviously, the server already delivers a trimmed version of the message list because there are 3 days old donationMessages but no requestMessages older than 9h. The server should not deliver donationMessages which are older than the oldest requestMessage. Filtering those redundant donationMessages on server side should significantly reduce the message count (in my test from 1420 to 261) and therefore reduce the lag.

You could also modify the TrimMessage (see below) method but this would require an app update and is also on the wrong end (imho).

This is the (client-side) "preprocessing" Routine:
StaRTS.Main.Views.UX.Squads/SquadMsgManager::TrimMessages
But: This routine skips all donation messages (basically one message per donation button press).
And: Donation messages are actually the majority (1370 of 1420) of these messages. So TrimMessages does nearly nothing.

Code: Select all

jq "[.data[0].result[] | select(.type == \"troopDonation\")] | length" <response.json


Another method to check:
StaRTS.Main.Views.UX.Squads/SquadMsgChatDisplay::ProcessMessage
Last edited by RebelYell on Wed Dec 28, 2016 7:38 am, edited 7 times in total.
ImageWe're recruiting! (Rebels/Android/iOS). Just PM me here/LINE:lleyleber or request in game with a meaningful text. If you want to take part in wars, lv7+ is useful.


User avatar
rRr
Admiral
Posts: 548

Re: Let's fix: the chat lag

Post#15 » Wed Dec 28, 2016 3:36 am

This is their answer when I was trying to fix the problem with chat:


Thanks for letting me know all of that information about your game and device. If you're still seeing this issue with your game, we're going to run you through basic troubleshooting and from there we'll see about investigating the issue on our end. Try following the steps below to see if it clears up the issue:

- Make sure that your device and app are running the newest version.
- Force Close all apps that you have running in the background.
- Clear your Star Wars: Commander game cache.
- Power OFF your device for at least 5 minutes and then power it back on
- Make sure that your device has at least 1-2 GB of RAM and 1-2 GB of free storage space. Anything under that will start giving you performance issues within the game.
- Ensure you're connected to a strong and steady WiFi signal.
- Do not delete or re-install the app; doing so will cause you to lose any unsynced progress.

Let me know if this helps, or if you are still needing some more assistance. I would be more than happy to help from there!

Charis
STAR WARS™: Commander Support


As for RebelYell's post:
The problem seems not to be on server side, but they really should do some data filtering..more if I am hardy able to see one days messages but my game client downloads 3 days..that is ridiculous..instead of 3 days they might change it into number of messages that is my client able to show.

Also I see a great possibilities of optimization there. You can see only last donation requests so why download them all?

And do they seriously expect us to keep 2GB free place? On some older devices it might be impossible.

To add to RebellYel, I often see, that with weak WiFi signal my chat load only messages without donation requests.

Also there is also question how big those messages are ;) I dont know much about Android programming but if they use ASCI description instead of binar, that might increase size..
Empire HQ X, 30 000+ medals, contrabant addict.
Proud officer of Sith-Society
we have currently 2 open slots,
take your chance to be in same squad as "UCL Tracker" chat family founder
;)
LINE: rrr-firstlorder


User avatar
RebelYell
Admiral
Posts: 575

Re: Let's fix: the chat lag

Post#16 » Wed Dec 28, 2016 3:49 am

The support message which you got seems to be simply the standard message from first-level support. It is probably not related in any way to the chat-lag.

Transfer is not the problem. 1400 messages took around 60kb (gz compressed) in transfer and result in around 400kb uncompressed json data. Many messages will increase the RAM consumption of the game, though (probably considerably more than these 400kb).

When you leave a squad and return (beware, you will lose any unopened war rewards) the message counter is probably reset to 0. So you'll have the chat window open faster until you reach 3 days of squad membership again.
ImageWe're recruiting! (Rebels/Android/iOS). Just PM me here/LINE:lleyleber or request in game with a meaningful text. If you want to take part in wars, lv7+ is useful.


User avatar
RebelYell
Admiral
Posts: 575

Re: Let's fix: the chat lag

Post#17 » Wed Dec 28, 2016 7:45 am

I had another look which led me to edit the previous (#1-#6) post a bit.

Basically, i think that the lag should be significantly reduced by "optimized" processing/trimming of the chat messages on the server side. -> remove obsolete troop donation messages.
Last edited by DeathStriker on Wed Dec 28, 2016 2:49 pm, edited 1 time in total.
Reason: Update Thread Post - Added Link to Previous Post to Aid Discussion when this Post is Quoted.
ImageWe're recruiting! (Rebels/Android/iOS). Just PM me here/LINE:lleyleber or request in game with a meaningful text. If you want to take part in wars, lv7+ is useful.


User avatar
Kender
Captain
Posts: 99

Re: Let's fix: the chat lag

Post#18 » Wed Dec 28, 2016 11:11 am

Good work RebelYell!
SONS_OF_DEATH http://squadsofdeath.com
Global Squad War Ranking http://squadsofdeath.com/squadranking


User avatar
rRr
Admiral
Posts: 548

Re: Let's fix: the chat lag

Post#19 » Wed Dec 28, 2016 11:32 am

RebelYell wrote:I had another look which led me to edit the previous (#1-#6) post a bit.

Basically, i think that the lag should be significantly reduced by "optimized" processing/trimming of the chat messages on the server side. -> remove obsolete troop donation messages.

Now just if they did it..
Last edited by DeathStriker on Wed Dec 28, 2016 2:50 pm, edited 1 time in total.
Reason: Update Thread Post - Revised Quote due to original being edited by Moderator.
Empire HQ X, 30 000+ medals, contrabant addict.
Proud officer of Sith-Society
we have currently 2 open slots,
take your chance to be in same squad as "UCL Tracker" chat family founder
;)
LINE: rrr-firstlorder


User avatar
rRr
Admiral
Posts: 548

Re: Let's fix: the chat lag

Post#20 » Wed Dec 28, 2016 2:50 pm

RebelYell I have additional data for you.

After I have transfered my account to my new phone, chat showed me that I have 480 new messages. However no new message (compared to old device) was present.
Empire HQ X, 30 000+ medals, contrabant addict.
Proud officer of Sith-Society
we have currently 2 open slots,
take your chance to be in same squad as "UCL Tracker" chat family founder
;)
LINE: rrr-firstlorder


Return to “Bugs and Glitches (iOS/Android)”

Who is online

Users browsing this forum: No registered users and 3 guests