(Solved) "Refusing to open (file) while predicting" Error

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
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

(Solved) "Refusing to open (file) while predicting" Error

#1 Post by SypherZent »

I booted an old client's game. It should be fully functional.

However, I am getting an error that it's refusing to predict an image file which is clearly present in the game's files.

I did a Ren'Py update to latest version. Game was developed on a previous version of Ren'Py.
Still, I have other games developed on previous versions of Ren'Py and this doesn't happen to those.

Any help would be appreciated, thanks.

Edit to add: The file in question opens fine for me. I also opened it in GIMP, re-saved it, moved the file's directory, etc. Nothing worked; the error persists.
Last edited by SypherZent on Wed May 20, 2020 2:27 am, edited 1 time in total.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: "Refusing to open (file) while predicting" Error

#2 Post by rayminator »

what error are you getting?
Have you update the codes that you using for the previous version of Ren'Py?
some codes from the previous version might not work anymore
when that error shows up there should be a button there that say copy bbcode click it and past it here
code lines of code that might be causing that couple line up and down

User avatar
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

Re: "Refusing to open (file) while predicting" Error

#3 Post by SypherZent »

I posted the error in the title of the post.

"Refusing to open (file) while predicting."

The code is not from my game. It's from Ren'Py's loader.py.

Code: Select all


def load(name, tl=True):

    if renpy.display.predict.predicting: # @UndefinedVariable
        if threading.current_thread().name == "MainThread":
            if not (renpy.emscripten or os.environ.get('RENPY_SIMULATE_DOWNLOAD', False)):
                raise Exception("Refusing to open {} while predicting.".format(name))

    if renpy.config.reject_backslash and "\\" in name:
        raise Exception("Backslash in filename, use '/' instead: %r" % name)

    name = re.sub(r'/+', '/', name).lstrip('/')

    for p in get_prefixes(tl):
        rv = load_core(p + name)
        if rv is not None:
            return rv

    raise IOError("Couldn't find file '%s'." % name)

Source: https://github.com/renpy/renpy/blob/561 ... /loader.py

The code from my game is a frame's background. The most basic thing. It should be working.

Code: Select all

screen Order(this_order):
    zorder 10

    frame:
        background "ui/order_balloon.png"
The error says "Refusing to open "ui/order_balloon.png" while predicting.

As I said, I can open the file myself. I opened it in GIMP and re-saved it. I moved it from images directory to images/ui directory.
Nothing works.

This isn't a problem with my code. I turned this project in months ago for client, and it runs fine for them.

Seems to be a problem with the engine.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: "Refusing to open (file) while predicting" Error

#4 Post by Remix »

So, does it work if you point the frame background at a different image?
Frameworks & Scriptlets:

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: "Refusing to open (file) while predicting" Error

#5 Post by rayminator »

have tried recreating the problem If I take out this_order it works fine but if it's inside() it doesn't work only way I can recreate it need the code for this_order

Code: Select all

screen Order(this_order):
    zorder 10

    frame:
        background "ui/order_balloon.png"

User avatar
SypherZent
Veteran
Posts: 362
Joined: Fri Sep 02, 2016 3:14 am
Completed: Multiverse Heroes, Space Hamster in Turmoil
Location: Puerto Rico
Contact:

Re: "Refusing to open (file) while predicting" Error

#6 Post by SypherZent »

I found the problem.

Sorry, rayminator. I didn't provide the next line of my code because I only posted up to the line reported by Ren'Py.

The problem was on the following line. The xysize of the screen.

I have three screens. Order1, Order2, Order3. They are coded the same, except slight differences, to be used by different sprites without conflict.

Code: Select all

screen Order(this_order):
    zorder 10

    frame:
        background "ui/order_balloon.png"
        xysize renpy.image_size("ui/order_balloon.png")
I got lazy with this code, instead of storing the size in a SETUP dictionary (as I normally do), I used renpy.image_size function to retrieve it.
The error doesn't happen with screen Order1. It happens with screen Order2.

I presume, during the loader.py running preloading (at game launch, because the game wouldn't even boot with this error), it probably ran renpy.image_size and everything fine for screen Order1. When it reached Order2, it seems to have 'gotten confused' for lack of a better way to explain it, causing the image prediction error to be thrown. No idea why.

In any case, I'm glad I was able to figure this out and I hope the feedback helps the engine to be improved for future updates.

Thanks to rayminator and Remix for commenting. Remix, your comment triggered me to try a different image and when the crash reported the previous image instead of the new one, that's when I figured out that it was reporting the wrong line in the error report. Learning that prompted me to verify the xysize line. So, I really appreciate your input, thanks.

Post Reply

Who is online

Users browsing this forum: Google [Bot]