moonlight-stream / moonlight-android

GameStream client for Android
GNU General Public License v3.0
3.16k stars 503 forks source link

Latency message after streaming now reports with decimal point #1314

Open kentyman23 opened 4 months ago

kentyman23 commented 4 months ago

The Show latency message after streaming toast previously reported truncated integers because integer division was used to calculate them (5.99 would be reported as 5). This led to inaccuracies reported here: https://docs.google.com/spreadsheets/d/1WSyOIq9Mn7uTd94PC_LXcFlUi9ceZHhRgk-Yld9rLKc/

Since we're using floating-point arithmetic, we no longer have to avoid divide-by-zero errors. Corner cases one might see are "∞ ms" (positive time divided by 0 frames) or "NaN ms" (0 time divided by 0 frames). I felt these were perfectly fine to output in these theoretical, degenerate cases. Because of this, I was able to simplify the logic in Game.onStop to no longer check for 0s. This simpler logic means we don't need both conn_client_latency_hw and conn_hardware_latency localized strings; I opted to remove the former and keep the latter and put a newline between them, as it was hard to quickly read both stats when the visual location of the values depended upon how the wrapping worked out. This is how it looks:

image

(Note that PR #1313 was abandoned after I realized I pushed to my fork's master instead of a branch.)