Towards Efficient Record and Replay: A Case Study in WeChat

Sidong Feng, Haochuan Lu, Ting Xiong, Yuetang Deng, Chunyang Chen · DOI

Introduction

Quality assurance for "super apps" like WeChat presents a massive logistical challenge. To maintain performance across a fragmented ecosystem of devices, developers rely on record-and-replay testing. This process involves recording a sequence of user actions—such as sending a message or opening a digital wallet—on one device and replaying it across hundreds of others.

However, the primary bottleneck in this automation is inter-event waiting time. If a replay tool attempts to click a button before the screen has finished rendering (due to network latency or hardware limitations), the test fails. To mitigate this, industrial testers often resort to "safety buffers," setting wait times significantly longer than necessary. This practice ensures reliability but makes the testing cycle agonizingly slow. This paper introduces WeReplay, a lightweight, image-based tool designed to solve the waiting time problem using deep learning.

The Problem: The "View Hierarchy" Fallacy

Existing record-and-replay tools typically rely on the "view hierarchy"—the underlying XML code structure of the UI—to determine when a screen is ready. However, the view hierarchy is often an unreliable indicator of visual readiness. The code may report that a widget exists and is interactable before it has actually been rendered on the screen or while the app is still in a loading state.

When hardware heterogeneity is introduced, the problem worsens. A script recorded on a high-end device (e.g., a Snapdragon 845) will likely fail on a lower-end device (e.g., a Helio P35) if using fixed timers, as the latter requires more time to process the same UI transitions.

Methodology: WeReplay

WeReplay treats GUI state detection as a computer vision problem rather than a code-parsing problem. By mimicking how a human user waits for visual cues, the tool achieves higher synchronization accuracy.

Visual Classification

The system utilizes a fine-tuned MobileNetV2 convolutional neural network (CNN). MobileNetV2 was chosen for its lightweight architecture, ensuring that the inference process does not become a performance bottleneck during real-time replay. The model classifies screenshots into two primary categories:

  1. Fully Rendered: The UI is static and ready for user interaction.
  2. Partially Rendered: This includes the Transiting State (sliding or fading between screens) and the Loading State (visible loading icons or spinners).

Dynamic Scheduling

During the replay phase, WeReplay streams real-time screenshots to the model. The tool acts as a "dynamic brake," pausing execution until the model confirms the GUI has reached a "Fully Rendered" state. This allows the test to proceed as fast as the specific hardware allows, without the risk of premature interaction.

Data Augmentation

To train the model without exhaustive manual labeling, the authors developed three synthesis techniques to create "partially rendered" training data:

  • Stitching: Simulating screen slides.
  • Blending: Simulating alpha-channel fades.
  • Loading Injection: Superimposing loading spinners onto static, fully rendered screenshots.

Experimental Evaluation

The authors evaluated WeReplay using a dataset of 23,331 WeChat GUI screencasts, refined into 10,656 unique images. Testing covered 23 fundamental usage scenarios across four distinct Android devices (Xiaomi Mix2S, Huawei Nova2S, Vivo Y3, and Google Pixel4a).

Key Results

  • Model Performance: The classification model achieved 92.1% precision and 93.3% recall, significantly outperforming traditional computer vision methods like SIFT and ORB.
  • Reliability: While the state-of-the-practice tool (SARA) saw success rates drop as low as 21.7% on certain devices, WeReplay achieved a 100% success rate across all tested scenarios and hardware.
  • Efficiency: WeReplay proved to be 88% faster than the standard industrial "10x wait" strategy. Average replay time per scenario was reduced from approximately 153 seconds to just 18.45 seconds.

Limitations and Future Work

Despite its success, WeReplay faces challenges with highly dynamic assets. The model occasionally misclassifies pages containing videos or GIFs as "loading" because the constant movement mimics a transiting state. Additionally, very small or inconspicuous loading indicators can sometimes be missed by the CNN.

Future work will focus on expanding the dataset to include more diverse GUI elements and advertisements, as well as adapting the framework for iOS, which will require new datasets to account for platform-specific rendering nuances.

Summary updated

BibTeX
@inproceedings{feng2023towards,
  author = {Sidong Feng and Haochuan Lu and Ting Xiong and Yuetang Deng and Chunyang Chen},
  title = {{Towards Efficient Record and Replay: A Case Study in WeChat}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2023},
  doi = {10.1145/3611643.3613880},
}
Figure