Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-22 Thread Adam Ratana
For anyone that comes across this in the future, the solution I wound up
implementing is basically not rotating text constantly, but only by discrete
values when the rotation angle passes a certain limit, ie a rough example
would be, if it's  45 degrees, rotate text by 90,  -45 , rotate by-90, so
that it doesn't fill up the cache with a bazillion instances drawn at
slightly different angles.  It's not as pretty as before, but now the cache
is not being thrashed, so will end up being prettier in the end :)  Thanks
again to Romain and Dianne for replying, I really appreciate your presence
on these forums, and not just on this post, it's a big help.


On Mon, Jun 20, 2011 at 9:47 PM, Dianne Hackborn hack...@android.comwrote:

 Yes, that will do it.  Note that each angle you draw a glyph at needs a new
 entry in the cache for the bitmap of the glyph drawn at that angle.

 On Mon, Jun 20, 2011 at 6:42 PM, Adam Ratana adam.rat...@gmail.comwrote:

 After seeing this response, I spent some time to figure out exactly what I
 was doing now that was causing this to appear in the logs so much.  I was
 puzzled because I wasn't using many styles or colors, the same font, same
 color.  I turned off alpha blending, and removed all the items I was drawing
 until I was left with 1, and it was still overloading the cache.  I narrowed
 it down to doing:

 canvas.save();
 canvas.rotate(rotationAngle, p.x, p.y); // this is the offending line
 canvas.drawText(text, p.x, p.y, paint);
 canvas.restore();

 If I rotate and then draw text (this is an AR type implementation where
 the text is rotating with the phone), this is where the font cache fills up,
 with just 1 static piece of text.  Commenting out the above line doesn't.
  Even with a large number of text items, NOT rotating the canvas before
 drawing the text, doesn't fill the cache.

 This seems kind of strange to me that this would fill the cache, but, is
 there another way to do this to not fill the cache?




 On Mon, Jun 20, 2011 at 7:43 PM, Dianne Hackborn hack...@android.comwrote:

 Well having it printed every second or so indicates you are pretty
 severely thrashing the cache, which can certainly impact performance.  For
 example drawing your UI may not be fitting in the cache so each frame you
 draw requires re-rendering glyphs back in to the cache.  If that is the
 case, look at doing things like reducing the number of distinct font sizes
 or families/styles you are using to have less impact on the cache.




 --
 Adam Ratana
 adam.rat...@gmail.com

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Adam Ratana
adam.rat...@gmail.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Adam Ratana
Thank you for responding; it seems to be freeing up quite often, probably 
several to more than several meg of memory a second (if the numbers are 
right), depending on how often the view is invalidated.  I know we are 
working with limited heap space, is this something we can optimize in our 
implementation or should we not be concerned at all?  Most of the text is 
the same, but could be generated with new string instances for example. 
 Thanks,

Adam

On Monday, June 20, 2011 12:58:03 AM UTC-4, Dianne Hackborn wrote:

 It just means it needs to flush old data from the font cache.  You may see 
 this a lot if you are for example drawing at a large number of sizes, as you 
 fill up the font cache with glyphs in a lot of sizes and old glyphs need to 
 be removed to make room.

 On Sun, Jun 19, 2011 at 9:17 PM, Adam Ratana adam@gmail.com wrote:

 Hello, I am noticing the same with an implementation for some new 
 functionality I'm experimenting with.  I am doing a lot of canvas.drawText 
 calls on a custom View canvas, using the system font though.  Are you doing 
 canvas.drawText a lot, Samuh?

 Also a bump in case anyone reading has knowledge on this subject. 
  Wondering am I doing something stupid here, trying to avoid jankiness.


 On Wednesday, June 1, 2011 2:10:27 PM UTC-4, Samuh wrote:

 We are using four different custom fonts across our app. These files 
 are bundled in Assets and are opened in onCreate of every Activity. 

 While studying the logs of our app we keep observing the following log 
 from Skia decoder. 

 01-01 19:19:51.585: DEBUG/skia(1510): purging 197K from font cache [20 
 entries] 

 What does the above mean? And how does it affect performance? 

 Is it desirable? 

 Thanks. 

  -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com
 To unsubscribe from this group, send email to
 android-develop...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




 -- 
 Dianne Hackborn
 Android framework engineer
 hac...@android.com

 Note: please don't send private questions to me, as I don't have time to 
 provide private support, and so won't reply to such e-mails.  All such 
 questions should be posted on public forums, where I and others can see and 
 answer them.



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Romain Guy
Skia's font cache doesn't count towards your heap limit.

On Sun, Jun 19, 2011 at 11:19 PM, Adam Ratana adam.rat...@gmail.com wrote:
 Thank you for responding; it seems to be freeing up quite often, probably
 several to more than several meg of memory a second (if the numbers are
 right), depending on how often the view is invalidated.  I know we are
 working with limited heap space, is this something we can optimize in our
 implementation or should we not be concerned at all?  Most of the text is
 the same, but could be generated with new string instances for example.
  Thanks,
 Adam

 On Monday, June 20, 2011 12:58:03 AM UTC-4, Dianne Hackborn wrote:

 It just means it needs to flush old data from the font cache.  You may see
 this a lot if you are for example drawing at a large number of sizes, as you
 fill up the font cache with glyphs in a lot of sizes and old glyphs need to
 be removed to make room.

 On Sun, Jun 19, 2011 at 9:17 PM, Adam Ratana adam@gmail.com wrote:

 Hello, I am noticing the same with an implementation for some new
 functionality I'm experimenting with.  I am doing a lot of canvas.drawText
 calls on a custom View canvas, using the system font though.  Are you doing
 canvas.drawText a lot, Samuh?
 Also a bump in case anyone reading has knowledge on this subject.
  Wondering am I doing something stupid here, trying to avoid jankiness.

 On Wednesday, June 1, 2011 2:10:27 PM UTC-4, Samuh wrote:

 We are using four different custom fonts across our app. These files
 are bundled in Assets and are opened in onCreate of every Activity.

 While studying the logs of our app we keep observing the following log
 from Skia decoder.

 01-01 19:19:51.585: DEBUG/skia(1510): purging 197K from font cache [20
 entries]

 What does the above mean? And how does it affect performance?

 Is it desirable?

 Thanks.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-d...@googlegroups.com
 To unsubscribe from this group, send email to
 android-develop...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


 --
 Dianne Hackborn
 Android framework engineer
 hac...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Adam Ratana
Thanks for the speedy replies Romain and Diane. I take it now that we should 
not worry about it, beyond the typical known concerns for real-time drawing 
and rendering, etc.  Appreciated --

Adam

On Monday, June 20, 2011 2:22:14 AM UTC-4, Romain Guy (Google) wrote:

 Skia's font cache doesn't count towards your heap limit.

 On Sun, Jun 19, 2011 at 11:19 PM, Adam Ratana adam@gmail.com wrote:
  Thank you for responding; it seems to be freeing up quite often, probably
  several to more than several meg of memory a second (if the numbers are
  right), depending on how often the view is invalidated.  I know we are
  working with limited heap space, is this something we can optimize in our
  implementation or should we not be concerned at all?  Most of the text is
  the same, but could be generated with new string instances for example.
   Thanks,
  Adam
 
  On Monday, June 20, 2011 12:58:03 AM UTC-4, Dianne Hackborn wrote:
 
  It just means it needs to flush old data from the font cache.  You may 
 see
  this a lot if you are for example drawing at a large number of sizes, as 
 you
  fill up the font cache with glyphs in a lot of sizes and old glyphs need 
 to
  be removed to make room.
 
  On Sun, Jun 19, 2011 at 9:17 PM, Adam Ratana adam...@gmail.com wrote:
 
  Hello, I am noticing the same with an implementation for some new
  functionality I'm experimenting with.  I am doing a lot of 
 canvas.drawText
  calls on a custom View canvas, using the system font though.  Are you 
 doing
  canvas.drawText a lot, Samuh?
  Also a bump in case anyone reading has knowledge on this subject.
   Wondering am I doing something stupid here, trying to avoid jankiness.
 
  On Wednesday, June 1, 2011 2:10:27 PM UTC-4, Samuh wrote:
 
  We are using four different custom fonts across our app. These files
  are bundled in Assets and are opened in onCreate of every Activity.
 
  While studying the logs of our app we keep observing the following log
  from Skia decoder.
 
  01-01 19:19:51.585: DEBUG/skia(1510): purging 197K from font cache [20
  entries]
 
  What does the above mean? And how does it affect performance?
 
  Is it desirable?
 
  Thanks.
 
  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to androi...@googlegroups.com
  To unsubscribe from this group, send email to
  android-d...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en
 
 
  --
  Dianne Hackborn
  Android framework engineer
  hac...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see 
 and
  answer them.
 
  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-d...@googlegroups.com
  To unsubscribe from this group, send email to
  android-develop...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

 -- 
 Romain Guy
 Android framework engineer
 roma...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Dianne Hackborn
Well having it printed every second or so indicates you are pretty severely
thrashing the cache, which can certainly impact performance.  For example
drawing your UI may not be fitting in the cache so each frame you draw
requires re-rendering glyphs back in to the cache.  If that is the case,
look at doing things like reducing the number of distinct font sizes or
families/styles you are using to have less impact on the cache.

On Sun, Jun 19, 2011 at 11:33 PM, Adam Ratana adam.rat...@gmail.com wrote:

 Thanks for the speedy replies Romain and Diane. I take it now that we
 should not worry about it, beyond the typical known concerns for real-time
 drawing and rendering, etc.  Appreciated --

 Adam


 On Monday, June 20, 2011 2:22:14 AM UTC-4, Romain Guy (Google) wrote:

 Skia's font cache doesn't count towards your heap limit.

 On Sun, Jun 19, 2011 at 11:19 PM, Adam Ratana adam@gmail.com wrote:
  Thank you for responding; it seems to be freeing up quite often,
 probably
  several to more than several meg of memory a second (if the numbers are
  right), depending on how often the view is invalidated.  I know we are
  working with limited heap space, is this something we can optimize in
 our
  implementation or should we not be concerned at all?  Most of the text
 is
  the same, but could be generated with new string instances for example.
   Thanks,
  Adam
 
  On Monday, June 20, 2011 12:58:03 AM UTC-4, Dianne Hackborn wrote:
 
  It just means it needs to flush old data from the font cache.  You may
 see
  this a lot if you are for example drawing at a large number of sizes,
 as you
  fill up the font cache with glyphs in a lot of sizes and old glyphs
 need to
  be removed to make room.
 
  On Sun, Jun 19, 2011 at 9:17 PM, Adam Ratana adam...@gmail.com
 wrote:
 
  Hello, I am noticing the same with an implementation for some new
  functionality I'm experimenting with.  I am doing a lot of
 canvas.drawText
  calls on a custom View canvas, using the system font though.  Are you
 doing
  canvas.drawText a lot, Samuh?
  Also a bump in case anyone reading has knowledge on this subject.
   Wondering am I doing something stupid here, trying to avoid
 jankiness.
 
  On Wednesday, June 1, 2011 2:10:27 PM UTC-4, Samuh wrote:
 
  We are using four different custom fonts across our app. These files
  are bundled in Assets and are opened in onCreate of every Activity.
 
  While studying the logs of our app we keep observing the following
 log
  from Skia decoder.
 
  01-01 19:19:51.585: DEBUG/skia(1510): purging 197K from font cache
 [20
  entries]
 
  What does the above mean? And how does it affect performance?
 
  Is it desirable?
 
  Thanks.
 
  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to androi...@googlegroups.com

  To unsubscribe from this group, send email to
  android-d...@googlegroups.com

  For more options, visit this group at
  http://groups.google.com/**group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=en
 
 
  --
  Dianne Hackborn
  Android framework engineer
  hac...@android.com
 
  Note: please don't send private questions to me, as I don't have time
 to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
 and
  answer them.
 
  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-d...@googlegroups.com
  To unsubscribe from this group, send email to
  android-develop...@**googlegroups.com
  For more options, visit this group at
  http://groups.google.com/**group/android-developers?hl=enhttp://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 roma...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, 

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Adam Ratana
After seeing this response, I spent some time to figure out exactly what I
was doing now that was causing this to appear in the logs so much.  I was
puzzled because I wasn't using many styles or colors, the same font, same
color.  I turned off alpha blending, and removed all the items I was drawing
until I was left with 1, and it was still overloading the cache.  I narrowed
it down to doing:

canvas.save();
canvas.rotate(rotationAngle, p.x, p.y); // this is the offending line
canvas.drawText(text, p.x, p.y, paint);
canvas.restore();

If I rotate and then draw text (this is an AR type implementation where the
text is rotating with the phone), this is where the font cache fills up,
with just 1 static piece of text.  Commenting out the above line doesn't.
 Even with a large number of text items, NOT rotating the canvas before
drawing the text, doesn't fill the cache.

This seems kind of strange to me that this would fill the cache, but, is
there another way to do this to not fill the cache?




On Mon, Jun 20, 2011 at 7:43 PM, Dianne Hackborn hack...@android.comwrote:

 Well having it printed every second or so indicates you are pretty severely
 thrashing the cache, which can certainly impact performance.  For example
 drawing your UI may not be fitting in the cache so each frame you draw
 requires re-rendering glyphs back in to the cache.  If that is the case,
 look at doing things like reducing the number of distinct font sizes or
 families/styles you are using to have less impact on the cache.




-- 
Adam Ratana
adam.rat...@gmail.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-20 Thread Dianne Hackborn
Yes, that will do it.  Note that each angle you draw a glyph at needs a new
entry in the cache for the bitmap of the glyph drawn at that angle.

On Mon, Jun 20, 2011 at 6:42 PM, Adam Ratana adam.rat...@gmail.com wrote:

 After seeing this response, I spent some time to figure out exactly what I
 was doing now that was causing this to appear in the logs so much.  I was
 puzzled because I wasn't using many styles or colors, the same font, same
 color.  I turned off alpha blending, and removed all the items I was drawing
 until I was left with 1, and it was still overloading the cache.  I narrowed
 it down to doing:

 canvas.save();
 canvas.rotate(rotationAngle, p.x, p.y); // this is the offending line
 canvas.drawText(text, p.x, p.y, paint);
 canvas.restore();

 If I rotate and then draw text (this is an AR type implementation where the
 text is rotating with the phone), this is where the font cache fills up,
 with just 1 static piece of text.  Commenting out the above line doesn't.
  Even with a large number of text items, NOT rotating the canvas before
 drawing the text, doesn't fill the cache.

 This seems kind of strange to me that this would fill the cache, but, is
 there another way to do this to not fill the cache?




 On Mon, Jun 20, 2011 at 7:43 PM, Dianne Hackborn hack...@android.comwrote:

 Well having it printed every second or so indicates you are pretty
 severely thrashing the cache, which can certainly impact performance.  For
 example drawing your UI may not be fitting in the cache so each frame you
 draw requires re-rendering glyphs back in to the cache.  If that is the
 case, look at doing things like reducing the number of distinct font sizes
 or families/styles you are using to have less impact on the cache.




 --
 Adam Ratana
 adam.rat...@gmail.com

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] skia / purging [x]k from font cache [y entries] - what does it mean? was Re: Custom Fonts

2011-06-19 Thread Dianne Hackborn
It just means it needs to flush old data from the font cache.  You may see
this a lot if you are for example drawing at a large number of sizes, as you
fill up the font cache with glyphs in a lot of sizes and old glyphs need to
be removed to make room.

On Sun, Jun 19, 2011 at 9:17 PM, Adam Ratana adam.rat...@gmail.com wrote:

 Hello, I am noticing the same with an implementation for some new
 functionality I'm experimenting with.  I am doing a lot of canvas.drawText
 calls on a custom View canvas, using the system font though.  Are you doing
 canvas.drawText a lot, Samuh?

 Also a bump in case anyone reading has knowledge on this subject.
  Wondering am I doing something stupid here, trying to avoid jankiness.


 On Wednesday, June 1, 2011 2:10:27 PM UTC-4, Samuh wrote:

 We are using four different custom fonts across our app. These files
 are bundled in Assets and are opened in onCreate of every Activity.

 While studying the logs of our app we keep observing the following log
 from Skia decoder.

 01-01 19:19:51.585: DEBUG/skia(1510): purging 197K from font cache [20
 entries]

 What does the above mean? And how does it affect performance?

 Is it desirable?

 Thanks.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en