[Closed] Graphic glitches since updating to 8.1

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
goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

[Closed] Graphic glitches since updating to 8.1

#1 Post by goldo »

Sorry for the double post, I think I put this question in the wrong part of the forum. Anyway, trying my luck in the 'Questions' thread.

I have updated Ren'py to 8.1.1 (from 8.0.1 previously) and I have run into graphical glitches that didn't use to happen before in my game, not changing any of the code.

First, when opening or reloading the game, sometimes all buttons on screen have a black mark where the text should be. Hovering with the mouse over the buttons removes the black marks, and they don't come back until a later restart/reload (I doesn't happen on every restart/reload either, it's pretty random).

Image

Going to the console, I see a bunch of new 'Leaking texture' messages show up, which I assume are related:
Image

Second and maybe related issue: I use a version of the ProportionalScale class to resize pictures at init to the game's resolution, which are then used as backgrounds. After updating to 8.1.1, the first background picture displayed after starting the game (summoned with 'show') is not actually resized to the current resolution, but all other pictures shown afterwards seem to resize normally. While the first background picture does not show at the right size, going full screen then back to window mode solves the problem and the picture is then shown proportionally.

I never had these glitches before so I don't really know where to start to fix them. It never happened previously in 8.0.1 (in fact I have it still installed, and going back to that version everything works fine).

The game UI uses an edited version of a legacy theme (crayon), if that means anything.

Thank you for your insights.
Last edited by goldo on Fri Mar 08, 2024 10:17 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Graphic glitches since updating to 8.1

#2 Post by PyTom »

That class is using undocumented internal functions, and so it's possible something has changed to make it stop working. I'd suggest not using it.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Graphic glitches since updating to 8.1

#3 Post by goldo »

Thank you. For the record, I have updated to 8.1.2 and will report if the glitches are still there.

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Graphic glitches since updating to 8.1

#4 Post by goldo »

Just to report that I have the same glitches with 8.1.2.

I guess I understand ProportionalScale() might be out of order, but unless I'm mistaken that doesn't explain the behavior of plain textbuttons turning black (which do not use the ProportionalScale class).

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Graphic glitches since updating to 8.1

#5 Post by PyTom »

Does it happen in games without ProportionalScale? Once the internal state is corrupted, anything can go.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Graphic glitches since updating to 8.1

#6 Post by goldo »

Unfortunately, I don't have other complex games available to compare.

For the record, here is the full code for the ProportionalScale class I am using. If anyone knows a fix, I would welcome it.

Code: Select all

class ProportionalScale(im.ImageBase):
        '''Resizes a renpy image to fit into the specified width and height.
        The aspect ratio of the image will be conserved.'''
        def __init__(self, imgname, maxwidth=None, maxheight=None, bilinear=True, **properties):
            img = im.image(imgname)
            super(ProportionalScale, self).__init__(img, maxwidth, maxheight, bilinear, **properties)
            self.imgname = imgname # Stores relative path from the 'game/' folder
            self.image = img
            if maxwidth: # Set maxwidth as None to ignore
                self.maxwidth = int(maxwidth)
            else:
                self.maxwidth = config.screen_width
            if maxheight: # Set maxheight as None to ignore
                self.maxheight = int(maxheight)
            else:
                self.maxheight = config.screen_height
            self.bilinear = bilinear

        def load(self):
            #<Chris12 NotFound>
            # Loads a neutral image instead of failing, in case an image does not exist
            try :
                child = im.cache.get(self.image)
            except IOError :
                # renpy.notify("Missing: " + self.imgname) # Commented out because it causes bugs in the CG gallery. Requires investigation
                child = im.cache.get(Image("backgrounds/not_found.webp"))
            #</Chris12 NotFound>

            width, height = child.get_size()

            ratio = min(self.maxwidth/float(width), self.maxheight/float(height))
            width = ratio * width
            height = ratio * height

            if self.bilinear:
                try:
                    renpy.display.render.blit_lock.acquire()
                    rv = renpy.display.scale.smoothscale(child, (width, height))
                finally:
                    renpy.display.render.blit_lock.release()
            else:
                try:
                    renpy.display.render.blit_lock.acquire()
                    rv = renpy.display.pgrender.transform_scale(child, (newwidth, newheight))
                finally:
                    renpy.display.render.blit_lock.release()
            return rv

        def predict_files(self):
            return self.image.predict_files()
Thank you!

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Graphic glitches since updating to 8.1

#7 Post by goldo »

Sorry to necro this thread, but I finally found the culprit, it's this function:

Code: Select all

#<PredictImages>
    # Threading is necessary, because otherwise the screen only shows AFTER ALL images have been loaded.
    # That would actually make things slower. With threading, the images load in the background as intended.
    def predict_images(girls, predict_portraits = True, predict_profiles = True):
        def predict_images_helper():
            try:
                # Predict all portraits first since they are needed immediately.
                for girl in girls:
                    if predict_portraits and girl.portrait is not None : renpy.predict(girl.portrait.get(side=True))

                # After that, begin loading the profile images
                for girl in girls:
                    if predict_profiles and girl.profile is not None : renpy.predict(girl.profile.get(profile=True))
            except: pass
        if girls is not None and len(girls) > 0:
            t = threading.Thread(target=predict_images_helper)
            t.daemon = True
            t.start()
I didn't write it, so I'm not sure what's wrong with it. This is called on the 'Home' screen to predict a gallery of portraits and profile pictures.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Graphic glitches since updating to 8.1

#8 Post by PyTom »

This is simply bad - with very few exceptions, Ren'Py functions can't be called outside of the main thread. (IIRC, renpy.queue_event is the only one, and you can also update data in the store.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

goldo
Regular
Posts: 127
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Graphic glitches since updating to 8.1

#9 Post by goldo »

Thanks, I have removed it from my game and will let the creator know if I can get a hold of him.

Post Reply

Who is online

Users browsing this forum: Alex, Bing [Bot], Majestic-12 [Bot], NoFanru