Closed Bug 95711 Opened 24 years ago Closed 10 years ago

free font when no longer in use

Categories

(Core :: Internationalization, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bstell, Assigned: jshin1987)

References

Details

(Keywords: intl)

Attachments

(1 file, 6 obsolete files)

Fonts that are loaded are not released even when they are no longer in use. We need to ref count the fonts and release them when the count goes to zero.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.5
Keywords: intl
attachment 49313 [details] [diff] [review] frees the x/gdk font when not in use. The node/nsFontGTK is otherwise not affected. Katakai/Roland: could you look at this and see if it makes sense. thanks
Two issues: 1. Is it guranteed that the font isn't freed while the GC-cache (GTK+/Xlib/Xprint use GC caches) still has a GC cache entry which uses this font ? 2. Do you file a port to Xlib gfx or should I do that ?
Roland: could you give me a pointer to where the GC cache accesses a font? I'm not setup to test the Xlib code path. Would you mind creating a Xlib patch and attaching it to this bug?
> Roland: could you give me a pointer to where the GC cache accesses a font? See http://lxr.mozilla.org/seamonkey/source/gfx/src/xlib/nsGCCache.cpp and http://lxr.mozilla.org/seamonkey/source/gfx/src/xlib/nsGCCache.h The UpdateGC() method (http://lxr.mozilla.org/seamonkey/source/gfx/src/xlib/nsRenderingContextXlib.cpp#480) is responsible to get a matching GC entry for that font... (GTK+ gfx code does the same except that it plays around with the silly GDK/GTK+ wrappers). > I'm not setup to test the Xlib code path. Would you mind creating a Xlib > patch and attaching it to this bug? No problem... "Now" or can I wait until the GTK+ version has been r='ed (and you're then r='ing the Xlib version... :-) ?
Roland: I would recommend waiting until we think the gtk version is stable but then proceed before the r= is done.
We probably need to increment/decrement the counters when a font is put-in / removed-from a gc.
bstell wrote: > Roland: I would recommend waiting until we think the gtk version is stable > but then proceed before the r= is done. OK! ---- bstell wrote: > We probably need to increment/decrement the counters when a font is > put-in / removed-from a gc. I am not sure... if I remember correctly there is one GC-cache per |Drawable|. If all objects which keep refs to the GC-cache are destroyed (which means that the GC-cache will finally destroy itself) before the fonts get disposed then we're safe... otherwise we need a way to track the use of fonts by the GC-cache.
Target Milestone: mozilla0.9.5 → mozilla0.9.6
QA Contact: andreasb → ylong
We will need to add the "font" (nsXFont) to this so we can addref on insert and decref on remove. http://lxr.mozilla.org/seamonkey/source/gfx/src/xlib/nsGCCache.h#92 92 struct GCCacheEntryXlib 93 { 94 PRCList clist; 95 unsigned long flags; 96 XGCValues gcv; 97 Region clipRegion; 98 xGC *gc; 99 };
Depends on: 90813
Comment on attachment 56317 [details] [diff] [review] the full diff (includes the changes from the ~4500 lines of bug 90813 attachment 55932 [details] [diff] [review]) patch does not like attachement 56317
Attachment #56317 - Attachment is obsolete: true
Comment on attachment 56317 [details] [diff] [review] the full diff (includes the changes from the ~4500 lines of bug 90813 attachment 55932 [details] [diff] [review]) humm. now attachment 56317 [details] [diff] [review] works
Attachment #56317 - Attachment is obsolete: false
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Attachment #56317 - Attachment is obsolete: true
Attachment #49313 - Attachment is obsolete: true
-> 0.9.8
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Target Milestone: mozilla0.9.8 → mozilla0.9.9
give to shanjian. please do nothing untill bstell land his truetype patch remove target
Assignee: bstell → shanjian
Status: ASSIGNED → NEW
Target Milestone: mozilla0.9.9 → ---
I don't mind working on this with you Shanjian.
brian, what's your plan for this? We probably do want to check in this for machV.
Status: NEW → ASSIGNED
Basically the code is in attachment 56315 [details]. It adds ref counting to the fonts.
Attachment #56315 - Attachment is obsolete: true
Attachment #56827 - Attachment is obsolete: true
bstell, would you mind take a look of the patch ?
Shanjian: What about using |nsCOMPtr| for ref-tracking instead of using "home-grown" code ?
Shanjian: thanks for working on this. It has been a while since I last looked at this so I do not remember the details. Would it be possible for you to address these commented out lines? +// gdk_font_unref(mFont); + //mXFont->UnloadFont(); + //mXFont->UnloadFont(); Roland: do you intend to add gfx/xlib patches?
Attachment #89146 - Attachment is obsolete: true
Attachment #89147 - Attachment is obsolete: true
Brian Stell wrote: > Roland: do you intend to add gfx/xlib patches? Sure, if you say the GTK+ patch is OK for you... :)
Roland, I didn't use nsISupport is because reference count is the only thing we need here, and we need to special handling dereference to release font any way.
I talked to dbaron (and waterson). Both recommended not using nsCOMPtr since in debug mode it checks if the code did a queryInterface and if the uuid is non-zero. They both did however suggest using nsRefPtr, http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsAutoPtr.h#201. http://lxr.mozilla.org/seamonkey/source/xpcom/tests/TestAutoPtr.cpp David noted that he had not tried it on all systems and thus it may cause some issue on the ports page but he said he would resolve these. Waterson felt that moz developers should start using this.
I have no idea about how to use nsRefPtr. It looks like to me that nsISupport need to be implemented before it will work. I don't see what is the point to use that.
No, it only requires that the refcounting methods be called AddRef and Release. That said, I should really add the test app for nsRefPtr to the build before you try to use it in code. See bug 104346.
> it only requires that the refcounting methods be called AddRef and Release. Specifically this means adding nsRefPtr to nsFontGTK -class nsFontGTK +class nsFontGTK : nsRefPtr and in the patch IncXFontRefCnt() changes to AddRef: -inline void IncXFontRefCnt() { mXFontRefCnt++; }; +inline void AddRef() { mXFontRefCnt++; }; and DecXFontRefCnt() changes to Release() -nsXFontAAScaledBitmap::DecXFontRefCnt() +nsXFontAAScaledBitmap::Release() (and all the other uses of these in the patch)
> -class nsFontGTK > +class nsFontGTK : nsRefPtr There's no need to do that. It will just increase the size of nsFontGTK by a word and probably cause weird compilation errors.
shanjian is no longer working on mozilla for 2 years and these bugs are still here. Mark them won't fix. If you want to reopen it, find a good owner first.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → WONTFIX
Mass Reassign Please excuse the spam
Assignee: shanjian → nobody
Mass Re-opening Bugs Frank Tang Closed on Wensday March 02 for no reason, all the spam is his fault feel free to tar and feather him
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Reassigning Franks old bugs to Jungshik Shin for triage - Sorry for spam
Assignee: nobody → jshin1987
Status: REOPENED → NEW
QA Contact: amyy → i18n
The code changed by the patch no longer exists. I think the font code under gfx/thebes/ now implements what this bug requested.
Status: NEW → RESOLVED
Closed: 21 years ago10 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: