View Issue Details

IDCategoryLast Update
0002685Bug Report2020-05-04 01:33
Reporterskrskrskr 
SeveritycrashReproducibilityrandom
Status resolvedResolutionfixed
Summary0002685: Sometimes Out of memory during blurry backgrounds calculation
DescriptionThe game's calculation of blurry and zoomed background calculations is not optimized and memory expensive on higher zoom levels, leading to possible Out-of-Memory situations under certain circumstances (depending on game usage, PC hardware and re-boot state):

-----------------------------------------------------------------
I'm sorry, but an uncaught exception occurred.

While loading <'Blur' <'MatrixColor' <'Crop' <'Rotozoom' <'Image' u'backgrounds/location_pink_day.jpg'> 0 7.0> 5368 2920 1024 768> (1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)> 1.7 None>:
  File "renpy/common/00console.rpy", line 807, in script
    python in _console:
  File "renpy/common/00console.rpy", line 808, in <module>
    console.interact()
  File "renpy/common/00console.rpy", line 343, in interact
    line = ui.interact()
error: Out of memory

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "scripts/locations/map/map.rpyc", line 15, in script call
  File "scripts/locks/home_lock_check.rpyc", line 129, in script call
  File "scripts/locations/home/entrance/hallway/attic/attic.rpyc", line 6, in script call
  File "scripts/locks/01global_lock_check.rpyc", line 67, in script call
  File "scripts/locations/home/entrance/hallway/hallway.rpyc", line 65, in script call
  File "scripts/locks/01global_lock_check.rpyc", line 67, in script call
  File "scripts/locks/01global_lock_check.rpyc", line 67, in script call
  File "scripts/locations/map/map.rpyc", line 15, in script call
  File "scripts/locks/01global_lock_check.rpyc", line 67, in script call
  File "scripts/characters/ivy/button.rpyc", line 59, in script call
  File "renpy/common/00console.rpy", line 807, in script
    python in _console:
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00console.rpy", line 808, in <module>
    console.interact()
  File "renpy/common/00console.rpy", line 343, in interact
    line = ui.interact()
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\ui.py", line 297, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\core.py", line 3194, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\core.py", line 2094, in draw_screen
    renpy.config.screen_height,
  File "renpy/display/render.pyx", line 490, in renpy.display.render.render_screen (gen\renpy.display.render.c:6805)
    rv = render(root, width, height, st, st)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen\renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen\renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen\renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen\renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "accelerator.pyx", line 110, in renpy.display.accelerator.transform_render
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen\renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 583, in render
    return cache.get(self, render=True)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 266, in get
    surf = image.load()
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 1196, in load
    surf = cache.get(self.image)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 266, in get
    surf = image.load()
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 1259, in load
    surf = cache.get(self.image)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 266, in get
    surf = image.load()
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 1007, in load
    return cache.get(self.image).subsurface((self.x, self.y,
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 266, in get
    surf = image.load()
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\im.py", line 965, in load
    rv = renpy.display.pgrender.rotozoom(child, self.angle, self.zoom)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\pgrender.py", line 182, in rotozoom
    return copy_surface_unscaled(surf)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\pgrender.py", line 129, in copy_surface
    rv = surface_unscaled(surf.get_size(), alpha)
  File "Q:\Games\SummertimeSaga-0-19-5-pc\archives\SummertimeSaga-0-19-5-pc - unmodded\renpy\display\pgrender.py", line 118, in surface
    surf = Surface((width + 4, height + 4), 0, sample)
  File "src/pygame_sdl2/surface.pyx", line 164, in pygame_sdl2.surface.Surface.__init__
error: Out of memory

Windows-8-6.2.9200
Ren'Py 7.3.5.606
SummertimeSaga 0.19.5
Fri Apr 17 10:54:32 2020
-----------------------------------------------------------------

This is not always reproducable, but in the console you can force it by increasing zoom levels like in the following statement:

1. Load a save and go to Pink store.
2. Open console and execute:

    scene expression background(840, 472, 7., t=0)

This is what happens if you ask Ivy for a massage and the catalog is being displayed. That statement is already testing the limits because sometimes it already runs out of memory. If it does not, try:

    scene expression background(840, 472, 9., t=0)

You can also see that smaller zoom factors will most likely work:

    scene expression background(840, 472, 4., t=0)

I identified the problem being the fact that in file scripts/core/posing/background.rpy, in function background the calculation is done by first zooming and then cropping the background image, wich will cause an enormously large picture to be produced internally:

    @renpy.pure
    def _background(i, x, y, z):
        if z != 1.:
            i = im.Rotozoom(i, 0, z)
            x = int(max(min(x * z - midx, maxx * z - maxx), 0))
            y = int(max(min(y * z - midy, maxy * z - maxy), 0))
            i = im.Crop(i, (x, y, maxx, maxy))
            i = im.MatrixColor(i, identity)
        i = im.Blur(i, 1.7)
        return i

A better implementation is this:

    @renpy.pure
    def _background(i, x, y, z):
        if z != 1. and z != 0.:
            x = int(max(min(x - midx/z, maxx - maxx/z), 0))
            y = int(max(min(y - midy/z, maxy - maxy/z), 0))
            i = im.Crop(i, (x-z/2, y-z/2, maxx/z+z/2, maxy/z+z/2))
            i = im.Rotozoom(i, 0, z)
            i = im.MatrixColor(i, identity)
        i = im.Blur(i, 1.7)
        return i

Here, the picture is first cropped and zoomed afterwards, producing a significantly smaller image when using larger zoom factors (this is only a quick shot, maybe further improvements are necessary).

The problem also affects other scenes, like when MC first clicks on the kitchen door in Rump's house.
Platform/OSWindows
Version0.19.5

Relationships

related to 0002624 resolved Went into Rump manor and tried to click the kitchen, then received the following crash error 

Activities

Casiope

Casiope

2020-04-17 13:43

updater   ~0004585

Dynamic image blurring has indeed been implemented in the two previous versions; this has also coincided with an increase in "out of memory" reports.

The game developer has analyzed the submitted reports and several changes have been made in the way the engine computes and applies the image transformations. These changes will be effective in the next update.

Thank you for your report, anyway.
Casiope

Casiope

2020-05-04 01:33

updater   ~0004669

The issue has been fixed in version 0.20.0. Please update the game to the last version. The report is now closed.

Issue History

Date Modified Username Field Change
2020-04-17 09:04 skrskrskr New Issue
2020-04-17 13:43 Casiope Note Added: 0004585
2020-04-18 13:14 Casiope Status new => confirmed
2020-04-18 13:16 Casiope Relationship added related to 0002624
2020-05-04 01:33 Casiope Status confirmed => resolved
2020-05-04 01:33 Casiope Resolution open => fixed
2020-05-04 01:33 Casiope Note Added: 0004669