Author Topic: Cheats, lag, caching  (Read 2037 times)

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Cheats, lag, caching
« on: January 05, 2013, 07:43:51 PM »
Seeing more discussion in the shoutbox about cheat lags.  Somehow my cheats menu doesn't refresh when I expect it to.  E.g. reset to default user preferences, then pick a game, go to Play, and no cheats show up.  Next time I restart the app the cheats are built properly. I have a few questions:

- When to refresh the cheats menu - Currently I think this is done when the user presses the Play menu.  But I'm wondering if it might be more logical to refresh after the user changes to a different ROM.

- Caching - Is there anything we can persist between sessions that would speed it up?  I'm thinking, user changes ROMS, the menu system refreshes itself (possibly with a toast or progress bar) then persists whatever it needs to reconstruct the cheats menu.  Next time user starts the app, if they don't change ROMS, there's nothing to wait for.

I may be missing the point entirely, not sure exactly what's going on in the cheats menu and have hardly looked at that part of the code other than where it ties into MenuActivity.java.  Thoughts?
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Cheats, lag, caching
« Reply #1 on: January 05, 2013, 07:54:14 PM »
I think if we persist the header name on change of the selecte game, that would speed things up considerably.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Cheats, lag, caching
« Reply #2 on: January 05, 2013, 08:17:42 PM »
Persisting should be easy.  After the header name is computed, just stuff it into a new field in AppData, like I do with last slot value or asset version number.  Just follow the same pattern.

I would suggest handling the refresh in MenuActivity.onSharedPreferenceChanged(...) rather than MenuActivity.onPreferenceClick(...).  Test for key == "pathSelectedGame".   Then just set a persistent flag in AppData and restart the entire activity, like I do when the video plugin or touchpad enabled changes.  Then in MenuActivity.onCreate(...), that's where you do the actual header calculation, and persist the name to AppData.  I use a similar pattern for rebuilding the video settings screen whenever the plugin changes.

Edit: sorry for the overload...
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Cheats, lag, caching
« Reply #3 on: January 06, 2013, 12:30:15 AM »
That sounds like what is needed per-session, but storing in AppData would only be good until the app was restarted.. or more to the point, it would require re-reading the header first thing every time the app starts, which I'd like to avoid.  I think the header name will need to be saved along with the app preferences somehow.  Before I would have stuck the value into the config file, but that doesn't follow the new pattern.  Any thoughts on this?  I suppose it might be possible to make a hidden preference to store the string, that never actually gets displayed in the menus.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Cheats, lag, caching
« Reply #4 on: January 06, 2013, 12:34:52 AM »
Actually appdata does persist some data across sessions. Namely current slot and asset version code.  Readthe javadoc header, this is exactly a hidden preference.
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3494
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Cheats, lag, caching
« Reply #5 on: January 06, 2013, 12:45:10 AM »
Great, will do.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted