My card game application has a TextView inside of a ScrollView and uses the TextView to display the scores for each player in the game for each round played The TextView is populated with with multiple lines of text string data (see example below).
Round Player1 Player2 Player3 Player4 Player5 Player6
9 3/2 10 1/2 20 0/3 10 3/1 13 4/0 10 3/3 13
8 4/1 14 2/3 23 1/3 10 4/3 13 2/2 22 1/1 21
7 1/1 24 2/2 33 3/2 13 4/2 14 1/2 25 2/2 32
6 etc..
5 etc..
4 etc..
3 etc..
2 etc..
2 etc..
3 etc..
4 etc..
5 etc..
6 etc..
7 etc..
8 etc..
9 etc..
After appending a new text line into the TextView, I resize the TextView (width and height values) so each line can be seen on its own line to avoid any word wrapping from taking place. The ScrollView.contentsize is then set to the TextView.frame.size. This allows the text in the TextView to be scrolled left/right and up/down for viewing.
ISSUE
When the TextView is populated with 40-50 lines of text (each having about 100 characters), then the text display will start to flicker on/off quickly when scrolling is occurring. If I keep scrolling up/down or left/right while flickering is currently occurring, then the flickering will get worse and the full TextView display starts to disappear/reappear/disappear/reappear (worse than just flickering) until eventually the app crashes.
During my testing, when the TextView only has 12 lines of text (each having about 100 characters), I can constantly scroll left/right/left/right/etc. without any flicker for a while, however, eventually (after scrolling left/right/left/right for about 20 times back and forth) then flickering starts to occur. Once the flickering occurs then the flickering is constant until I stop scrolling left/right. If I stop scrolling for 10-15 seconds then start the left/right/left/right scrolling again then the scrolling works fine until I scrolled back and forth about 20 times again, then flickering starts up again. I cannot get it to crash with only 12 lines of text in the TextView. To get it to crash I need about 40-50 lines of data in the TextView
When flickering occurs, I see MANY MANY of the following lines displayed in the simulator debug window:
CoreAnimation: failed to allocate ###### bytes
In the case where a crash eventually occurs, I see the following in the debug window as well:
malloc: can't allocate region securely
Why would a TextView inside of a ScrollView start to flicker when populated with only 12 lines of text (100 characters per line)? This does not seem like a lot of data. Any ideas what is going on and how I can potentially fix this issue?
This issue is seen on my real iPhone and logs were obtained when it was connected to the Xcode simulator. If I simply run my application in the simulator only (not using a real iPhone) then I do not see the flickering occur.