Android - "I/O operation on closed file" when saving game

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
User avatar
Eliont
Regular
Posts: 110
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Android - "I/O operation on closed file" when saving game

#1 Post by Eliont » Mon Jul 06, 2020 5:01 am

Hello and good time of day.

Why this is happening ?
There are no problems with saves on PC or launcher-emulated android, but crashed when installed on real android 7 (Nox App Player or android tablet).

Storage permission granted.
Image

Code: Select all

While running game code:
  File "renpy/common/00action_file.rpy", line 372, in __call__
ValueError: I/O operation on closed file. (perhaps store.file = <_io.BytesIO object at 0x707d3cef50>)
Additional info: we using saving metadata via json callback:

Code: Select all

def json_callback(d):
        d["time"] = time_now()
        d["date"] = date.to_string()

config.save_json_callbacks.append(json_callback)
Can it be an issue? How to fix it?

Thanks in advance.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Android - "I/O operation on closed file" when saving game

#2 Post by PyTom » Sat Jul 11, 2020 2:00 pm

I can't think of anything. Is there a longer traceback?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Eliont
Regular
Posts: 110
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Android - "I/O operation on closed file" when saving game

#3 Post by Eliont » Sat Jul 11, 2020 7:59 pm

PyTom wrote:
Sat Jul 11, 2020 2:00 pm
I can't think of anything.
Solved now - it's because i used

Code: Select all

        RandomNames = {}
    
        with renpy.file("db/RandomNames/RusNames.txt") as file:
            RandomNames['rus'] = random_names_file.readlines()
        with renpy.file("db/RandomNames/EngNames.txt") as file:
            RandomNames['eng'] = random_names_file.readlines()
Fixed by replacing this code with:

Code: Select all

        RandomNames = {}
    
        with renpy.file("db/RandomNames/RusNames.txt") as random_names_file:
            RandomNames['rus'] = random_names_file.readlines()
        with renpy.file("db/RandomNames/EngNames.txt") as random_names_file:
            RandomNames['female_eng'] = random_names_file.readlines()
            
        del random_names_file    
            
I dont know though why first variant still works on desktops but fails on android.

Post Reply

Who is online

Users browsing this forum: No registered users