Skip to content

Conversation

brad-richardson
Copy link
Contributor

@brad-richardson brad-richardson commented Jan 2, 2023

Description

Continuation of #658 to show new app art on edit, tested working on Moonlight QT/iOS.

Screenshot

IMG_628909436696-1
Note that the scaling is wrong for this image on iOS, I'll make a separate change in the moonlight client to fix.

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@brad-richardson
Copy link
Contributor Author

@cgutman Any ideas about why app list refreshes don't seem to load properly on the qt client?

Also, thoughts on the off by ones I've removed here? I had a couple minor issues around current game state after the changes but I haven't been able to consistently reproduce

@brad-richardson
Copy link
Contributor Author

The commit should fix the iOS scaling issue: brad-richardson/moonlight-ios@33b0307 It's taking a while to install xcode/configure my env so haven't tested it yet.

// Add a property named "id" to the inputTree with a value of the current timestamp
// Time is in seconds because some Moonlight clients cannot accept more than a 32-bit integer
// Milliseconds would be a better option
time_t id = time(nullptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_t is 64-bit on modern systems to avoid the Y2038 issue. We should cast it to make sure it's actually 32-bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my bad... I knew it would just be safe until 2038... but that would also assume the user has their clock set correctly.

I would really like to use milliseconds instead of seconds anyway, in the event someone is saving multiple apps with the upcoming API. The code I removed here got the value in milliseconds if we want to go back to that. https://github.com/LizardByte/Sunshine/compare/7ebe09223c41b16cb8feb421e64f0902e0a91353..21660ea083e217075102ce0bc9130c69bd358983

Using milliseconds probably over complicates this all though... so maybe stick with the time_t and have some logic to ensure that the id isn't already used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to just be a random number given the upcoming API. I didn't add any guard logic here because it seems unnecessary. Let me know what you think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to just be a random number given the upcoming API. I didn't add any guard logic here because it seems unnecessary. Let me know what you think

My fear with using a random number is it's possible for them to repeat. I've seen cases where random functions are not really very random at all.

Here's a potential idea. Use an incrementing counter and store the counter as a separate property in the apps.json. Then just use that value and add 1 to it when assigning a new id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the small chance of collision with this generator vs potential bugs with something like a user-writable counter in a threaded context I would probably lean towards the former?

I could switch to a more precise timestamp with some truncation/casting but this felt a little safer to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about random then, but check if the id is already used? I feel if we allow it to duplicate, it definitely will happen. I'm used to the SQL auto incrementing style that eliminates the chance of duplication.

@cgutman
Copy link
Collaborator

cgutman commented Jan 2, 2023

Any ideas about why app list refreshes don't seem to load properly on the qt client?

Are you relaunching the client? That should reliably update it (and it should poll the app list every 30 seconds after that).

Also, thoughts on the off by ones I've removed here? I had a couple minor issues around current game state after the changes but I haven't been able to consistently reproduce

I think those were to avoid using app ID 0.

@ReenigneArcher
Copy link
Member

Can you also replace the ./src_assets/common/assets/box.png with this image? https://discord.com/channels/804382334370578482/1055290596304105572/1059455062243541082

@brad-richardson
Copy link
Contributor Author

Are you relaunching the client? That should reliably update it (and it should poll the app list every 30 seconds after that).

Yes, I'm noticing the app list on the mac client doesn't seem to refresh at all (even when I add a new app). I'll keep digging, I may have just put it in a bad state

@brad-richardson
Copy link
Contributor Author

I fixed the issue on the qt client, an ID above max signed 32-bit int was failing to parse. This PR should be ready now

@brad-richardson brad-richardson marked this pull request as ready for review January 2, 2023 20:34
ReenigneArcher and others added 9 commits January 2, 2023 18:20
When an application is saved, the current timestamp in milliseconds is added to as the application id. A timestamp was used instead of a random integer to prevent any chance of repeated values.
@ReenigneArcher ReenigneArcher merged commit 052297a into LizardByte:nightly Jan 3, 2023
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

Successfully merging this pull request may close these issues.

3 participants