## 4 Research Method
### Automatic Training Data Generation  
Object detection algorithms necessitate an extensive dataset for training models, making the collection of numerous screen captures depicting GUI display issues labor-intensive. Currently, there is a dearth of publicly available datasets explicitly tailored for addressing GUI display problems. This paper introduces a methodology for the automatic generation of training data. Our approach relies on the Rico dataset [34], comprising design data from 93,000 Android applications and offering over 66,000 UI screen captures, each paired with its corresponding JSON file.  
Algorithm 1 presents a heuristic-based approach for the automatic generation of training data. Initially, it accepts input parameters, including error-free screen captures, their associated JSON files, the specified category of UI display problems to be generated, and pre-prepared image icons for the \"image missing\" class. The algorithm systematically traverses the JSON file, extracting relevant component information, such as TextView and ImageView. Utilizing this component information, Algorithm 1 duplicates and adjusts positions and sizes according to predefined rules, thereby generating UI screen captures with the associated issues, as illustrated in Figures 3-6.  
In the event of a component occlusion error, the text or image becomes obscured by other components. To induce such errors, Algorithm 1 initiates the process by generating a color block matching the background of the current component, possessing the same width but differing in height. Subsequently, this generated color block is repositioned to partially cover the component.  
Figure 3: Example of an algorithm generating a component occlusion problem.  
```
Input :category Output :image
1 ifcategory is 'component occlusion'then
2 rand \(\leftarrow\) randomUniform(0, 1);
3 ifrand > 0.5 then
4 range \(\leftarrow\) randomUniform(0.5, 0.7);
5 end if
6 else
7 range \(\leftarrow\) randomUniform(\(-\)0.7, \(-\)0.5);
8 end if
9 Generate block image with [width, height \(\times\) range] and background;
10 ifrange \(\geq\) 0 then
11 pasteBlockOn(image, x1, y1);
12 end if
13 else
14 pasteBlockOn(image, x1, y2 + height \(\times\) range);
15 end if
16
17 end if
18 ifcategory is'missing image'then
19 generateAndPasteBlock(image, x1, y1, genericWidth, genericHeight);
20 resizelconTo(image, x1, y1, genericWidth, genericHeight);
21
22 end if
23 ifcategory is 'null value'then
24 generateAndPasteBlock(image, x1, y1, genericWidth, genericHeight);
25 drawNullStringOn(image, x1, y1, font, background);
26
27 end if
28 ifcategory is 'text overlap'then
29 range \(\leftarrow\) randomUniform(0.8 \(\times\) genericWidth, 0.85 \(\times\) genericWidth);
30 rand \(\leftarrow\) randomUniform(0, 1);
31 cropped \(\rightarrow\) cropImageBy(image, x1, y1, x2, y2);
32 ifrand > 0.5 then
33 pasteCroppedOn(image, cropped, x2 \(-\) range, y1);
34
35 end if
36
37 pasteCroppedOn(image, cropped, x1 \(-\) genericWidth + range, y1);
38
39 end if
40
41 end if
42
43 return image;
```  
**Algorithm 1**Heuristic-based training data auto-generation.  
In the case of an image missing error, where the original image fails to display correctly and is represented by an image icon, Algorithm 1 employs four common image icons to emulate situations where the image is not properly rendered. Initially, a color block, identical in size to the current image and with a background color corresponding to the predetermined color of the image, is created. The display area of the original image is then covered.  
In instances of a null value error, manifested as the display of \"null\" in the text area, Algorithm 1 first determines the height of text in a TextView and converts it into a font of the same height. Subsequently, a \"null\" text with an identical background color is generated and superimposed onto the original TextView.  
When confronted with a text overlap error, characterized by the overlapping of text content, thereby impairing readability, Algorithm 1 initially acquires the position and size