Android: Drawing a Picture with a clip into a scroll view causes consistent ANR?
<p>I ran into a mysterious ANR with my application which uses Pictures to record drawing command (paths, clips, text, etc.) and then draws these Pictures into Views held by a ScrollView.  I was able to reproduce the issue with the below activity.  In this activity, scrolling down in the ScrollView will produce an ANR as soon the bottom of the square is reached.  Has anyone else ran into this?  Any suggestions on how to avoid it? </p>

<pre><code>public class AnrTest extends Activity
{
    public void onCreate(Bundle saveInstBundle)
    {
        super.onCreate(saveInstBundle);

        ScrollView sc = new ScrollView(this);
        MyView view = new MyView(this);
        sc.addView(view);
        setContentView(sc);
    }

    class MyView extends View
    {
        Picture mPic;

        public MyView(Context context)
        {
            super(context);
            mPic = new Picture();
            Canvas picCanvas = mPic.beginRecording(300, 900);

            Paint p = new Paint();
            p.setColor(Color.RED);
            picCanvas.drawRect(20, 20, 100, 100, p);

            picCanvas.clipRect(0, 0, 100, 100);

            mPic.endRecording();
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) 
        {
            //set a height larger than the screen, so that we can scroll.
            setMeasuredDimension(300, 900);
        }

        protected void onDraw(Canvas canvas)
        {
            canvas.drawPicture(mPic);
        }
    }
}
</code></pre>
