devision by zero at renpy\display\dragdrop.py

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
iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

devision by zero at renpy\display\dragdrop.py

#1 Post by iichan_lolbot »

Hi!

Bug is not stable, sometimes i can't reproduce it at all for some minutes, sometimes i get it just after several clicks.
How to reproduce:
1. unzip and run attached sample code
2. click on "plus" button very fast with a mouse (i was never able to reproduce it with a keyboard)
3. some time after you'll get traceback like this

Traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/start.rpy", line 75, in script
    $ ui.interact()
  File "game/start.rpy", line 75, in <module>
    $ ui.interact()
ZeroDivisionError: float division by zero

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

Full traceback:
  File "game/start.rpy", line 75, in script
    $ ui.interact()
  File "c:\renpy\renpy\ast.py", line 785, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "c:\renpy\renpy\python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/start.rpy", line 75, in <module>
    $ ui.interact()
  File "c:\renpy\renpy\ui.py", line 247, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "c:\renpy\renpy\display\core.py", line 2145, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "c:\renpy\renpy\display\core.py", line 2474, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "c:\renpy\renpy\display\core.py", line 1673, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 363, in renpy.display.render.render_screen (gen\renpy.display.render.c:5330)
  File "render.pyx", line 174, in renpy.display.render.render (gen\renpy.display.render.c:2537)
  File "c:\renpy\renpy\display\layout.py", line 618, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 98, in renpy.display.render.render (gen\renpy.display.render.c:2849)
  File "render.pyx", line 174, in renpy.display.render.render (gen\renpy.display.render.c:2537)
  File "c:\renpy\renpy\display\layout.py", line 618, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 98, in renpy.display.render.render (gen\renpy.display.render.c:2849)
  File "render.pyx", line 174, in renpy.display.render.render (gen\renpy.display.render.c:2537)
  File "c:\renpy\renpy\display\layout.py", line 618, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 98, in renpy.display.render.render (gen\renpy.display.render.c:2849)
  File "render.pyx", line 174, in renpy.display.render.render (gen\renpy.display.render.c:2537)
  File "c:\renpy\renpy\display\layout.py", line 618, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 98, in renpy.display.render.render (gen\renpy.display.render.c:2849)
  File "render.pyx", line 174, in renpy.display.render.render (gen\renpy.display.render.c:2537)
  File "c:\renpy\renpy\display\dragdrop.py", line 405, in render
    done = (at - self.at) / (self.target_at - self.at)
ZeroDivisionError: float division by zero

Windows-post2008Server-6.2.9200
Ren'Py 6.18.2.729
 
Error is inside this code:

Code: Select all

        # Determine if we need to do the snap animation.
        if at >= self.target_at:
            self.x = self.target_x
            self.y = self.target_y
        else:
            done = (at - self.at) / (self.target_at - self.at)
            self.x = absolute(self.x + done * (self.target_x - self.x))
            self.y = absolute(self.y + done * (self.target_y - self.y))
            redraw(self, 0)
I have tried to log some values, and here is what i got at devision-by-zero-moment:
(at, self.at, self.target_at, self.x, self.y, self.target_x, self.target_y) = (0.0, 0.4099998474121094, 0.4099998474121094, 689, 279, 689, 279)
Attachments
renpy_bug.zip
(5.71 KiB) Downloaded 34 times

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#2 Post by Donmai »

Search for 'ZeroDivisionError: float division by zero' and you will find several threads about this problem, like this: http://lemmasoft.renai.us/forums/viewto ... =8&t=15211
Looks like math adventures on Pythonland.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#3 Post by iichan_lolbot »

Donmai wrote:Search for 'ZeroDivisionError: float division by zero' and you will find several threads about this problem, like this: http://lemmasoft.renai.us/forums/viewto ... =8&t=15211
Looks like math adventures on Pythonland.
Have you seen my code?
I know what division by zero is and I know haw to avoid it in my scripts.
But in my case i'm not deviding anything, it's RenPy's renpy.display.dragdrop.Drag class that has a bug in render() function.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: devision by zero at renpy\display\dragdrop.py

#4 Post by PyTom »

I think you might be doing a zero-time snap.
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

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#5 Post by iichan_lolbot »

Well, devision is in snap-related code, but i don't think that i do any explicit snap calls because i learned about snaps only after i got this error, lol.

When you press "plus" actually one of Drag's grandchildren is regenerated and then ui.image is called for DragGroup. Maybe zero-time snap is implicitly called somewhere in this logic.

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#6 Post by iichan_lolbot »

Please, also note the values that i have got: (at, self.at, self.target_at, self.x, self.y, self.target_x, self.target_y) = (0.0, 0.4099998474121094, 0.4099998474121094, 689, 279, 689, 279)

'at' is 0.0, while self.at and self.target_at are bigger and equal.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1960
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#7 Post by Donmai »

iichan_lolbot wrote:I know what division by zero is and I know haw to avoid it in my scripts.
Congratulations. The search I suggested could show you this problem haunts many Python programmers. I know you are a skilled programmer. I only don't know why you are so certain it's a Ren'Py bug. But then I'm not skilled enough to argue, so I'm shutting my mouth. Sorry for bothering you.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: devision by zero at renpy\display\dragdrop.py

#8 Post by iichan_lolbot »

Donmai wrote:I only don't know why you are so certain it's a Ren'Py bug.
Because it is a devision error that happens in snap-related code deep-deep inside ui.interact(), while my code contained no devisions and no implicit snaps.
Also this bug is not easy to reproduce even with exactly the same conditions, which also indicates that roots must be somewhere deep underneath ui.*, not in high-level code.
Donmai wrote:Sorry for bothering you.
Sorry if my message looked offensive. English is not my native language, so i might have said something very wrong..

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: devision by zero at renpy\display\dragdrop.py

#9 Post by PyTom »

I'm tracking this as a Ren'Py bug, anyway.
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]