[SOLVED] Android - loading a save file does not always work

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Bren
Newbie
Posts: 18
Joined: Mon Aug 24, 2020 5:34 am
Contact:

[SOLVED] Android - loading a save file does not always work

#1 Post by Bren »

Hi guys,

I just encountered a new yet very unexpected issue with Android!

In a nutshell, I asked my code to save the game everytime a new dialogue is displayed - no autosave, no quicksave, only one save file called "1-1" (i.e. appears on first page & first slot of the save menu). And on the launch screen, I only have a "Start" button that checks the existence of the save file "1-1" and loads it (if it doesn't exist, it starts a new game).

When I test the game on Bluestack / Renpy, no problem => the "Start" button on launch screen does launch the save file "1-1" and I start exactly where I left the game ==> all good
But when I test the game on my Android device (with SD card), I sometimes encounter a weird issue when I start the app:
  1. 50% of times, the game directly loads the latest (and theoretically only) save file "1-1" without showing the launch screen - the screen just says "auto-reloading" and then directly displays the loaded file (a bit weird, but at least I start exactly where I left the game)
  2. The other 50% of times, the game properly start and I get to the launch screen (no direct loading of saved file); but when I click on "Start" button, the save file it loads is not the latest one=> it's an "old" "1-1" file that does not get me exactly where I left the game
So when I'm unlucky, I can get 3 times in a row the "old" "1-1" file when I start the app, i.e. the game would just not save the latest progression and just send me back to an old save => this doesn't make sense to me as there is supposedly only one save file called "1-1" that is replaced everytime I display a new dialogue...

My only guess would be that there are actually two different "1-1" files somehow, one on the device and one on the SD card:
  • The "proper" latest one would take me to case 1. (game automatically loads the latest file, no launch screen)
  • The "old" file would take me to case 2. (game shows launch screen, but I only get access to a weird old "1-1" file)
Just FYI, I have disactivated all automatic saves, including the ones from Android (in script.rpy):

Code: Select all

define config.save_on_mobile_background = False
define config.has_quicksave = False
define config.has_autosave = False
define config.autosave_on_choice = False
define config.autosave_on_quit = False
define config.autoreload = False
Has anyone encountered the same issue? Any advice would be a massive help, I'm completely stuck on this!

Many thanks!
Last edited by Bren on Thu Jul 08, 2021 7:28 am, edited 2 times in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3796
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Android - loading a save file does not always work

#2 Post by Imperf3kt »

Have you tried setting quit_on_mobile_background True?
https://www.renpy.org/doc/html/config.h ... background

This will force the game to fully restart each time you close it and relaunch it, so you won't see the soft launch (auto-restarting), which should force the game to go to the main menu, triggering your load.


Just something to think about though, saving in every line of dialogue is not a good habit as you're hammering I/O, which will wear the users device out fast as well as slow your game down.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Bren
Newbie
Posts: 18
Joined: Mon Aug 24, 2020 5:34 am
Contact:

Re: Android - loading a save file does not always work

#3 Post by Bren »

Hi Imperf3kt, thanks for your help! Will definitely try this tonight - hopefully the hard launch will make the game load the latest "1-1" save file (and not some old version that somehow exists).

About your side note, I understand your point - what would be the best practice here to make sure there's only one save file always up-to-date?

User avatar
Lochana
Newbie
Posts: 21
Joined: Fri Jul 28, 2017 6:26 am
Projects: Touhou - Reimu's day out! (Won't see the light of day probably)
Github: lochana-Dineko
Contact:

Re: Android - loading a save file does not always work

#4 Post by Lochana »

Why not have the game save at sections instead of every line. Auto saving at every line is way too excessive.

Bren
Newbie
Posts: 18
Joined: Mon Aug 24, 2020 5:34 am
Contact:

Re: Android - loading a save file does not always work

#5 Post by Bren »

Hi guys,

Thank you so much for all your help - tried Imperf3kt's solution, it works perfectly (I don't have any "soft launch", and the app properly loads the latest save file).
Here is the final code FYI:

Code: Select all

define config.save_on_mobile_background = False
define config.quit_on_mobile_background = True
define config.has_quicksave = False
define config.has_autosave = False
define config.autosave_on_choice = False
define config.autosave_on_quit = False
define config.autoreload = False

Regarding the saving frequency, I will try to set up frequent checkpoints as you guys suggested to make things smoother.

Thanks so much!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]