Lag when using image heavy screens?

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
Heiden
Regular
Posts: 120
Joined: Sat May 11, 2013 3:20 pm
Completed: Elvine, The Life Threads, Helena's Flowers, Dr. Frank's Build-A-Boyfriend, Beyond the Deep, The Bog's Heart, The Girl With the Gray Hair Awakens
Projects: The Far Rings, NB107A
Tumblr: heidengames
itch: Heiden
Contact:

Lag when using image heavy screens?

#1 Post by Heiden » Thu Oct 05, 2017 8:24 pm

Hello~!

I've run into a problem where my game will slow down pretty significantly when I'm using screens with 5 or 6 different items you can click on.

I've made a point and click game based on screens where you click on imagebuttons to send you to different labels.

I've been looking through previous thread posts looking to see if anyone else has run into this issue (I found a few) and if anyone was able to find a solution for this.
I've tried increasing image cache size as well as forcing Renpy to dump its memory cache every so often, but neither have worked. Also using shift + d and forcing the game into Direct X also doesn't help the lag.

I'm using Renpy 6.99.

(And I'm sorry I don't have much experience with programming (never the less programming dealing with performance issues) so I don't really know... how to approach this.)
Completed: Elvine (GxB), The Life Threads, Helena's Flowers (GxG)(As Writer, Coder), Dr. Frank's Build-A-Boyfriend (BxB), Beyond the Deep (GxB)(As Artist), The Bog's Heart, The Girl with the Gray Hair Awakens

(I ran out of URLs I can have in my sig haha, you can find all the games listed on my itch.io page!!)

User avatar
Remix
Eileen-Class Veteran
Posts: 1307
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: Lag when using image heavy screens?

#2 Post by Remix » Fri Oct 06, 2017 9:55 pm

The functions you likely want to look at are:

Code: Select all

renpy.exports.get_image_load_log(age=None):
    """
    :doc: other

    A generator that yields a log of image loading activity. For the last 100
    image loads, this returns:

    * The time the image was loaded (in seconds since the epoch).
    * The filename of the image that was loaded.
    * A boolean that is true if the image was preloaded, and false if the
      game stalled to load it.

    The entries are ordered from newest to oldest.

    `age`
        If not None, only images that have been loaded in the past `age`
        seconds are included.

    The image load log is only kept if config.developer = True.
    """
# As a generator, you should be calling:
for i in renpy.exports.get_image_load_log():
    renpy.say("", "[i]") 
# or somesuch after the screen shows

# a line or two before call/show screen... use above to test result
renpy.start_predict_screen( "your screen name in quotes" )

# just after (or during is better)
if renpy.has_screen( "your screen name in quotes" ):
    renpy.stop_predict_screen( "your screen name in quotes" )

# and possibly... before
renpy.exports.start_predict( list of the images used in the screen )
# after
renpy.exports.stop_predict( list of the images used in the screen )
Mad Scientist Todo List:
  • Finish Improved Event Handler
  • Implement DragonBones animation as a Creator Defined Container
  • Develop Cartoon Speech Bubble dialogue
  • Finish Bitmask collision and rebound vector system
  • Develop time based building mechanic
  • Others
  • *Find a superb artist and actually write a game*

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

Re: Lag when using image heavy screens?

#3 Post by Imperf3kt » Sat Oct 07, 2017 4:13 am

According to the documentation, screens without () are slower than screens with ()
For best performance, all screens should be defined with a parameter list. When a screen doesn't take parameters, it should be define with an empty parameter list. The screen:

Code: Select all

screen test():
    vbox:
        for i in range(10):
            text "[i]"
is faster than:

Code: Select all

screen test:
    vbox:
        for i in range(10):
            text "[i]"
When a screen is defined without a parameter list, any name used in that screen can be redefined when the screen is show. This requires Ren'Py to be more conservative when analyzing the screen, which can limit the optimization it performs.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Todo list:
Actually finish a project

Post Reply

Who is online

Users browsing this forum: BigBucket, Google [Bot], nautilus_nc