On Sat, Apr 19, 2008 at 10:54 PM, Txema Vicente <[EMAIL PROTECTED]> wrote:
>
>
>
> > Nothing's "not allowed". As Nathan pointed out, the Text behaviour is
> > a little different. I'd suggest commenting out large sections of your
> > code to try to isolate what pyglet features are causing trouble.
>
> I have done that, removed almost all, but no clue.
>
> So I decided to start testing from scratch.
>
> Following code breaks all my windows desktops.
> Not inmidiately, but in a minute it does. Try to move and resize.
>
> Even if you skip the graph, it ends breaking.
>
> #------------------------------------
> FPS=None
> #FPS=60.0
>
> import pyglet
> from pyglet.gl import *
>
> dat=[]
> win = pyglet.window.Window(resizable=True)
> fps = pyglet.text.Label('XX',font_size=24, x=0, y=0)
>
> def graph():
> x=0
> glBegin(GL_LINES)
> for y in dat:
> glVertex3f(x,32,0)
> glVertex3f(x,32+y*1000,0)
> x+=1
> glEnd()
>
> def frame(dt):
> dat.remove(dat[0])
> dat.append(dt)
> if dt==0:fps.text="--"
> else: fps.text=str(int(1./dt))
>
> @win.event
> def on_draw():
> win.clear()
> graph() #You can skip this, too.
> fps.draw()
>
> def start(dt=None):
> for i in range(0,256): dat.append(0)
> number=(type(dt)==type(0.0)) or (type(dt)==type(0))
> if number: pyglet.clock.schedule_interval(frame, 1.0/float(dt))
> else: pyglet.clock.schedule(frame)
> pyglet.app.run()
>
> start(FPS)
> #------------------------------------
>
>
>
> > I'm surprised you're getting the same artifacts with two different
> > devices, as I've not seen anything like that before.
>
>
> I was very surprised too, and I`m even ashamed not getting the new piggy
> working.
>
> Am I the only one getting this things with 1.1 on win32:
>
>
>
> Please, people, test this code and tell me if it works for you.
>
Thanks for the test case, it behaved exactly as you describe on my
machine. It turns out there are two issues:
1. The font object is being continually recreated each time the layout
text is reset. There is a font cache, but as of pyglet 1.1 the cache
uses weak references to avoid leaks on programs that change fonts and
don't reuse them. The cache was still effective until a few weeks ago
as there was a circular reference holding the font references away
from the collector until a full collection was done; which is
relatively rare and unlikely to coincide with the short amount of time
that the layout drops the font reference.
I've put in a temporary fix (r2030) which is to hold onto references
of the last three created fonts. This is obviously a hack, but it
will completely resolve this issue. A better solution would be to
have the AbstractDocument classes hold onto fonts that are in use, and
release them if a text or style change causes the font to be unused.
This is reasonably simple for UnformattedDocument, but quite tricky
(and potentially expensive) for FormattedDocument.
I may just revert the font cache to not use weak references for pyglet
1.1, as it seems that use-case (using and discarding fonts) is going
to be a lot smaller than this one (replacing or recreating documents
with the same font, or using IncrementalTextLayout).
2. There is also a memory leak in the win32 font code, which I haven't
looked for yet. If anyone wants to dive in, most welcome :-)
Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---