Skip to content

sdlgfx behaviour showing noise (reads wrong memory) on newer macs #282

@JASlotman

Description

@JASlotman

What doesn't work?
We made a small engine that we use for students, so we can test many different architectures. We stumbled upon a bug where when we use the drawcricle and other shapes from the gfx library and update a surface or window it draws a noisy reactangles around the shapes we want to display.

How To Reproduce
Any code that reproduces the bug, e.g.:

Sorry I dont have a minimal code that creates this bug here are three minimal tidbits of our code that give the problem

def update(self,name):
        window = self.windowlist.get(name)
        SDL_ShowWindow(window)
        ren = SDL_GetRenderer(window)
        SDL_RenderPresent(ren)

def clear(self,name):
        ren = SDL_GetRenderer(self.windowlist.get(name))
        SDL_SetRenderDrawColor(ren, 0, 0, 0, 255)
        SDL_RenderClear(ren)


def drawCircle(self,x,y,r,color,filled):
        if filled:
            filledCircleColor(self.renderer,int(x),int(self.ySize-y),int(r),color)
        else:
            aacircleColor(self.renderer,int(x),int(self.ySize-y),int(r),color)

#psuedocode intended to draw a line that causes problems but works on all other architectures (linux, windows, old macs) but not on new macs adding a clear solves this but it will clear the screen in between updates which is not intended behavior (i.e. does not draw a line but shows a moving circle)

while running:
      x += 1
      y += 1
      drawCircle(x,y,r,col,True)
      update()

Platform (if relevant):

  • OS: [Mac, newer machines]
  • Python Version: [>3.9]
  • SDL2 Version: [0.9.16 / 2.30.10]
  • Using pysdl2-dll: [Yes]

Additional context
Only drawing a single element also causes this unless we first do a clear. When a student that was working on an other project used and saw that the rectangles were not filled with random noise but with an image that he loaded into memory for another project, which makes us beleive sdl2 might be accessing a wrong memory area in these newer macs. (my guess is these are the M1 or higher machines)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions