A method, apparatus, device and medium for rendering a dynamic image

By using a rendering method based on the frame delay of dynamic images, combined with timestamps and historical rendering error calculations, the problem of inconsistent playback rhythm of dynamic images on different devices in traditional technologies is solved, achieving a smooth and stable rendering effect.

CN122492897APending Publication Date: 2026-07-31ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
Filing Date
2026-04-21
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Traditional motion graphics rendering technology cannot accurately control the playback rhythm on devices with different refresh rates, resulting in motion graphics playing at double speed on high refresh rate devices and playing slowly or stuttering on low refresh rate devices, while also consuming too much resources.

Method used

By obtaining the frame delay of the dynamic image as the rendering benchmark, and combining the current timestamp, historical rendering timestamps and errors, the current effective elapsed time difference is calculated. Rendering is only performed when the time difference meets the frame delay, and the historical rendering timestamps and errors are updated to avoid invalid rendering.

Benefits of technology

It achieves accurate frame-by-frame rendering and smooth continuous playback of dynamic images on devices with different refresh rates, reduces device power consumption, avoids playback speed increase and stuttering, and meets the rendering needs of cross-platform applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122492897A_ABST
    Figure CN122492897A_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and medium for rendering dynamic images. The method includes: using the frame delay of the dynamic image itself as the benchmark for rendering determination, abandoning the direct binding mode between the rendering drive signal and the screen refresh rate, and allowing the rendering rhythm of the dynamic image to be determined by its own defined frame delay rather than the screen refresh cycle of the device. This enables precise control of the playback rhythm of animated images on digital cultural and creative software terminals with different refresh rates, avoiding the situation of accelerated playback on high refresh rate devices, and also avoiding the situation of slow playback or stuttering on low refresh rate devices. This application meets the practical needs of achieving accurate frame-by-frame rendering and continuous smooth playback of dynamic images on different digital cultural and creative software terminals, and can be widely used in the fields of digital cultural product production software and digital cultural and creative software in the digital creative industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of digital cultural and creative software technology, and in particular to a method, apparatus, device and medium for rendering dynamic images. Background Technology

[0002] In the field of dynamic image rendering technology for digital cultural and creative software, dynamic image rendering refers to the process of decoding and displaying multiple frames of dynamic images such as GIF, WebP, and APNG sequentially according to a preset rhythm to present a continuous animation effect. To ensure that the playback speed of the animated image conforms to its original definition and to guarantee consistency between the original definition and cross-terminal presentation, it is often necessary to rationally configure the rendering logic of the animated image to reduce unnecessary decoding and rendering operations and lower the hardware load on the device.

[0003] Traditional techniques for rendering dynamic images typically bind the rendering drive signal directly to the physical screen refresh rate of the current playback device, thus triggering frame rendering directly upon receiving the rendering drive signal. However, on high refresh rate devices, if the screen refresh cycle is shorter than the frame delay of the animation, frequent rendering triggers can cause the animation to play at double speed. On low refresh rate devices, if the screen refresh cycle is longer than the frame delay of the animation, the animation will play slowly or stutter.

[0004] Because the rendering rhythm of traditional technology is determined by the screen refresh cycle rather than by the animation itself, the playback speed of the animation deviates from the original design during the rendering process due to the inability to accurately control the playback rhythm of the animation. This results in problems such as stuttering, frame skipping, or chaotic rendering rhythm in the playback of dynamic images, and cannot meet the actual needs of achieving accurate frame-by-frame rendering and continuous smooth playback of dynamic images in different digital cultural and creative software terminals. Summary of the Invention

[0005] The main purpose of this application is to propose a method, apparatus, device and medium for rendering dynamic images. By using the frame delay of the dynamic image itself as the benchmark for rendering, the rendering rhythm of the dynamic image is determined by its own defined frame delay rather than the device screen refresh cycle. This allows for precise control of the playback rhythm of animated images on digital cultural and creative software terminals with different refresh rates, thus meeting the requirements for continuous and smooth playback of animations in digital cultural and creative software.

[0006] To achieve the above objectives, one aspect of this application proposes a method for rendering dynamic images, the method comprising: Obtain the frame delay of a dynamic image; Repeat the following signal response operation until the dynamic image is rendered: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Based on the current timestamp, the historical rendering timestamp, and the historical rendering time error, a current effective elapsed time difference is generated; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; When it is determined that the current effective elapsed time difference is not less than the frame delay, the unrendered frame is rendered, and the historical rendering timestamp and the historical rendering time error are updated according to the current effective elapsed time difference, the frame delay and the current rendering timestamp at the time of this rendering. When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the next round of the image rendering drive signal.

[0007] Further, in some embodiments, updating the historical rendering timestamp and the historical rendering time error for the next execution of the signal response operation based on the current effective elapsed time difference, the frame delay, and the current rendering timestamp during this rendering includes: Use the current rendering timestamp as the historical rendering timestamp for the next execution of the signal response operation; The time error between the current effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

[0008] Furthermore, in some embodiments, after determining that the current effective elapsed time difference is less than the frame delay, and before receiving the next round of the image rendering drive signal, the method further includes: Continuously acquire real-time candidate timestamps, and each time a candidate timestamp is acquired, calculate the candidate effective elapsed time difference based on the candidate timestamp, the historical rendering timestamp, and the historical rendering time error; When it is determined that the candidate effective elapsed time difference is not less than the frame delay, frame data preparation is performed on the unrendered frame to obtain the frame to be rendered with the frame data preparation completed, so that the frame to be rendered can be directly rendered when the image rendering drive signal of the next round is received. The candidate timestamp corresponding to the completion of frame data preparation will be used as the historical rendering timestamp for the next execution of the signal response operation. The time error between the candidate effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

[0009] Furthermore, in some embodiments, obtaining the current unrendered frame of the dynamic image upon receiving the image rendering drive signal for the current round includes: Upon receiving the image rendering drive signal for the current round, determine whether there is a frame to be rendered that has completed frame data preparation; If so, render the frame to be rendered, and then obtain the current unrendered frame of the dynamic image; If not, then directly obtain the current unrendered frame of the dynamic image.

[0010] Furthermore, in some embodiments, the step of performing frame data preparation on the unrendered frame includes: Allocate a corresponding rendering buffer for the unrendered frame; The single-frame vertical synchronization period is determined based on the screen refresh frequency corresponding to the image rendering drive signal. The single-frame vertical synchronization cycle is divided into a first half-frame timing stage and a second half-frame timing stage that are connected sequentially. The frame data of the unrendered frame is split into the first half frame data and the second half frame data; During the first half-frame timing phase, the first half-frame data is written to the rendering buffer; during the second half-frame timing phase, the second half-frame data is written to the rendering buffer. When it is detected that all the data of the second half of the frame has been written to the rendering buffer, the frame data preparation of the unrendered frame is completed.

[0011] Furthermore, in some embodiments, obtaining the current unrendered frame of the dynamic image upon receiving the image rendering drive signal for the current round includes: Upon receiving the image rendering drive signal for the current round, determine whether the rendering buffer has completed writing all the data for the first half of the frame and the second half of the frame. If so, the first half-frame data and the second half-frame data are rendered sequentially, and then the current unrendered frame of the dynamic image is obtained. If not, then directly obtain the current unrendered frame of the dynamic image.

[0012] Further, in some embodiments, the step of using the time error between the candidate valid elapsed time difference and the frame delay as the historical rendering time error for the next execution of the signal response operation includes: The difference between the candidate effective elapsed time difference and the frame delay is taken as the time error to be compensated. Get the current rendering load rate; Based on the mapping relationship between the load rate and the compensation coefficient, the error compensation coefficient corresponding to the rendering load rate is extracted; Multiply the error compensation coefficient by the time error to be compensated to obtain the compensated time error value; The compensated time error value is used as the historical rendering time error when the signal response operation is performed next time.

[0013] Furthermore, in some embodiments, the generation of the initial time value includes: Upon first receiving the image rendering drive signal, the clock timestamp of the current system hardware is collected; The average of the trigger timestamp of the image rendering drive signal and the clock timestamp is used as the initial time value.

[0014] Furthermore, in some embodiments, the method further includes, before repeatedly performing the signal response operation: When it is determined that the frame delay is less than the first preset delay threshold, the second preset delay threshold is used as the corrected frame delay; The corrected frame delay is used as the frame delay when performing the signal response operation; Wherein, the first preset delay threshold is less than the second preset delay threshold.

[0015] Furthermore, in some embodiments, the method further includes, before repeatedly performing the signal response operation: Get the current battery level; When it is determined that the current battery level is less than a preset battery level threshold, an adjusted frame delay is generated based on the product of the frame delay and a preset ratio value; wherein, the preset ratio value is used to increase the frame delay. The adjusted frame delay is used as the frame delay when performing the signal response operation.

[0016] To achieve the above objectives, another aspect of this application proposes a dynamic image rendering apparatus, the apparatus comprising: The frame delay acquisition module is used to acquire the frame delay of dynamic images; The dynamic image rendering module is used to repeatedly execute the following signal response operation until the dynamic image rendering is complete: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Based on the current timestamp, the historical rendering timestamp, and the historical rendering time error, a current effective elapsed time difference is generated; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; When it is determined that the current effective elapsed time difference is not less than the frame delay, the unrendered frame is rendered, and the historical rendering timestamp and the historical rendering time error are updated according to the current effective elapsed time difference, the frame delay and the current rendering timestamp at the time of this rendering. When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the next round of the image rendering drive signal.

[0017] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned dynamic image rendering method.

[0018] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned dynamic image rendering method.

[0019] The embodiments of this application include at least the following beneficial effects: This application provides a method, apparatus, device, and medium for rendering dynamic images. The method first obtains the frame delay defined by the dynamic image itself and uses it as the basis for determining the rendering rhythm. During the repeated execution of signal response operations, each time the current round of image rendering drive signal is received, the unrendered frame and the current timestamp are obtained. The current effective elapsed time difference is calculated by combining the historical rendering timestamp and the historical rendering time error. The comparison result between the current effective elapsed time difference and the frame delay of the dynamic image itself is used as the rendering determination basis. The frame rendering operation is only performed when the time difference is not less than the frame delay; otherwise, the next round of image rendering drive signal is waited for. This can avoid the situation where frame rendering is directly triggered when the rendering drive signal is received. After rendering, the present invention also updates the historical rendering timestamp and historical rendering time error of the next round according to the current effective elapsed time difference, frame delay, and the current rendering timestamp of this rendering, realizing dynamic iterative calibration of rendering timing parameters. Compared with traditional technologies, this application uses the frame delay of the dynamic image itself as the benchmark for rendering, abandoning the direct binding mode between the rendering drive signal and the screen refresh rate. Instead, it uses the current effective elapsed time difference, which integrates historical timing parameters, as the actual basis for rendering triggering. This allows the rendering rhythm of the dynamic image to be determined by its own defined frame delay rather than the device's screen refresh cycle. This enables precise control of the animation playback rhythm on digital cultural and creative software terminals with different refresh rates, avoiding the situation of accelerated playback on high refresh rate devices and the situation of slow playback or stuttering on low refresh rate devices. It solves the problem that the traditional technology causes the animation playback speed to deviate from the original design because the rendering rhythm is determined by the screen refresh cycle. This can meet the actual needs of achieving accurate frame-by-frame rendering and continuous smooth playback of dynamic images on different digital cultural and creative software terminals. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating a dynamic image rendering method provided in an embodiment of this application; Figure 2 This is a flowchart illustrating the repeated execution of the signal response operation in step S2000 provided in the embodiments of this application; Figure 3 This is a flowchart of the gap stage processing of step S2400 provided in the embodiments of this application; Figure 4 This is a flowchart illustrating the process of determining the completed frame data operation in step S2100 provided in this application embodiment; Figure 5 This is a flowchart of the rendering buffer data writing process in step S2430 provided in the embodiments of this application; Figure 6 This is a flowchart of step S2440, the time error compensation step, provided in an embodiment of this application. Figure 7 This is a schematic diagram of the structure of a dynamic image rendering device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0022] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”

[0023] As used in this application, the term "each" means each of a corresponding plurality, and "any" means any one of a plurality.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0025] Before providing a detailed description of the embodiments of this application, some of the nouns and terms involved in the embodiments of this application will be explained first. The nouns and terms involved in the embodiments of this application are subject to the following interpretations.

[0026] (1) Dynamic images: refers to image files containing multiple frames that can present continuous animation effects, including formats such as GIF, WebP, and APNG, whose playback rhythm is defined by the frame delay attribute.

[0027] (2) Image rendering drive signal: namely the system VSync (vertical synchronization) signal, which is a periodic synchronization pulse generated by the terminal screen according to the physical refresh rate. The triggering frequency is consistent with the screen refresh rate. For example, a 120Hz screen refresh rate device triggers once every 8.33ms.

[0028] (3) Frame delay: refers to the display duration of a single frame as defined in the dynamic image metadata. It is the benchmark for the playback rhythm of the animation. For example, 100ms means that each frame needs to be displayed for 100ms before switching to the next frame.

[0029] (4) VSync (Vertical Sync): The synchronization mechanism of the terminal screen, used to coordinate the working rhythm of the CPU (Central Processing Unit), GPU (Graphics Processing Unit) and the screen, to ensure that the frame of the image rendered by the GPU can be precisely aligned with the screen refresh cycle, and to avoid abnormalities such as screen tearing and misalignment. In this invention, the VSync signal is the image rendering drive signal, and its triggering frequency is strictly consistent with the screen refresh rate. It is the triggering node of the rendering process.

[0030] (5) GPU (Graphics Processing Unit): A hardware component specifically designed for processing graphics and image-related calculations. It has parallel computing capabilities, and its core functions include frame data decoding, pixel format conversion, texture rendering, and buffer data reading. In this invention, the GPU is responsible for performing the final display operation of the unrendered frames. It reads the prepared frame data through the rendering buffer and quickly completes the image rendering.

[0031] (6) React Native: A cross-platform application development framework based on JavaScript / TypeScript, characterized by "write once, adapt to multiple platforms". It connects the JS logic layer and the native rendering layer of iOS / Android through the C++ Fabric bridging layer, eliminating the need for separate development for different terminals. In this invention, React Native is the main cross-platform framework for adaptation. The scheduler of this invention is deployed between the bridging layer and the native rendering layer of this framework to achieve consistent rendering of dynamic images across iOS / Android terminals.

[0032] (7) iOS is Apple's mobile operating system; Android is a mobile operating system developed primarily by Google. iOS system CADisplayLink: A high-precision timer component provided by the iOS system. Its trigger frequency is automatically synchronized with the screen's physical refresh rate, such as triggering once every 16.67ms for a 60Hz screen and once every 8.33ms for a 120Hz screen. Its function is to provide a precise timing triggering reference for rendering operations on the iOS side. In this invention, the iOS device obtains VSync (image rendering drive signal) by listening to the callback signal of CADisplayLink, which is the implementation method of capturing the screen refresh rhythm at the physical layer.

[0033] (8) GIF (Graphics Interchange Format): A bitmap image format that supports multi-frame animation, achieving continuous playback by defining frame delays in metadata. In this invention, GIF is one of the adapted dynamic image formats, and its frame delay is extracted by parsing the Graphic Control Extension block of the file as a reference for the rendering rhythm.

[0034] (9) WebP: A high-efficiency dynamic image format developed by Google, supporting lossy / lossless compression, alpha channels, and multi-frame animation. It has a smaller file size than GIF for the same image quality, and the frame delay definition is stored in the Animation Chunk. In this invention, WebP and GIF use a unified frame delay parsing logic and rendering control process, achieving consistent playback across platforms without additional adaptation.

[0035] (10) APNG (Animated Portable Network Graphics): A dynamic image format based on the PNG format extension, supporting full color levels and alpha channels. Frame delay is calculated using delay_num (delay numerator) and delay_den (delay denominator) of the fcTL block. In this invention, the frame delay parsing logic of APNG has been integrated into the core process, sharing a rendering determination mechanism with other dynamic image formats.

[0036] With the popularization of cross-platform application development technology, dynamic images have become core content in scenarios such as chat interaction and transaction display, and their rendering effect directly affects the user experience. However, traditional dynamic image rendering solutions often adopt a mechanism that directly binds the rendering drive signal to the physical screen refresh rate. When the screen refresh signal is received, frame decoding and rendering are triggered directly without accurately determining the frame latency characteristics of the dynamic image itself.

[0037] Traditional techniques have many shortcomings in the rendering process. For example, on high refresh rate devices, the screen refresh cycle is shorter than the animation frame delay, which will cause the animation to play at double speed; on low refresh rate devices, the screen refresh cycle is longer than the animation frame delay, which will cause playback to stutter or the rhythm to go off track. At the same time, high-frequency invalid rendering will cause redundant consumption of CPU / GPU resources, aggravate device heat generation, shorten battery life, and make it difficult to meet the requirements of digital cultural and creative software applications for accurate and stable rendering of dynamic images.

[0038] In view of this, this application provides a method, apparatus, device, and medium for rendering dynamic images. The method first obtains the frame delay of the dynamic image, then repeatedly executes signal response operations until rendering is complete. Specifically, upon receiving an image rendering drive signal, it synchronously obtains the unrendered frame and the current timestamp, combines the historical rendering timestamp and historical rendering time error to generate the current effective elapsed time difference. Rendering is only performed and historical data is updated when this time difference is not less than the frame delay; otherwise, it waits for the next drive signal. Compared to the traditional mode of directly rendering based on the refresh rate, this application decouples the logical frame rate of the dynamic image from the physical screen refresh rate. By rendering on demand and intercepting invalid rendering requests, it avoids the accelerated playback and redundant resource consumption of high refresh rate screens, ultimately ensuring consistent and smooth playback speed of dynamic images on devices with different refresh rates, while reducing device power consumption and meeting the requirements of accurate frame-by-frame rendering and continuous smooth playback of dynamic images for cross-platform applications.

[0039] This application provides a dynamic image rendering method, relating to the field of digital creative industry technology. It can be applied to terminals, servers, or digital cultural product creation software running on either a terminal or server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or in-vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the dynamic image rendering method, but is not limited to the above forms.

[0040] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0041] Please see Figure 1 , Figure 2 These are two optional flowcharts of a dynamic image rendering method provided in the embodiments of this application. Figure 1 , Figure 2 The method may include, but is not limited to, steps S1000 to S2000: Step S1000: Obtain the frame delay of the dynamic image; In illustrative terms, when rendering and displaying a dynamic image on different display devices, this invention first extracts the frame delay of the dynamic image. The frame delay is the playback interval between two adjacent frames originally defined by the dynamic image itself, which is determined by the frame rate when the animation was created. For example, if the original frame rate of the animation is 10 FPS, the frame delay is 100 ms. It can be directly extracted by parsing the file header information and metadata of the dynamic image. This frame delay is the benchmark for subsequent rendering and does not change with the screen refresh rate of the playback device.

[0042] Understandably, whether it's a 60Hz standard refresh rate screen, a 120Hz high refresh rate screen, or a 90Hz mid-range refresh rate screen, all use the frame delay of the dynamic image itself as the basis for the rendering rhythm, avoiding the playback rhythm disorder caused by the difference in device refresh rates in traditional technologies.

[0043] Step S2000: Repeat the following signal response operation until the dynamic image is rendered: Step S2100: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Step S2200: Generate the current effective elapsed time difference based on the current timestamp, the historical rendering timestamp, and the historical rendering time error; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; Step S2300: When it is determined that the current effective elapsed time difference is not less than the frame delay, proceed to step S2310; Step S2310: Render the unrendered frame; Step S2320: Based on the current effective elapsed time difference, the frame delay, and the current rendering timestamp during this rendering, update the historical rendering timestamp and the historical rendering time error for the next execution of the signal response operation; Step S2400: When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the image rendering drive signal of the next round.

[0044] As an illustration, the image rendering drive signal can be generated by the vertical synchronization (VSync) module of the playback device, and its triggering period is matched with the screen refresh rate. For example, the drive signal triggering period for a 60Hz screen is 16.66ms, and the drive signal triggering period for a 120Hz screen is 8.33ms. However, in this embodiment of the invention, the drive signal is only used as a triggering node for the rendering process and does not directly determine whether a frame is rendered. The rendering determination is still dominated by the frame delay of the dynamic image itself.

[0045] The current timestamp can be collected via the device's system hardware clock with microsecond-level accuracy, ensuring the accuracy of timing calculations. The historical rendering timestamp, on the other hand, refers to the time reference after the previous rendering round was completed. The historical rendering time error is the difference between the effective elapsed time difference and the frame latency in the previous rendering round, used to offset time deviations in a single rendering round and avoid error accumulation. Understandably, after each rendering, the current rendering time error is recalculated and used as the historical rendering time error for the next rendering round.

[0046] Optionally, the generation of the initial time value includes: Upon first receiving the image rendering drive signal, the clock timestamp of the current system hardware is collected; The average of the trigger timestamp of the image rendering drive signal and the clock timestamp is used as the initial time value.

[0047] Indicatively, in this embodiment of the invention, the initial time value can be generated using the dual timestamp averaging method. That is, when the image rendering drive signal is received for the first time, the clock timestamp of the system hardware and the trigger timestamp of the drive signal are collected simultaneously, and the average of the two is used as the initial time value to avoid the initial timing reference offset caused by the single timestamp collection error. Optionally, the initial error value is configured to be 0ms by default. If there is a known initial timing deviation in the dynamic image, the initial error value can be manually entered through the parameter configuration interface to improve the initial calibration accuracy.

[0048] Steps S1000 to S2000 as shown in the embodiments of this application determine whether to render by using the frame delay of the dynamic image itself as the rendering benchmark and integrating the timing calculation logic of the current timestamp, the historical rendering timestamp, and the historical rendering time error. Rendering is only performed when the frame delay of the dynamic image itself is satisfied. This ensures that the playback rhythm of the dynamic image is consistent with the original definition on different refresh rate devices, avoiding issues of speeding up, slowing down, or stuttering. Furthermore, through the iterative update of the timing parameters, precise calibration of the rendering timing is achieved, offsetting the time deviation of a single round of rendering.

[0049] Furthermore, this invention, through the mechanism of updating the historical rendering timestamp in each round and the dynamic compensation for historical rendering time errors, can not only offset the time deviation caused by hardware response delay and system load fluctuation in a single round of rendering, but also effectively suppress the frame drift phenomenon caused by error accumulation. Even in scenarios where dynamic images are played continuously for a long time, it can maintain a stable frame interval, ensuring that the display duration of each frame is highly consistent with the original frame delay, thus guaranteeing the smoothness and continuity of playback and avoiding the timing disorder problem of increasingly off-track playback in traditional technologies.

[0050] Moreover, this invention does not require reliance on the native rendering interface of the playback device or playback platform or customized hardware development. It only needs to collect timestamps and calculate timing logic to adapt to terminal devices with different hardware architectures and different refresh rate specifications, thereby reducing the adaptation cost of cross-platform deployment of dynamic images. At the same time, it provides reliable technical support for the cross-terminal dissemination of digital cultural and creative content.

[0051] In some embodiments, this embodiment is a detailed refinement of the timing parameter update steps, which clarifies the update rules for historical rendering timestamps and historical rendering time errors, realizes rapid iteration of timing parameters, and ensures that the timing reference of each round of signal response operation accurately inherits the rendering results of the previous round.

[0052] In this embodiment, updating the historical rendering timestamp and the historical rendering time error for the next execution of the signal response operation based on the current effective elapsed time difference, the frame delay, and the current rendering timestamp during this rendering includes: Use the current rendering timestamp as the historical rendering timestamp for the next execution of the signal response operation; The time error between the current effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

[0053] In this embodiment of the invention, the following advantages or beneficial effects are achieved: the timing parameter update logic is simplified, and the historical rendering timestamp and historical rendering time error can be rapidly iterated without complex calculations, ensuring the real-time performance of timing calibration; this invention directly uses the deviation calculated in a single round of rendering as the error to be used in the next round, effectively offsetting the time fluctuations in the rendering process and avoiding the rendering rhythm shift caused by error accumulation.

[0054] For example, in a device scenario, the screen's physical refresh rate is 120Hz, so the interval between each round of image rendering drive signals (VSync signal) is approximately 8.3333ms; the animation frame latency is 100ms, which defines the switching after each frame is displayed for 100ms; initial state: historical rendering timestamp = 0ms, historical error = 0ms Since the embodiments of the present invention can calculate the time error of each rendering, the process from error generation to cancellation can be as follows: First, a 100ms delay is required to meet the rendering conditions. However, the screen triggers a signal every 8.33ms. At the 12th signal, the accumulated physical time is 99.96ms, less than 100ms. At the 13th signal, the accumulated physical time is 108.29ms, which is also the current effective elapsed time difference. Rendering will then be triggered. Therefore, the rendering timestamp for this instance is 108.29ms. The time error between the current effective elapsed time difference (108.29ms) and the frame delay (100ms) is: 108.29ms - 100ms = +8.29ms. This is recorded as an over-wait of 8.29ms. This 8.29ms can be used as the historical rendering time error for the next execution of the signal response operation. When the second rendering condition is met, due to the historical error of 8.29ms, the physical time only needs to wait 91.71ms. When the current timestamp is 200ms, the current effective elapsed time difference is: 200ms - 108.29ms + 8.29ms = 100ms. That is to say, at this time, the error is exactly 100ms, so the second rendering is triggered directly. The rendering error at this time is 100ms - 100ms = 0ms, so the previous 8.29ms rendering error can be canceled out. Therefore, the extra 8.29ms waited in the previous round can be reduced by 8.29ms in the next round, and the two cancel each other out, preventing them from accumulating.

[0055] Therefore, the embodiments of the present invention can make the excess error of each round become the compensation benchmark for the next round. The insufficient part of the physical time difference can be made up by the historical error, and finally the error is cyclically canceled, avoiding the rendering rhythm deviation caused by error accumulation, such as playing faster or slower, and ensuring that the total average playback rate strictly matches the original frame delay of the animation during long-term playback.

[0056] Please see Figure 3 In one implementation of this invention, step S2400 further includes, but is not limited to, the following gap stage processing steps: Step S2410: Continuously acquire real-time candidate timestamps; Step S2420: Each time a candidate timestamp is obtained, the candidate effective elapsed time difference is calculated based on the candidate timestamp, the historical rendering timestamp, and the historical rendering time error. Step S2430: When it is determined that the candidate effective elapsed time difference is not less than the frame delay, perform frame data preparation on the unrendered frame to obtain the frame to be rendered with completed frame data preparation, so that the frame to be rendered can be directly rendered when the image rendering drive signal of the next round is received. Step S2440: Use the candidate timestamp corresponding to the completion of frame data preparation as the historical rendering timestamp for the next execution of the signal response operation; The time error between the candidate effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

[0057] In illustrative terms, this embodiment also enables pre-preparation of frame data during the waiting phase when the current effective elapsed time difference is less than the frame delay. This invention can complete time-consuming operations such as uploading unrendered frames in advance while waiting for the next rendering drive signal, avoiding rendering stutters caused by insufficient data preparation when subsequent signals are triggered, and further improving playback smoothness.

[0058] For example, using a screen physical refresh rate of 120Hz, the interval of each round of image rendering drive signal (VSync signal) is approximately 8.3333ms, and the animation frame delay is 100ms.

[0059] Upon the 12th signal trigger, the current effective elapsed time difference is 99.96ms < 100ms, entering a waiting phase. At this time, this embodiment of the invention enters the gap monitoring phase, continuously monitoring the system clock in real time between 99.6ms and 108.29ms (the interval between the 12th and 13th VSync signals), and calculating the effective time in real time. Specifically, candidate timestamps are collected; when a candidate timestamp = 100.00ms, the candidate effective elapsed time difference = 100.00ms - 0ms + 0ms = 100.00ms ≥ 100ms. Trigger frame data preparation, perform upload and frame data preparation for the currently unrendered frame (frame 1), and add it to the queue of frames to be rendered so that when the 13th signal is triggered, frame 1 in the queue of frames to be rendered can be rendered directly without additional data preparation, thus shortening the rendering time.

[0060] At this point, the updated historical rendering timestamp is set to 100.00ms, and the historical rendering time error is 100.00ms - 100ms = 0ms. It's understandable that during the 13th signal trigger, not only will the first frame in the rendering queue be rendered directly, but the current effective elapsed time difference at the 13th signal trigger will also be calculated based on the updated historical rendering timestamp (100.00ms) and historical rendering time error (0ms) from the gap monitoring phase. For example, if the real-time system clock is 108.32ms, the updated historical rendering timestamp (100.00ms) and historical rendering time error (0ms) from the 12th signal trigger are retrieved. The current effective elapsed time difference at the 13th signal trigger is calculated as: 108.32 - 100.0 + 0 = 8.32ms < 100ms, which is considered substandard. The gap monitoring will then resume (e.g., 108.32ms ~ 116.65ms).

[0061] In this embodiment of the invention, the following advantages or beneficial effects are achieved: Traditional technology, after determining that the current effective elapsed time difference is less than the frame delay, simply waits for the next round of drive signal triggering, during which system resources are idle, and all frame data preparation is concentrated after the drive signal is triggered. However, frame data preparation for dynamic images often involves complex calculations and data transmission, especially for high-resolution, high-compression dynamic images, where decoding operations alone may take tens of milliseconds, causing rendering to be delayed until data preparation is complete after the drive signal is triggered, which can easily lead to rendering stuttering, uneven frame intervals, and other problems. This invention can utilize this idle gap to perform the time-consuming frame data preparation operation in advance. When the candidate effective elapsed time difference meets the standard, the entire process of frame data preparation is immediately triggered, so that the frame to be rendered is already in a ready state when the drive signal is triggered, achieving a fast response of rendering upon signal triggering.

[0062] Meanwhile, this invention synchronously updates timing parameters during the gap phase, breaking the limitation of traditional technology that only updates timing parameters when the drive signal is triggered. In traditional technology, the elapsed time during the gap phase is not included in timing calibration, resulting in timing parameters still being calculated based on static data from the previous trigger when the drive signal is triggered in the next round. This can easily lead to rendering judgment deviations due to accumulated time errors during the gap phase. However, this invention continuously collects candidate timestamps and calculates the candidate effective elapsed time difference in real time. While preparing frame data, it updates the corresponding candidate timestamps to the historical rendering timestamps for the next round, and updates the difference between the candidate effective elapsed time difference and the frame delay to the historical rendering time error. This allows the timing parameters to keep up with the real-time changes of the system clock, avoiding timing gaps and effectively suppressing frame drift caused by error accumulation. Even with long-term continuous playback, it can maintain a high degree of consistency between the frame interval and the original frame delay.

[0063] Therefore, since the system clock is still running while waiting for the next drive signal, waiting until the next drive signal arrives to prepare data would increase rendering time. This invention makes full use of the gap time between image rendering drive signals to complete frame data pre-preparation, bringing forward the time-consuming operation that was originally performed after the drive signal was triggered, greatly reducing the rendering time after the next drive signal is triggered, realizing rendering upon drive signal trigger, and improving the smoothness of dynamic image playback; at the same time, timing parameters are updated during the gap phase, ensuring the continuity of timing calibration, avoiding timing gaps during the gap phase, and further improving the accuracy of rendering timing.

[0064] Please see Figure 4 In one implementation of this invention, step S2100 further includes, but is not limited to, the following determination step for completed frame data operations: Step S2110: When the image rendering drive signal of the current round is received, determine whether there is a frame to be rendered that has completed frame data preparation; If yes, then render the frame to be rendered, and then proceed to step S2130 to obtain the current unrendered frame of the dynamic image. Step S2130: If not, directly obtain the current unrendered frame of the dynamic image.

[0065] Indicatively, this invention can be adapted to the above-mentioned gap frame pre-preparation design, clearly defining the rendering priority of frames to be rendered and unrendered frames, ensuring that pre-prepared frames to be rendered are rendered first. Specifically, upon receiving the image rendering drive signal for the current round, it first determines whether there is a frame to be rendered in the rendering buffer of the playback device that has completed frame data preparation, i.e., a frame prepared during the gap phase.

[0066] If there are frames to be rendered, the frames to be rendered are rendered directly first. After the rendering is completed, the current unrendered frames of the dynamic image are obtained from the frame sequence of the dynamic image in the playback order, in order to prepare for the next round of rendering or gap frames. If there is no frame to be rendered, the current unrendered frame of the dynamic image is obtained directly from the frame sequence of the dynamic image in the playback order, and the normal rendering determination process is executed.

[0067] For example, using the above scenario, the animation consists of 3 frames: frame 1, frame 2, and frame 3, with a frame delay of 100ms for each frame. When the 13th signal is triggered, the queue of frames to be rendered is [frame 1]. After rendering frame 1, it is removed from the queue, and frame 2 is obtained as the unrendered frame. Entering the waiting phase, if frame 2 completes data preparation, then the queue of frames to be rendered = [frame 2]; when the 25th signal is triggered, frame 2 is rendered, and frame 3 is obtained as an unrendered frame; then when the 37th signal is triggered, frame 3 is rendered, and the animation rendering is complete.

[0068] In this embodiment of the invention, the following advantages or beneficial effects are achieved: the invention ensures that the frames to be rendered are rendered in the original sequence order, avoiding frame backlog or disordered order, and ensuring that the playback logic is consistent with the animation definition; moreover, prepared frames can be directly triggered for display without repeated data preparation, shortening the rendering time of a single frame, and significantly improving smoothness, especially under high refresh rate screens. Therefore, while effectively reducing rendering latency, the invention can also ensure that the rendering order of frames is consistent with the original playback order, without frame skipping or garbled frames.

[0069] Please see Figure 5 In one implementation of this invention, step S2430 further includes, but is not limited to, the following rendering buffer data writing step: Step S2431: Allocate a corresponding rendering buffer for the unrendered frame; Step S2432: Determine the single-frame vertical synchronization period based on the screen refresh frequency corresponding to the image rendering drive signal; Step S2433: Divide the single-frame vertical synchronization cycle into a first half-frame timing stage and a second half-frame timing stage that are connected sequentially. Step S2434: Split the frame data of the unrendered frame into first half frame data and second half frame data; Step S2435: During the first half-frame timing phase, the first half-frame data is written to the rendering buffer; during the second half-frame timing phase, the second half-frame data is written to the rendering buffer. When it is detected that all the data of the second half of the frame has been written to the rendering buffer, the frame data preparation of the unrendered frame is completed.

[0070] As an illustration, this embodiment refines the frame data preparation process, which can write data in stages based on the vertical synchronization cycle to avoid data transmission and rendering operations conflicting in the same time window, resulting in data writing failure or rendering stutter, thus ensuring the stability and reliability of data preparation.

[0071] Specifically, the single-frame vertical synchronization period = 1000ms / screen refresh rate; for example, the single-frame vertical synchronization period corresponding to a 60Hz screen refresh rate is 16.6667ms, and the single-frame vertical synchronization period corresponding to a 90Hz screen refresh rate is 11.1111ms; then, the timing phases of the first half frame and the second half frame are divided equally into 11.1111ms durations. The frame data of the unrendered frame is divided equally according to the number of rows of pixels. For example, in a frame with 1080 rows of pixels, the first 540 rows are the data of the first half of the frame, and the last 540 rows are the data of the second half of the frame, so as to ensure that the amount of data in the two segments is roughly balanced. In the first half-frame timing phase, the writing of the first half-frame data is initiated, and the buffer synchronization is triggered after the writing is completed. In the second half-frame timing phase, the writing of the second half-frame data is initiated, and the buffer data is marked as ready after all data is written, thus completing the preparation of frame data for unrendered frames.

[0072] In this embodiment of the invention, the following advantages or beneficial effects are achieved: This invention, through staged writing, solves the rendering stuttering or data loss problems caused by one-time writing in traditional technologies. Traditional technologies, when writing the entire frame of data to the rendering buffer at once, easily cause excessively high peak values ​​of system bandwidth and GPU resource usage in a short period. This not only leads to data transmission delays, packet loss, or incomplete writing, but may also cause timing conflicts with screen refresh read operations, resulting in screen tearing, rendering stuttering, and other problems, severely affecting the smoothness of dynamic image playback. This invention, by precisely dividing the single-frame vertical synchronization cycle into the first and second half-frame timing stages, and equally dividing the frame data according to the number of pixel rows, avoids system resource congestion caused by excessive data transmission pressure in a single stage, and ensures that the data writing rhythm is precisely aligned with the hardware timing of screen line-by-line refresh. For example, when the screen scans the first half-frame area, the GPU synchronously completes the writing of the first half-frame data; when the screen scans the second half-frame area, the GPU synchronously completes the writing of the second half-frame data, eliminating timing conflicts between GPU writing and screen reading, avoiding screen tearing problems, and ensuring the integrity of visual presentation.

[0073] Meanwhile, the single-frame vertical synchronization cycle is dynamically calculated based on the current device's screen refresh rate. The timing stages of the first half-frame and the second half-frame are evenly divided according to the cycle, which makes the solution adaptable to terminal devices with different refresh rates such as 60Hz, 90Hz, and 120Hz without the need for additional customized adaptation logic, significantly improving cross-device compatibility.

[0074] Furthermore, based on the above-described rendering buffer writing process, the rendering buffer, which contains the first half-frame data and the second half-frame data, can be derived. The specific process of obtaining the current unrendered frame of the dynamic image each time the current round's image rendering drive signal is received may include: Upon receiving the image rendering drive signal for the current round, determine whether the rendering buffer has completed writing all the data for the first half of the frame and the second half of the frame. If so, the first half-frame data and the second half-frame data are rendered sequentially, and then the current unrendered frame of the dynamic image is obtained. If not, then directly obtain the current unrendered frame of the dynamic image.

[0075] As an illustration, this embodiment adds judgment logic to the write state of the rendering buffer. The purpose is to avoid triggering rendering when the data is not completely written, which would cause screen tearing, glitches and other abnormalities, and ensure rendering quality and visual effects.

[0076] In the embodiments of the present invention, the following advantages or beneficial effects are achieved: the present invention determines the rendering timing based on the data writing status, which can avoid abnormalities such as screen tearing or screen distortion, and ensure the visual experience of dynamic images during rendering; moreover, the status marking logic of the present invention is simple, easy to adapt to cross-platform, does not rely on system private interfaces, and further improves cross-device compatibility.

[0077] Please see Figure 6 In one implementation of this invention, step S2440 further includes, but is not limited to, the following time error compensation steps: Step S2441: The difference between the candidate effective elapsed time difference and the frame delay is taken as the time error to be compensated; Step S2442: Obtain the current rendering load rate; Step S2443: Based on the mapping relationship between the load rate and the compensation coefficient, extract the error compensation coefficient corresponding to the rendering load rate; Step S2444: Multiply the error compensation coefficient by the time error to be compensated to obtain the compensated time error value; Step S2445: Use the compensated time error value as the historical rendering time error when the signal response operation is executed next time.

[0078] As an illustration, this embodiment refines the update logic for historical rendering time errors. It can dynamically adjust the error compensation weight based on the current system rendering load rate, avoiding resource contention caused by full error compensation in high-load scenarios, and further improving the robustness of the solution.

[0079] For example, using the above scenario with a frame delay of 100ms, when the candidate effective elapsed time difference = 100.0004ms, the time error to be compensated = 100.0004ms - 100ms = +0.0004ms; The current rendering load rate is 45%, indicating a medium load. The compensation coefficient is 0.8. Therefore, the compensated time error is 0.8 × 0.0004 ms = 0.00032 ms. The time error for the next round of historical rendering is 0.00032 ms.

[0080] In the embodiments of the present invention, the following advantages or beneficial effects are achieved: During the dynamic image rendering process, the system load will fluctuate with the frame complexity and the state of multi-task concurrency; for example, in high-load scenarios, the fluctuation of hardware response latency and data transmission time will increase significantly. If full error compensation is still used, the instantaneous fluctuation error will be excessively amplified, leading to the accumulation of subsequent timing calculation deviations, causing rendering judgment to be falsely triggered or delayed, ultimately resulting in playback stuttering and uneven frame intervals.

[0081] This invention achieves dynamic adaptation of error compensation by mapping the rendering load rate to the compensation coefficient. It accurately matches the corresponding error compensation coefficient by acquiring the current system rendering load rate in real time. Optionally, under low load (load rate ≤ 30%), the compensation coefficient can be close to 1, such as 0.9-1.0, to quickly correct timing deviations and ensure calibration accuracy. Under medium load (30% < load rate ≤ 60%), the compensation coefficient is appropriately reduced, such as 0.7-0.8, to balance error correction and resource consumption and avoid resource contention caused by over-compensation. Under high load (load rate > 60%), the compensation coefficient is further reduced, such as 0.4-0.6, to attenuate the error compensation weight, spread out instantaneous fluctuation errors, and prevent random errors under high load from being amplified into persistent timing deviations, effectively alleviating system resource pressure.

[0082] In addition, the mapping relationship between load rate and compensation coefficient supports flexible configuration and can be customized according to the hardware performance or application scenario of different devices. For example, in the scenario of digital cultural and creative display, it can adapt to multiple platforms and multiple hardware architectures without modifying the core logic, which greatly reduces the adaptation cost of cross-device deployment.

[0083] In one embodiment, before repeatedly performing the signal response operation, the method further includes: When it is determined that the frame delay is less than the first preset delay threshold, the second preset delay threshold is used as the corrected frame delay; The corrected frame delay is used as the frame delay when performing the signal response operation; Wherein, the first preset delay threshold is less than the second preset delay threshold.

[0084] This embodiment illustrates that it provides correction logic for scenarios with illegal extremely short frame delays in the animated image metadata, such as frame delays of 0ms or 5ms. The purpose is to avoid abnormalities such as high-speed playback or screen flickering caused by excessively short frame delays, thereby improving rendering stability.

[0085] Optionally, the first preset delay threshold is 10ms, which can be used as a benchmark for judging illegal delays, and the second preset delay threshold is 100ms, which can be used as a correction benchmark and can be adjusted through configuration files to adapt to different scenarios.

[0086] In the embodiments of the present invention, the following advantages or beneficial effects are achieved: the present invention improves the stability of animated image playback by automatically identifying the original frame delay of the animated image and automatically filtering illegal extremely short delays, thereby avoiding abnormalities such as high-speed playback or screen flickering from the source.

[0087] In one embodiment, before repeatedly performing the signal response operation, the method further includes: Get the current battery level; When it is determined that the current battery level is less than a preset battery level threshold, an adjusted frame delay is generated based on the product of the frame delay and a preset ratio value; wherein, the preset ratio value is used to increase the frame delay. The adjusted frame delay is used as the frame delay when performing the signal response operation.

[0088] As an illustration, this embodiment provides dynamic frame latency adjustment logic for low-power scenarios. The purpose is to reduce the number of rendering operations by lengthening the frame latency and optimizing frame skipping. This not only saves power but also ensures that the visual experience is not degraded under high refresh rate screens. Optionally, the preset ratio value is greater than 1, and it can be adjusted through configuration files to adapt to different scenarios.

[0089] For example, a preset battery threshold of 20% and a preset ratio of 2 are used to lengthen frame latency.

[0090] The remaining power of the device is obtained in real time through the system power management interface. If the current remaining power is ≥20%, no adjustment is required, and the original frame delay or the corrected frame delay is used. If the current power is <20%, then the adjusted frame delay = frame delay × preset ratio value. For example, if the original frame delay is 100ms, then the adjusted frame delay = 200ms.

[0091] Understandably, since the ratio is 2, the adjusted frame delay corresponds to playing 1 frame and skipping 1 frame, ensuring that there is no obvious visual stuttering, and the human eye cannot perceive slight frame skipping under a high refresh rate screen.

[0092] In this embodiment of the invention, the following advantages or beneficial effects are achieved: In low-power scenarios, by increasing frame latency and combining it with frame-dropping processing, the rendering frequency and load are significantly reduced without causing slow-motion or stuttering, thus improving the battery life for dynamic image playback under low power conditions. Moreover, this invention does not sacrifice slow refresh rates to make users feel stuttered; instead, it performs frame-dropping, reducing the original frame to 1 / 2 or 1 / 3, resulting in a better visual experience on high refresh rate screens.

[0093] In one embodiment, taking the React Native cross-platform framework, an iOS system with a 120Hz screen refresh rate, and animated emojis (containing 30 frames with a raw frame latency of 100ms) as the scenario, this solution establishes a scheduler between the cross-platform framework layer and the native rendering layer to uniformly handle the rendering scheduling of all formats of animated images such as GIF and WebP. The scheduler construction rules and complete execution flow are as follows: The physical clock can be constructed by listening to the device's VSync vertical synchronization signal based on the iOS system's CADisplayLink, and obtaining the high-frequency physical refresh pulse corresponding to the 120Hz screen refresh rate. The single pulse interval is fixed at 8.3333ms, which serves as the physical triggering beat of the rendering process. A logic clock is constructed to parse the raw frame delay attribute (D_DELAY) from the metadata of the animated image file, which serves as the reference rate for animation playback and is completely decoupled from the device's physical refresh rate.

[0094] The scheduler uses an asynchronous decision mechanism and does not execute rendering directly with the physical refresh signal. Whenever the physical layer's VSync refresh signal is triggered, it obtains the system's high-precision nanosecond timestamp T_NOW in real time. The actual elapsed time is calculated using the following formula: T_DISTANCE = T_NOW - T_LAST_RENDER + T_ERROR; where T_LAST_RENDER is the timestamp of the previous frame's rendering, and T_ERROR is the rendering time error obtained during the rendering of the previous frame. When T_DISTANCE ≥ D_DELAY, the native client is allowed to execute the display operation for the next frame; otherwise, frame skipping is forcibly intercepted within the current physical refresh cycle. Based on the above decoupled scheduler architecture, the entire rendering process of dynamic images is carried out: First, the metadata of the dynamic image is parsed to obtain the original frame delay D_DELAY=100ms, which meets the legal threshold of ≥10ms and does not need to be corrected. The baseline frame delay of the logic layer is then determined to be 100ms. The scheduler receives the VSync signal from the physical layer for the first time, with a trigger timestamp of 1690000000000ns and a synchronization acquisition hardware clock timestamp of 1690000000100ns. The initial time value was calculated using the double timestamp averaging method: (1690000000000+1690000000100) / 2=1690000000050ns, and the initial historical rendering time error was 0ms. Next, the scheduler's signal response operation is executed cyclically as follows: the physical layer continuously outputs a 120Hz VSync signal, and the scheduler performs asynchronous frame determination round by round: For the 1st to 12th VSync signals, the calculated T_DISTANCE values ​​are 8.3333ms, 16.6666ms, ... 99.9996ms respectively. Since all of them are less than 100ms, the scheduler triggers frame skipping interception, enters the gap waiting stage, continuously collects candidate timestamps, and starts frame data pre-preparation. When the candidate timestamp = 1690000100050ns, and the corresponding effective elapsed time difference T_DISTANCE = 100.0000ms, the judgment condition is met. Then the scheduler releases the instruction, triggers the preparation of frame 1 data, writes it to the rendering buffer in stages, updates the historical rendering timestamp T_LAST_RENDER = 1690000100050ns, and the historical error T_ERROR = 0ms. For the 13th VSync signal, the scheduler detects that the queue of frames to be rendered is [frame 1], so it directly renders frame 1, sets frame 2 as a new unrendered frame, and calculates the actual elapsed time based on T_LAST_RENDER=1690000100050ns and T_ERROR=0ms.

[0095] During the process before the above execution, the scheduler will also detect the device's battery level. If the battery level is 18% and less than the threshold of 20%, the logic layer frame delay D_DELAY=100ms×2.0=200ms will be automatically adjusted, and subsequent frame-skipping scheduling will be performed at 200ms / frame. At the 25th VSync signal, T_DISTANCE = 200.0004ms, the rendering load rate is 40%, the compensation coefficient is 0.8, and the time error to be compensated is 0.0004ms. Therefore, the compensated time error value is 0.00032ms, which is updated to the historical rendering time error for the next round. Finally, the 30-frame animation was played at 100ms / frame under normal battery power, taking a total of 3.0 seconds. Under low battery power, it was played by skipping frames at 200ms / frame, taking a total of 6.0 seconds. This achieved playback without speed adjustment, stuttering, or error accumulation.

[0096] This embodiment uses the React Native framework, a 120Hz high refresh rate screen device, and GIF animation as the core scenarios for illustration. Those skilled in the art can flexibly adapt the technical solution of this invention to other cross-platform frameworks and other dynamic image formats such as WebP and APNG. All adaptations and adjustments based on the core technical ideas of this invention are within the protection scope of this invention.

[0097] In summary, this invention achieves decoupling and adaptive alignment between dynamic image rendering and screen refresh rate, and compared with traditional technologies, it has the following advantages: The core rendering criterion is the frame delay defined by the dynamic image itself, which is no longer directly bound to the screen refresh rate. This avoids the problem of speed-up / slow-down playback on devices with different refresh rates, and ensures that the playback speed of dynamic images such as GIF, WebP, and APNG is consistent with the original definition on multiple platforms such as iOS and Android and devices with different refresh rates. By combining the current timestamp, historical rendering timestamp, and historical rendering time error, dynamic iterative calibration of the rendering sequence is achieved, which offsets the time deviation of a single round of rendering, avoids the rendering rhythm shift caused by error accumulation, and ensures accurate rendering frame by frame. By utilizing the gaps in the image rendering drive signals to perform frame data pre-preparation, rendering is achieved immediately upon triggering the drive signal, reducing rendering latency. At the same time, by writing vertically synchronized frame-by-frame timing data to the rendering buffer, the screen tearing problem is solved, improving the visual experience. It integrates multiple adaptation methods such as load adaptation error compensation, abnormal frame delay correction, and low battery frame delay adjustment, ensuring the playback stability of dynamic images under complex scenarios such as high device load, abnormal frame data, and low battery, and improving the robustness of the method. The method in this application does not rely on the native rendering interface of a specific platform. It is implemented only through system-wide timestamp acquisition, rendering buffer operation, vertical synchronization signal invocation and other technologies. It can be directly integrated into various cross-platform applications and digital cultural and creative software, and is compatible with multiple platforms and multiple types of terminal devices.

[0098] Please see Figure 7 This application also provides a dynamic image rendering apparatus, which can implement the above-described dynamic image rendering method. The apparatus includes: The frame delay acquisition module 3001 is used to acquire the frame delay of a dynamic image; The dynamic image rendering module 3002 is used to repeatedly execute the following signal response operation until the dynamic image rendering is completed: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Based on the current timestamp, the historical rendering timestamp, and the historical rendering time error, a current effective elapsed time difference is generated; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; When it is determined that the current effective elapsed time difference is not less than the frame delay, the unrendered frame is rendered, and the historical rendering timestamp and the historical rendering time error are updated according to the current effective elapsed time difference, the frame delay and the current rendering timestamp at the time of this rendering. When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the next round of the image rendering drive signal.

[0099] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0100] It should be noted that the device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0101] Those skilled in the art will clearly understand that, for convenience and simplicity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0102] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned dynamic image rendering method. This electronic device can include any smart terminal such as a tablet computer or an in-vehicle computer.

[0103] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0104] Please see Figure 8 , Figure 8 The hardware structure of an electronic device 4000 according to another embodiment of the present invention is shown. The electronic device includes: The processor 4001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 4002 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 4002 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 4002 and is called and executed by the processor 4001 using the methods described in the embodiments of this application. The 4003 input / output interface is used to implement information input and output. The communication interface 4004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, Wi-Fi, Bluetooth, etc.). Bus 4005 transmits information between various components of the device (e.g., processor 4001, memory 4002, input / output interface 4003, and communication interface 4004); The processor 4001, memory 4002, input / output interface 4003 and communication interface 4004 are connected to each other within the device via bus 4005.

[0105] The above is an illustrative scheme of an electronic device according to this embodiment. It should be noted that the technical solution of this electronic device and the technical solution of the above-described dynamic image rendering method belong to the same concept. For details not described in detail in the technical solution of the electronic device, please refer to the description of the technical solution of the above-described dynamic image rendering method.

[0106] This invention also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the above-described dynamic image rendering method.

[0107] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0108] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information transmission medium.

[0109] The above provides a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.

Claims

1. A method of rendering a dynamic image, characterized by, The method includes: Obtain the frame delay of a dynamic image; Repeat the following signal response operation until the dynamic image is rendered: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Based on the current timestamp, the historical rendering timestamp, and the historical rendering time error, a current effective elapsed time difference is generated; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; When it is determined that the current effective elapsed time difference is not less than the frame delay, the unrendered frame is rendered, and the historical rendering timestamp and the historical rendering time error are updated according to the current effective elapsed time difference, the frame delay and the current rendering timestamp at the time of this rendering. When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the next round of the image rendering drive signal.

2. The method for rendering dynamic images according to claim 1, characterized in that, The step of updating the historical rendering timestamp and the historical rendering time error for the next execution of the signal response operation based on the current effective elapsed time difference, the frame delay, and the current rendering timestamp during this rendering includes: Use the current rendering timestamp as the historical rendering timestamp for the next execution of the signal response operation; The time error between the current effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

3. The method for rendering dynamic images according to claim 1, characterized in that, After determining that the current effective elapsed time difference is less than the frame delay, and before receiving the next round of the image rendering drive signal, the method further includes: Continuously acquire real-time candidate timestamps, and each time a candidate timestamp is acquired, calculate the candidate effective elapsed time difference based on the candidate timestamp, the historical rendering timestamp, and the historical rendering time error; When it is determined that the candidate effective elapsed time difference is not less than the frame delay, frame data preparation is performed on the unrendered frame to obtain the frame to be rendered with the frame data preparation completed, so that the frame to be rendered can be directly rendered when the image rendering drive signal of the next round is received. The candidate timestamp corresponding to the completion of frame data preparation will be used as the historical rendering timestamp for the next execution of the signal response operation. The time error between the candidate effective elapsed time difference and the frame delay is used as the historical rendering time error when the signal response operation is executed next time.

4. The method for rendering dynamic images according to claim 3, characterized in that, The step of obtaining the current unrendered frame of the dynamic image upon receiving the image rendering drive signal for the current round includes: Upon receiving the image rendering drive signal for the current round, determine whether there is a frame to be rendered that has completed frame data preparation; If so, render the frame to be rendered, and then obtain the current unrendered frame of the dynamic image; If not, then directly obtain the current unrendered frame of the dynamic image.

5. The method for rendering dynamic images according to claim 3, characterized in that, The step of preparing frame data for the unrendered frame includes: Allocate a corresponding rendering buffer for the unrendered frame; The single-frame vertical synchronization period is determined based on the screen refresh frequency corresponding to the image rendering drive signal. The single-frame vertical synchronization cycle is divided into a first half-frame timing stage and a second half-frame timing stage that are connected sequentially. The frame data of the unrendered frame is split into the first half frame data and the second half frame data; During the first half-frame timing phase, the first half-frame data is written to the rendering buffer; during the second half-frame timing phase, the second half-frame data is written to the rendering buffer. When it is detected that all the data of the second half of the frame has been written to the rendering buffer, the frame data preparation of the unrendered frame is completed.

6. The method for rendering dynamic images according to claim 5, characterized in that, The step of obtaining the current unrendered frame of the dynamic image upon receiving the image rendering drive signal for the current round includes: Upon receiving the image rendering drive signal for the current round, determine whether the rendering buffer has completed writing all the data for the first half of the frame and the second half of the frame. If so, the first half-frame data and the second half-frame data are rendered sequentially, and then the current unrendered frame of the dynamic image is obtained. If not, then directly obtain the current unrendered frame of the dynamic image.

7. The method for rendering dynamic images according to claim 3, characterized in that, The step of using the time error between the candidate effective elapsed time difference and the frame delay as the historical rendering time error for the next execution of the signal response operation includes: The difference between the candidate effective elapsed time difference and the frame delay is taken as the time error to be compensated. Get the current rendering load rate; Based on the mapping relationship between the load rate and the compensation coefficient, the error compensation coefficient corresponding to the rendering load rate is extracted; Multiply the error compensation coefficient by the time error to be compensated to obtain the compensated time error value; The compensated time error value is used as the historical rendering time error when the signal response operation is performed next time.

8. The method for rendering dynamic images according to claim 1, characterized in that, The generation of the initial time value includes: Upon first receiving the image rendering drive signal, the clock timestamp of the current system hardware is collected; The average of the trigger timestamp of the image rendering drive signal and the clock timestamp is used as the initial time value.

9. The method for rendering dynamic images according to claim 1, characterized in that, Before repeatedly performing the signal response operation, the method further includes: When it is determined that the frame delay is less than the first preset delay threshold, the second preset delay threshold is used as the corrected frame delay; The corrected frame delay is used as the frame delay when performing the signal response operation; Wherein, the first preset delay threshold is less than the second preset delay threshold.

10. The method for rendering dynamic images according to claim 1, characterized in that, Before repeatedly performing the signal response operation, the method further includes: Get current battery level; When it is determined that the current battery level is less than a preset battery level threshold, an adjusted frame delay is generated based on the product of the frame delay and a preset ratio value; wherein, the preset ratio value is used to increase the frame delay. The adjusted frame delay is used as the frame delay when performing the signal response operation.

11. A dynamic image rendering apparatus, characterized in that, The device includes: The frame delay acquisition module is used to acquire the frame delay of dynamic images; The dynamic image rendering module is used to repeatedly execute the following signal response operation until the dynamic image rendering is complete: Upon receiving the image rendering drive signal for the current round, obtain the current unrendered frame of the dynamic image and obtain the current timestamp; Based on the current timestamp, the historical rendering timestamp, and the historical rendering time error, a current effective elapsed time difference is generated; wherein, when the signal response operation is initially executed, the historical rendering timestamp is the initial time value, and the historical rendering time error is the initial error value; When it is determined that the current effective elapsed time difference is not less than the frame delay, the unrendered frame is rendered, and the historical rendering timestamp and the historical rendering time error are updated according to the current effective elapsed time difference, the frame delay and the current rendering timestamp at the time of this rendering. When it is determined that the current effective elapsed time difference is less than the frame delay, wait to receive the next round of the image rendering drive signal.

12. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement a dynamic image rendering method according to any one of claims 1 to 10.

13. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements a method for rendering a dynamic image according to any one of claims 1 to 10.