Frequency point control method, device, storage medium and program product

By canceling CPU frequency boosting after identifying the target frame where the application has started in the terminal device, the problem of large response latency after CPU frequency boosting is solved, thus meeting performance requirements and reducing power consumption, thereby improving the user experience.

WO2026237470A1PCT designated stage Publication Date: 2026-11-19HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2026/079984
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-05-13
Filing Date
2026-02-25
Publication Date
2026-11-19

AI Technical Summary

Technical Problem

Existing technologies, even after increasing CPU frequency in terminal devices, cannot meet the performance requirements of various application scenarios, resulting in large response latency and affecting user experience.

Method used

By identifying the target frame or canceling CPU frequency boosting after the frame, and using frequency point control methods to promptly disable CPU frequency boosting after application startup, resource waste and power consumption are reduced.

Benefits of technology

It effectively reduces the response latency of terminal devices, meets the performance requirements of different applications, improves user experience, and reduces power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026079984_19112026_PF_FP_ABST
    Figure CN2026079984_19112026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of terminals. Provided in the embodiments of the present application are a frequency point control method, a device, a storage medium and a program product. The method comprises: receiving a first operation; enabling a first mechanism on the basis of the first operation, the first mechanism being used for increasing a frequency point of a CPU; and disabling the first mechanism within a first target frame or a second target frame, wherein the second target frame is a frame after the first target frame, the frame length of the first target frame is greater than a first duration, the first duration is determined on the basis of a first frame rate, and the first frame rate is a frame rate within the first target frame or the second target frame. In this way, the frame length of the first target frame being greater than the first duration indicates that a process (for example, starting a first application) triggered and executed by the first operation within the first target frame is completely started, and in this case, the first mechanism can be canceled, thereby helping to satisfy performance requirements for starting various applications, and improving user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Frequency control methods, devices, storage media and software products

[0001] This application claims priority to Chinese patent application filed on May 13, 2025, with application number 202510615912.8 and entitled "Frequency control method, apparatus, storage medium and program product", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of terminal technology, and in particular to a frequency control method, device, storage medium, and program product. Background Technology

[0003] With the development of terminal technology, terminal devices support increasingly richer functions, and users have higher and higher demands for the response speed of terminal devices. In order to improve the user experience, in various scenarios such as launching applications, switching windows, or recognizing input events, terminal devices will increase the frequency of the central processing unit (CPU) (i.e., CPU overclocking). After the CPU frequency is increased, the CPU processing performance is improved, which can speed up the launch of applications, window switching, or response to input events.

[0004] However, such methods may still fail to meet the performance requirements of various application scenarios, leading to problems such as large response latency in terminal devices. Summary of the Invention

[0005] This application provides a frequency control method, device, storage medium, and program product, applied in the field of terminal technology. It can identify target frames in the scenario of launching applications. The target frame can indicate that the application has been launched successfully. The terminal device can cancel CPU frequency boosting at or after the target frame, which helps to meet the performance requirements of launching various applications, reduce the response latency of the terminal device, and thus improve the user experience.

[0006] In a first aspect, embodiments of this application propose a frequency control method applied to a terminal device, the terminal device including a CPU. The method includes: receiving a first operation; based on the first operation, enabling a first mechanism, the first mechanism being used to increase the CPU's frequency; and disabling the first mechanism in a first target frame or a second target frame, the second target frame being a frame following the first target frame; wherein the frame length of the first target frame is greater than a first duration, the first duration being determined based on a first frame rate, the first frame rate being the frame rate within the first target frame or the second target frame.

[0007] The first operation can be understood as an operation related to the first application, such as an operation to launch the first application or an operation to trigger the display of target content through the first application. In other words, the first operation can trigger the terminal device to execute a first process, which is related to the first application. For example, it can be a process to launch the first application or other processes.

[0008] It should be understood that the first target frame and the second target frame can be tail frames of the first type described below. The first application can be an application that, after startup, will not receive the next vertical synchronization (Vsync) signal for a relatively long period of time. The first application can be, for example, a system application, such as a gallery as shown in Figure 5. The second target frame is the frame following the first target frame, or it can be any other frame after the first target frame.

[0009] For example, the first target frame can be the b+3rd frame below; the second target frame can be a frame after the b+3rd frame, such as the b+4th frame.

[0010] The first mechanism can refer to a strategy or mechanism used during application startup to increase CPU frequency, such as the boost mechanism. Enabling the first mechanism can be understood as increasing CPU frequency. Disabling the first mechanism can be understood as canceling, not using, or stopping the use of the first mechanism, which can be referred to as canceling CPU frequency increase in the following text.

[0011] The first duration can be duration 1 (as mentioned below). The first duration can also be understood as P first target frame lengths, where the first target frame length is a frame length determined based on the first frame rate, and P is a positive number greater than 1. The first target frame length can be a frame length calculated based on the first frame rate, such as the first target frame length being the ratio of 1000 to the first frame rate. The first frame rate, for example, is frame rate 1 (as mentioned below), which can be the frame rate obtained within the first or second target frame. P can be a preset value, such as the empirical parameter 1 (as mentioned below), such as 70% × 20, or 14.

[0012] Furthermore, within the first frame to the first target frame after the first mechanism is enabled, the frame length of the i-th frame is less than or equal to P theoretical frame lengths. The theoretical frame length is determined based on the frame rate within the i-th or (i+1)-th frame. The i-th frame can be any frame from the first frame to the first target frame after the first mechanism is enabled; the i-th frame is not the first target frame. That is, normally, during the startup of the first application, the frame length of the i-th frame is less than or equal to P theoretical frame lengths. Therefore, a frame length greater than P first target frame lengths can also indicate that the first application has finished starting within the first target frame.

[0013] It should be understood that, when the first operation is used to launch the first application, a frame length greater than a first duration indicates that the first application may have already launched within the first target frame. It is understood that "the first application may have already launched within the first target frame" does not imply that the first target frame must be the last frame in the application's launch process, nor does it imply that the first target frame must be the first frame after the application has launched. Rather, it means that if the frame length of the first target frame is greater than the first duration, the first application has a high probability of having launched within the first target frame; therefore, the first target frame can be understood as a frame used to indicate the completion of the first application's launch.

[0014] In the frequency control method of this application, after the terminal device performs CPU frequency increase based on the first operation, the CPU frequency increase can be canceled in the first target frame or the second target frame after the first target frame. Since the frame length of the first target frame is greater than the first duration, the first target frame can indicate that the first process (such as starting the first application) has been completed.

[0015] Canceling CPU frequency boosting in the first target frame or the second target frame following it can provide sufficient resources for executing the first process (such as launching the first application), helping to meet the performance requirements of launching the first process. This helps reduce the latency of the terminal device executing the first process and improves the user experience.

[0016] In conjunction with the first aspect, in some possible implementations, the method further includes: receiving a second operation; enabling a first mechanism based on the second operation; and disabling the first mechanism in or after the third target frame; wherein the frame length of the first Q frames of the third target frame satisfies the following: the degree of dispersion is less than a preset degree, and Q is an integer greater than 1.

[0017] The second operation can be used to trigger the second process, which is related to the second application. For example, the second application can be launched, which is an application that refreshes frames at a stable frame rate after launch, such as a short video application; or the first content can be displayed through the second application, which is short video or other content that needs to refresh frames at a relatively stable frame rate.

[0018] The third target frame can be the second type of tail frame described below, such as the (d+n)th frame below. The preceding Q frames of the third target frame can be understood as a series of n consecutive frames below, where Q can be n. Q can be a preset value. For example, the preceding Q frames of the third target frame are frames d to (d+n-1)th frames below, which are a series of n consecutive frames. The content displayed in the preceding Q frames can be, for example, video, animation, motion effects, text that needs to be updated in real time, etc. That is, when displaying this content, the terminal device refreshes frames at a relatively stable frame rate, and the frame length of the preceding Q frames satisfies the following condition: the dispersion is less than or equal to the preset degree.

[0019] A dispersion level less than or equal to a preset level indicates that the frame lengths of the first Q frames are very similar, meaning the frame rate of the first Q frames is close to a fixed frame rate. In this case, it suggests that the second application may have already started successfully. The dispersion level can be represented by any parameter, and the preset level can be understood as a preset condition. A dispersion level less than or equal to a preset level may include, for example, a first parameter less than or equal to a first threshold, where the first parameter indicates the dispersion of the frame lengths of the first Q frames, and the first threshold is a preset value.

[0020] It's understandable that the third target frame isn't necessarily the last frame in the second application's startup process. Rather, it indicates that if the frame length of the Q frames preceding the third target frame satisfies the condition that the dispersion is less than or equal to a preset level, then the second application has likely already finished starting up within the third target frame. For example, if the second application has started displaying short videos or other content, then the third target frame can be understood as a frame indicating that the second application has finished starting up.

[0021] If a third target frame is detected, the first mechanism can be disabled at the third target frame to promptly cancel CPU frequency boosting, thus reducing the power consumption of the terminal device. Alternatively, if a third target frame is detected, CPU frequency boosting can be canceled in the frame following the third target frame, such as the next frame or the second frame, to reduce the occurrence of canceling CPU frequency boosting before the second application has finished starting.

[0022] In this way, the third target frame can be used to indicate that the second application has finished starting. Canceling the CPU frequency boost at or after the third target frame provides sufficient resources to start the second application, helping to meet its performance requirements. This helps reduce the latency of starting the second application on the terminal device and improves the user experience.

[0023] In conjunction with the first aspect, in some possible implementations, the method further includes: receiving a third operation; enabling the first mechanism based on the third operation; disabling the first mechanism in or after the fourth target frame; and ensuring that the terminal device does not call the rendering thread in the fourth target frame and the H frames preceding the fourth target frame, where H is a positive integer.

[0024] The third operation can be used to trigger the third process, which is related to the third application, such as launching the third application. The third application can be an application that may have multiple consecutive blank frames during the launch process, such as the social application shown in Figure 7. The terminal device not calling the rendering thread can also be the third application not calling the rendering thread. The fourth target frame can be the third type of tail frame mentioned below. The fourth target frame and the H frames preceding the fourth target frame can be consecutive m frames mentioned below, where H can be m-1, and H or H+1 can be preset values.

[0025] If a fourth target frame is detected, the first mechanism can be disabled at the fourth target frame to promptly cancel CPU frequency boosting, thus reducing the power consumption of the terminal device. Alternatively, if a fourth target frame is detected, CPU frequency boosting can be canceled in the frame following the fourth target frame, such as the next frame or the second frame, to reduce the occurrence of canceling CPU frequency boosting before the third application has finished starting.

[0026] Thus, the fact that the third application did not call the rendering thread in the fourth target frame and the H frames preceding it indicates that the terminal device did not update the displayed content. Therefore, the response latency of the terminal device has little impact on the user experience. As a result, the terminal device can cancel the CPU frequency increase, thereby reducing the power consumption of the terminal device without affecting the user experience.

[0027] In conjunction with the first aspect, in some possible implementations, the first frame rate is the frame rate within the first target frame; after the first target frame, the first mechanism is turned off, including: acquiring the K1th vertical synchronization signal, the K1th vertical synchronization signal corresponding to the first target frame; if the K1+1th vertical synchronization signal is not received within the first time period after acquiring the K1th vertical synchronization signal, the first mechanism is turned off within the first target frame.

[0028] In this context, the K1th vertical synchronization signal corresponding to the first target frame can also be understood as the K1th vertical synchronization signal triggering or triggering the display of the first target frame, etc. The K1th vertical synchronization signal is, for example, the (a+3)th Vsync signal described below, and the first target frame is, for example, the (b+3)th frame described below. The first frame rate is, for example, the frame rate within the (b+3)th frame, i.e., the frame rate of 1 obtained after receiving the (a+3)th Vsync signal. Alternatively, the K1th vertical synchronization signal is, for example, the (K-1)th Vsync signal described below. The first target frame is also the frame corresponding to the (K-1)th Vsync signal, such as the (G-1)th frame.

[0029] In this way, once the first target frame is determined, CPU frequency boosting can be canceled at the first target frame. This allows for timely cancellation of CPU frequency boosting after the first application is launched, thereby reducing the power consumption of the terminal device while meeting the performance requirements for launching the first application.

[0030] In conjunction with the first aspect, in some possible implementations, in the second target frame, disabling the first mechanism includes: acquiring the K1+1th vertical synchronization signal, the K1+1th vertical synchronization signal corresponding to the second target frame, the second target frame being the next frame after the first target frame; and disabling the first mechanism within the second target frame if the frame length of the first target frame is greater than the first duration.

[0031] In this context, the K1+1th vertical sync signal corresponding to the second target frame can also be understood as the K1+1th vertical sync signal triggering or triggering the display of the second target frame, etc. The K1+1th vertical sync signal is, for example, the (a+4th)th Vsync signal described below, and the second target frame is, for example, the (b+4th)th frame described below. Alternatively, the K1th vertical sync signal is, for example, the Kth Vsync signal described below. The second target frame is also the frame corresponding to the Kth Vsync signal, such as frame G.

[0032] In one scenario, the first frame rate is the frame rate acquired in real time, meaning it's the frame rate obtained after receiving the (K1+1)th vertical synchronization signal, similar to the frame rate 1 obtained after receiving the (a+4)th Vsync signal in the following text. Therefore, the first frame rate is the frame rate within the second target frame.

[0033] In another scenario, the first frame rate, which is the frame rate obtained after receiving the K1th vertical synchronization signal (as described below, the frame rate 1 obtained after receiving the (a+3)th Vsync signal), is the frame rate within the first target frame.

[0034] In this way, the first target frame can indicate that the first application has finished starting, and the second target frame after the first target frame cancels the CPU frequency increase, which can meet the performance requirements for starting the first application.

[0035] In conjunction with the first aspect, in some possible implementations, if the frame length of the first target frame is less than or equal to the first duration, it is determined whether the first Q frames of the second target frame satisfy the first condition; if the first Q frames of the second target frame satisfy the first condition, the first mechanism is turned off within the second target frame; wherein, the first condition includes: the average frame length of the first Q frames of the second target frame is less than S times the second target frame length, where S is greater than 1; and / or, the first parameter is less than or equal to the first threshold, the first parameter is used to represent the dispersion of the Q frame lengths, the Q frame lengths being the frame lengths of the first Q frames of the second target frame; the second target frame length is determined based on the second frame rate, where the second frame rate is the frame length of the second target frame.

[0036] Wherein, the frame length of the first target frame is less than or equal to P times the length of the first target frame, for example, as described below: in S902, it is determined that the G-th frame is not the tail frame of the first type. The determination of whether the first Q frames of the second target frame satisfy the first condition is similar to the implementation of S903, or similar to the determination of whether the d-th to the (d+n-1)-th frames satisfy condition 1 as described below.

[0037] For example, the second target frame can be the (d+n)th frame mentioned below, and the Q frames preceding the second target frame can be the n frames preceding the (d+n)th frame mentioned below, i.e., frames d to (d+n-1)th, where Q can be n mentioned below. In this case, the second target frame is similar to the third target frame mentioned above, and is equivalent to the second type of tail frame mentioned below.

[0038] The average frame length of the preceding Q frames of the second target frame can be the average period of n consecutive Vsync cycles as described below. S times the second target frame length can be the duration twice as described below. The second frame rate can be the frame rate twice as described below. The second target frame length can be 1000 / second frame rate. S can be an empirical constant of 2, such as 115%, etc.

[0039] Optionally, the first parameter can be parameter 1 below, such as one or more of the following calculated based on the frame length of the first Q frames of the second target frame: standard deviation, variance, coefficient of variation (CV), the difference between the maximum and minimum values, or mean absolute deviation. The first threshold can be threshold 1 below. The coefficient of variation can be the ratio of the standard deviation to the mean.

[0040] It is understandable that the frame length of the first target frame being less than or equal to the first duration can also be replaced with: receiving the K1+1th vertical synchronization signal within the first duration after acquiring the K1th vertical synchronization signal.

[0041] That is, if the K1+1th vertical synchronization signal is received within the first time period after the K1th vertical synchronization signal is acquired, it is determined whether the first Q frames of the second target frame satisfy the first condition; if the first Q frames of the second target frame satisfy the first condition, the first mechanism is turned off within the second target frame. This can also be understood as determining whether the first Q frames of the second target frame satisfy the first condition within the second target frame.

[0042] In this way, when it is determined that the current second target frame length is not the first type of tail frame, it is also possible to determine whether the second target frame length is the second type of tail frame based on whether the preceding Q frames of the second target frame meet the first condition. This facilitates the cancellation of CPU after the first application has finished starting, which helps to meet the performance requirements of starting the first application; and it also helps to successfully identify the tail frame and cancel CPU frequency increase in a timely manner, reducing resource waste.

[0043] In conjunction with the first aspect, in some possible implementations, after receiving the K1+1th vertical synchronization signal, the method further includes: if the terminal device does not call the rendering thread within the second target frame after determining the second target frame and the H frames preceding the second target frame, the first mechanism is turned off within the second target frame.

[0044] The K1+1th vertical synchronization signal is, for example, the e+m-1th Vsync signal mentioned below, or the Kth Vsync signal in Figure 9. The second target frame and the H frames preceding it can be consecutive m frames mentioned below. If the terminal device (i.e., the first application) does not call the rendering thread within the second target frame and the H frames preceding it, it indicates that the H+1 frame is a blank frame. The second target frame can be the third type of tail frame mentioned below, in which case the second target frame is similar to the fourth target frame mentioned above.

[0045] Thus, multiple consecutive blank frames indicate that an interface similar to Figure 7(b) may be displayed during application startup. Since the user will not perceive any lag in this case, the terminal device can disable CPU overclocking, reducing power consumption without negatively impacting the user experience.

[0046] In conjunction with the first aspect, in some possible implementations, disabling the first mechanism within the second target frame includes: updating a first counter when it is determined that the terminal device has not invoked the rendering thread within the second target frame; the first counter is used to record the number of consecutive frames in which the terminal device has not invoked the rendering thread; and disabling the first mechanism within the second target frame when the number recorded by the updated first counter is greater than or equal to H+1.

[0047] The second target frame can be frame G in Figure 9. Within the second target frame, the terminal device (first application) not calling the rendering thread can be defined as frame G being a blank frame (as stated below). The first counter can be counter 1 (as stated below). Updating the first counter can be, for example, incrementing the number of frames recorded by the first counter by 1. The number of frames is the total number of frames. The updated first counter recording a number greater than or equal to H+1 can be defined as follows: In S907, it is determined that the number of frames recorded by counter 1 is greater than or equal to m. H+1 can be m.

[0048] In this way, the terminal device can record the number of consecutive blank frames using a first counter. When it is determined based on the first counter that H+1 consecutive blank frames have appeared, CPU frequency increase can be canceled in a timely manner to reduce resource waste of the terminal device.

[0049] In conjunction with the first aspect, in some possible implementations, the first mechanism is enabled, including: increasing the CPU frequency from a first value to a second value; wherein the second value is a preset value, or the difference between the first value and the second value is a preset value.

[0050] The first value can be the CPU frequency before the overclock, and can be any value. The second value can be a preset value, such as the maximum value within the adjustable range of the CPU frequency. Alternatively, the difference between the first and second values ​​can be a preset value, that is, the first value is increased by a preset amount.

[0051] Optionally, the CPU may include at least one CPU core; increasing the CPU frequency from a first value to a second value includes: increasing at least one CPU core from a first value to a second value.

[0052] In other words, CPU frequency boosting can be achieved by increasing the frequency of all CPU cores.

[0053] Alternatively, the CPU frequency can be increased from a first value to a second value, including increasing the frequency of at least one CPU core from the first value to the second value.

[0054] That is, the CPU may include multiple CPU cores. Furthermore, the CPU frequency increase in this application can be achieved by raising the frequency of some CPU cores to a second value. These CPU cores may be, for example, CPU cores bound to a launched application, such as CPU cores bound to a first application, a second application, or a third application, in order to meet the performance requirements of application startup while minimizing the power consumption of the terminal device.

[0055] In conjunction with the first aspect, in some possible implementations, the first operation is used to launch the first application.

[0056] In other words, the frequency control method described above can be applied to scenarios involving application startup. This allows for meeting the performance requirements of different applications while minimizing the power consumption of the terminal device.

[0057] Secondly, embodiments of this application provide a frequency control device, which can be a terminal device, or a chip or chip system within the terminal device. The frequency control device may include a processing unit. When the frequency control device is a terminal device, the processing unit may be a processor. The frequency control device may also include a storage unit, which may be a memory. The storage unit stores instructions, and the processing unit executes the instructions stored in the storage unit to cause the terminal device to implement a frequency control method described in the first aspect or any possible implementation of the first aspect. When the frequency control device is a chip or chip system within the terminal device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit to cause the electronic device to implement a frequency control method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit within the chip (e.g., a register, cache, etc.), or a storage unit located outside the chip within the terminal device (e.g., a read-only memory, random access memory, etc.).

[0058] For example, the processing unit is configured to disable the first mechanism in a first target frame or a second target frame.

[0059] Thirdly, embodiments of this application provide a terminal device, including a processor and a memory, wherein the memory is used to store code instructions and the processor is used to run the code instructions to perform the method described in the first aspect or any possible implementation of the first aspect.

[0060] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program or instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof.

[0061] Fifthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.

[0062] Sixthly, this application provides a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.

[0063] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).

[0064] It should be understood that the second to sixth aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description

[0065] Figure 1 is a schematic diagram of a process of CPU frequency boosting during application startup;

[0066] Figure 2 is a schematic diagram of another process of CPU frequency boosting during application startup;

[0067] Figure 3 is a schematic diagram of the interaction process between the terminal device software and hardware provided in the embodiment of this application;

[0068] Figure 4 is a flowchart illustrating the method for AMS scene recognition provided in an embodiment of this application;

[0069] Figure 5 is a schematic diagram of the first type of tail frame provided in the embodiments of this application;

[0070] Figure 6 is a schematic diagram of the second type of tail frame provided in the embodiments of this application;

[0071] Figure 7 is a schematic diagram of the third type of tail frame provided in the embodiments of this application;

[0072] Figure 8 is a schematic diagram of the timing for identifying blank frames provided in an embodiment of this application;

[0073] Figure 9 is a flowchart illustrating the tail frame recognition method provided in an embodiment of this application;

[0074] Figure 10 is a flowchart illustrating the frequency control method provided in an embodiment of this application;

[0075] Figure 11 is a schematic block diagram of the hardware architecture of the terminal device provided in the embodiment of this application;

[0076] Figure 12 is a schematic block diagram of a frequency control device provided in an embodiment of this application. Detailed Implementation

[0077] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below:

[0078] 1. Application warm start, warm start, and cold start

[0079] A cold start refers to the method of launching an application that is not currently running. It can be understood as the process of restarting an application after it has either never run or been completely terminated. In a cold start, the application's process is not in memory and needs to be reloaded; moreover, all of the application's resources, data, and user interface (UI) need to be reinitialized. Compared to warm starts and hot starts, cold starts are slower.

[0080] A warm start refers to the method of launching an application that is running in the background. It can be understood as the process of reactivating (or bringing back to the foreground) an application that has already been running and switched to the background by the user. In a warm start, the application process remains in memory, only paused; and the application's state and data are usually retained in memory, so they do not need to be reloaded. Therefore, compared to a cold start, a warm start is faster.

[0081] A warm start refers to an application that was previously closed, but the device retains some of its state information and resources. In a warm start, the application needs to reinitialize some resources and state, but it doesn't need to load everything from scratch. The startup speed falls between that of a warm start and a cold start.

[0082] 2. Frame rate

[0083] It can refer to the speed at which an application generates (or draws) new frames, usually expressed in frames per second (FPS).

[0084] 3. Vertical synchronization (Vsync)

[0085] Vsync is a mechanism used to coordinate the refresh and graphics rendering of terminal devices, designed to prevent screen tearing. Screen tearing refers to the incomplete or inconsistent display of an image during the screen refresh process, usually caused by a mismatch between the display's and graphics rendering's frame rates. Vsync solves this problem by synchronizing these two processes.

[0086] The working principle of the Vsync mechanism can be summarized as follows:

[0087] Hardware such as the display controller or graphics processing unit (GPU) in a terminal device can periodically generate Vsync signals, which are typically synchronized with the display's refresh rate (e.g., 60 times per second corresponds to a 60Hz refresh rate). The Vsync signal is used to instruct the system to render and display the next frame.

[0088] After the terminal device sends out the Vsync signal, applications and image compositing services (such as surface flinger, SF) can receive the Vsync signal.

[0089] When an application receives the Vsync signal, it triggers the UI rendering process, drawing UI components from the interface to be displayed into a buffer. The Vsync signal also triggers the SF (Frame Controller) to read data from the buffer and composite it to obtain a final frame buffer. This frame buffer can contain the image data of the interface to be displayed. The display controller can read this frame buffer and display the image data from it on the screen. Thus, the terminal device can composite and display one frame of image data within one Vsync cycle.

[0090] It's understandable that the display screen of an electronic device is filled with physical pixels. For example, if each row of the screen contains A pixels and each column contains B pixels, then the resolution of the screen is A×B. Displaying A pixels in one row is called a row scan, and displaying B rows of pixels is called a field scan.

[0091] The display screen can scan a field of physical pixels in response to a vertical synchronization (Vsync) signal. Scanning a field of physical pixels allows the display screen to show one frame of image data. The display screen completes scanning the field of physical pixels within one Vsync signal cycle; that is, the display screen can show one frame of image data within one Vsync signal cycle. One Vsync signal cycle can also be called the field synchronization period.

[0092] 4. Frame buffer

[0093] The frame buffer is a memory area that stores image data (or pixel data). It typically consists of image data generated by the GPU or CPU. The frame buffer is usually located in the memory inside the system on chip (SOC), or it may be located in a separate video memory (such as GDDR5 or GDDR6) and managed by a separate GPU.

[0094] 5. Terminal equipment

[0095] The terminal devices in this application embodiment may include handheld devices, vehicle-mounted devices, etc., with CPU frequency control functions. For example, some electronic devices include: mobile phones, tablets, PDAs, laptops, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to wireless modems, in-vehicle devices, wearable devices, terminal devices in 5G networks, or future evolution of public land mobile communication networks. Terminal devices in a network (PLMN), etc., are not limited to this in the embodiments of this application.

[0096] By way of example and not limitation, in this embodiment, the electronic device can also be a wearable device. Wearable devices, also known as wearable smart devices, are a general term for devices that utilize wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothing or accessories. Wearable devices are not merely hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are feature-rich, large in size, and can achieve complete or partial functions without relying on a smartphone, such as smartwatches or smart glasses, as well as those that focus on a specific type of application function and require the use of other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

[0097] Furthermore, in this embodiment of the application, the electronic device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection.

[0098] The terminal device in this application embodiment may also be referred to as: electronic device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user equipment, etc.

[0099] In this embodiment, the electronic device or various network devices include a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on top of the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux, Unix, Android, iOS, or Windows. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0100] 6. Other terms

[0101] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first chip" and "second chip" are used only to distinguish different chips and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.

[0102] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0103] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.

[0104] With the development of terminal technology, terminal devices are becoming increasingly powerful, and users are demanding faster response times from them. Therefore, optimizing terminal device performance and improving response speed has received widespread attention.

[0105] CPU frequency is a crucial factor affecting the performance of terminal devices. CPU frequency, also known as CPU operating frequency, indicates the speed at which the CPU executes instructions. It is usually measured in Hertz (Hz), such as gigahertz (GHz). The CPU frequency determines the number of instructions the CPU can execute per unit of time, thus significantly impacting the performance of terminal devices. Generally, a higher CPU frequency results in better performance and faster response times for the terminal device; conversely, a lower CPU frequency leads to poorer performance and slower response times.

[0106] However, the higher the CPU frequency, the greater the power consumption of the terminal device. Therefore, in order to balance performance requirements and power consumption, the CPU frequency of the terminal device may change dynamically during operation.

[0107] For example, in some scenarios, the response speed of the terminal device may significantly affect the user experience. In these scenarios, the terminal device can run at a higher CPU frequency. These scenarios may include, but are not limited to, launching applications, switching windows (or transitions), and input events such as swiping or clicking.

[0108] When the terminal device recognizes or detects this part of the scene, it can increase the CPU frequency to make the terminal device respond faster in these scenes, such as quickly launching applications, quickly transitioning scenes, or quickly responding to input events, thereby improving the user experience.

[0109] It should be understood that increasing the CPU frequency can also be understood as CPU frequency boosting, CPU frequency increase, or increasing the CPU's operating frequency, which refers to increasing the CPU's operating frequency to the highest or higher value within its operating frequency range, so that applications can allocate more processing resources. Terminal devices can increase the CPU frequency to a preset range, preset level, preset value, or maximum value, or can increase the CPU frequency by a preset amount; this application does not specifically limit this. The following description uses CPU frequency boosting as an example.

[0110] Currently, the duration of CPU frequency boosting in terminal devices is usually a preset duration. Taking the scenario of launching an application as an example, when a terminal device cold-starts an application, the duration of CPU frequency boosting can be, for example, 1500ms. That is, regardless of the type of application launched by the terminal device, the duration of CPU frequency boosting during the cold start of that application is always 1500ms.

[0111] However, the time required to launch an application may vary depending on the application. Therefore, the preset duration of CPU frequency boost may not be sufficient to launch different applications.

[0112] Below, referring to Figures 1 and 2, and taking a cold start with a CPU frequency boost duration of 1500ms as an example, we will explain the process of CPU frequency boosting when starting application 1 and application 2.

[0113] Figure 1 is a schematic diagram of a CPU frequency increase process. As shown in Figure 1(a), at time t1, the terminal device starts application 1 and begins CPU frequency increase. The duration of the CPU frequency increase is set to 1500ms.

[0114] At time t2, which follows time t1, the terminal device has not yet canceled the CPU frequency increase, meaning that the interval from time t1 is less than 1500ms, and application 1 has finished starting.

[0115] At time t3, which follows time t2, the terminal device cancels the CPU frequency boost. The time interval between time t3 and time t1 is 1500ms. That is, after application 1 has finished starting, the terminal device still performs a CPU frequency boost for a period of time (from time t2 to time t3).

[0116] Correspondingly, referring to Figure 1(b), before time t1, the terminal device has not yet increased the CPU frequency, and the CPU frequency is at a relatively low level. Between time t1 and time t3, the terminal device increases the CPU frequency, resulting in a higher CPU frequency during this period. Since the terminal device cancels the CPU frequency increase at time t3, the CPU frequency returns to a relatively low level after time t3.

[0117] It's understandable that between time t1 and t3, the CPU frequency is at a high level, resulting in higher power consumption for the terminal device. For application 1, the time it takes to launch application 1 is less than the duration of the CPU frequency boost (1500ms). That is, application 1 has already started up by time t2, before time t3. However, between time t2 and t3, the terminal device is still in a state of CPU frequency boost, resulting in wasted resources and higher power consumption.

[0118] It's understandable that Application 1 could be an application with a short startup time, such as system applications like email, calendar, gallery, and SMS. For this type of application, the preset CPU frequency boost duration might be relatively long, potentially leading to resource waste.

[0119] Figure 2 illustrates another CPU frequency increase process. As shown in Figure 2(a), at time t4, the terminal device starts application 2 and begins CPU frequency increase. The duration of the CPU frequency increase set by the terminal device remains 1500ms.

[0120] At time t5, which follows time t4, the terminal device cancels the CPU frequency increase. The time interval between time t5 and time t4 is 1500ms.

[0121] At time t6, which follows time t5, application 1 completes startup. That is, the terminal device has already canceled the CPU frequency increase before application 2 completes startup.

[0122] Correspondingly, referring to Figure 2(b), before time t4, the CPU frequency is at a relatively low level; between time t4 and time t5, the terminal device increases the CPU frequency, causing the CPU frequency to be at a higher level during this period. Since the terminal device cancels the CPU frequency increase at time t5, the CPU frequency is at a relatively low level after time t5.

[0123] Since application 2 has not finished starting at time t5 and the terminal device has canceled the CPU frequency boost, the startup time (or latency) of application 2 is relatively long, and there may even be abnormalities such as lag, resulting in a poor user experience.

[0124] It's understandable that Application 2 could be an application with a longer startup time, such as a shopping app, a short video app, or other third-party applications. For this type of application, the preset CPU boost duration may be short, resulting in insufficient CPU resources provided by the terminal device to start the application, thus causing a longer startup time.

[0125] It is understood that the 1500ms shown in the embodiments of this application is merely an example, and the preset duration of CPU frequency boosting for the terminal device can be other durations. Furthermore, the preset duration of CPU frequency boosting may vary depending on the application's startup method. For example, when the startup method is a warm boot, the preset duration of CPU frequency boosting could be 600ms, etc. This application does not impose specific limitations in this regard.

[0126] It should be understood that Figures 1 and 2 are merely examples. In actual applications, when increasing CPU frequency, the CPU frequency may not be a fixed value; that is, the CPU frequency can change dynamically. For example, referring to Figure 1, the CPU frequency can change dynamically from time t1 to time t3. This application does not impose specific limitations on this.

[0127] Therefore, when a terminal device increases its CPU frequency for a preset duration in scenarios such as launching applications, it may cause resource waste and high power consumption for some applications. For other applications, it may not be able to provide sufficient CPU resources, resulting in longer response times or even stuttering and other abnormalities, leading to a poor user experience.

[0128] In view of this, this application provides a frequency control method. For a target scenario that requires CPU frequency increase, such as a scenario where an application is launched, the terminal device can identify the end frame (i.e., the tail frame) of the target scenario, such as the tail frame of the application launch, and the terminal device can cancel CPU frequency increase in the tail frame.

[0129] In this way, since the process of CPU frequency boosting has ended when the terminal device detects the end frame (e.g., the application has finished starting), the terminal device can cancel the CPU frequency boosting. Compared to CPU frequency boosting for a preset duration, canceling the CPU frequency boosting at the end frame allows for adaptive CPU frequency boosting based on the performance requirements of the target scenario. This reduces resource waste caused by excessively long CPU frequency boosting durations (as shown in Figure 1) and excessively long terminal device response times caused by excessively short CPU frequency boosting durations (as shown in Figure 2). It adapts to the CPU frequency boosting duration requirements under different circumstances, helping to balance power consumption and performance in different scenarios and improve user experience.

[0130] The frequency control method provided in this application will be described in detail below with reference to Figures 3 to 10, taking a terminal device as the execution subject as an example. The specific form and number of each device shown are merely examples and should not constitute any limitation on the implementation of the method provided in this application.

[0131] The terminal device in the embodiments of this application may be the terminal device itself, or a chip, chip system or processor that supports the terminal device to implement the frequency point control method, or a logic module or software that can implement all or part of the functions of the terminal device. This application does not impose specific limitations on this.

[0132] To facilitate understanding of this solution, the software architecture of the terminal device will first be explained with reference to Figure 3.

[0133] The software system of a terminal device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses a layered architecture system as an example to illustrate the software structure of a terminal device.

[0134] In some embodiments, the interaction process between the software architecture and hardware architecture of the terminal device can be as shown in Figure 3.

[0135] The software system of a terminal device can adopt a layered architecture, which divides the software and hardware into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the terminal device may include, for example, an application (APP) layer, an application framework (FWK) layer, an Android runtime and system libraries, a hardware abstraction layer (HAL), a kernel layer, and a hardware layer.

[0136] 1. Application Layer

[0137] An application may include a series of application packages. For example, the application layer may include system applications and third-party applications, etc.

[0138] System applications, such as those with a user identifier (UID) of 1000, can be applications pre-installed on the device by the device manufacturer or operating system developer, such as desktop launchers, file management, settings, calendar, email, and gallery. These applications can be understood as part of the operating system.

[0139] Third-party applications can be applications developed by independent developers or companies. Users can download and install these applications through app stores or other channels, and can also uninstall them as needed. Examples of third-party applications include social applications, game applications, short video applications, shopping applications, and browser applications.

[0140] As is understandable, each application in the application layer typically runs in its own process. A process is the basic unit by which the operating system allocates resources (such as memory, CPU time, etc.). A process can contain multiple threads (including logic threads, UI threads, and rendering threads, etc.).

[0141] The UI thread is the main thread of the application, used to handle the rendering of the interface and user interaction events (such as clicks and touches). UI updates and event handling can both be performed in this thread.

[0142] The rendering thread is a background thread used to handle UI drawing. The UI thread can call the rendering thread to draw the UI.

[0143] It can also be understood that, based on the interface, users can interact with the terminal device, such as triggering the terminal device to launch an application or switch windows (or transitions); they can also input events such as swiping and clicking into the terminal device. Therefore, through the interface provided by the application, the terminal device may be able to recognize any of the following scenarios: launching an application, switching windows, swiping or clicking, etc.

[0144] 2. Application Framework Layer

[0145] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0146] The application framework layer may include the Activity Manager Service (AMS) and the Window Manager Service (WMS), etc.

[0147] The Activity Manager can be used to launch activities and manage their lifecycles. It can also manage application launches. For example, in response to a user's input to the target application's icon on the desktop, such as clicking the icon, the launcher can invoke the Activity Manager to launch the target application's activity; alternatively, other applications can also invoke the Activity Manager to launch the target application's activity.

[0148] Furthermore, AMS can identify the application's package name, process identifier (PID), and context, including one or more of the following: launching the application, switching windows, and input events such as swiping or clicking. For example, when the terminal device launches application 3, AMS can identify the application 3's package name, PID, and the context in which the application is launched. When the terminal device is running application 3 in the foreground and the terminal device is switching windows within application 3, AMS can identify the application 3's package name, PID, and the context of the window switching. When the terminal device is running application 3 in the foreground and displaying the application 3's interface, and receiving user clicks or swipes, AMS can identify the application 3's package name, PID, and the context of the input events such as swiping or clicking.

[0149] It is understood that in this embodiment, launching an application and switching windows can also be triggered by input events such as swiping or clicking. In this case, the application launch scenario and the window switching scenario can be understood as multi-event scenarios. A multi-event scenario is either: launching an application + a swiping or clicking input event, or switching a window + a swiping or clicking input event. Therefore, launching an application can also be understood as launching an application + a swiping or clicking input event; similarly, switching a window can be understood as switching a window + a swiping or clicking input event.

[0150] Alternatively, AMS can identify the scenario in which the application is launched, and also identify the launch method of the application, such as cold start, warm start, or hot start.

[0151] It should be understood that the method by which AMS identifies the application's package name, PID, and scenario can be found in the description in Figure 4 below, which will not be elaborated here.

[0152] Furthermore, AMS can indicate the package name and context of the identified application to WMS. It is understood that the application's package name can be replaced with other information that identifies the application, such as the application's name, PID, etc., and this application does not impose any specific limitations on this.

[0153] WMS can be used to manage window applications. Furthermore, WMS can trigger end-frame recognition based on the scene indicated by AMS.

[0154] In the first scenario, AMS indicates one or more identified scenarios to WMS. That is, the terminal device may identify one scenario, such as an input event like a swipe or click; or, the terminal device may identify multiple scenarios, such as a click input event and launching an application (e.g., the multi-event scenario mentioned above). Regardless of whether AMS identifies one or multiple scenarios, AMS will indicate one or more scenarios to WMS.

[0155] In this case, WMS can trigger tail frame recognition based on one or more scenarios, including the target scenario.

[0156] In the second scenario, the AMS indicates to the WMS the first scenario out of one or more scenarios, which is the highest priority scenario among those scenarios. The one or more scenarios can be referred to the description in the first scenario. When one or more scenarios constitute a single scenario, the first scenario is that single scenario. When one or more scenarios constitute multiple scenarios, the first scenario is the highest priority scenario among those multiple scenarios.

[0157] Regarding priority, the terminal device can preset the priority ranking among multiple scenarios. For example, according to the order of priority from high to low, the ranking of multiple scenarios is: launching an application > switching windows > input events such as swiping or clicking.

[0158] It's understandable that in the ranking of multiple preset scenarios, a higher priority indicates that the scenario requires more CPU resources, meaning the CPU frequency increase needs to last longer. To ensure that the duration of the CPU frequency increase by the terminal device meets the performance (or CPU resource) requirements of these scenarios, thereby improving the terminal device's response speed, the terminal device prioritizes determining the duration of the CPU frequency increase based on the highest priority scenario. Therefore, AMS can indicate the highest priority scenario to WMS.

[0159] When the first scene is the target scene, WMS can trigger tail frame recognition.

[0160] It should be understood that the method for WMS to identify the tail frame can be referred to in the description of Figures 5 to 9 below, which will not be elaborated here.

[0161] When WMS detects the end frame, it can transmit a first instruction to the frequency modulation event management module in the system library. The first instruction is used to instruct the CPU frequency increase to be canceled.

[0162] 3. System libraries (native) and Android runtime

[0163] The system library can include multiple functional modules. For example, an image compositing service (Surface Flinger, SF), a 3D graphics processing library (e.g., OpenGL ES), and a frequency modulation event management module.

[0164] SF is Android's Display Compositing Service, responsible for managing all application layers. SF can combine the layers (or buffers) of one or more applications into a final frame; or, in other words, SF can read data from a buffer and composite the data in the buffer to obtain a final frame buffer, which caches the image data of the interface to be displayed.

[0165] The 3D graphics processing library can convert rendering instructions from the application into OpenGL commands, and then call the GPU through the GPU driver to execute the OpenGL commands so that the GPU can render the layers and obtain the rendered layers.

[0166] The frequency adjustment event management module can obtain the first instruction from WMS, and based on the first instruction, it can adjust the CPU frequency through the CPU frequency module, such as canceling CPU frequency increase.

[0167] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.

[0168] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0169] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0170] 4. The kernel layer is the layer between hardware and software. In an exemplary embodiment, the kernel layer includes a display driver, a graphics processing unit (GPU) driver, and a CPU frequency module.

[0171] The display driver can also obtain SF composite image data from the frame buffer and drive the display screen to display the image data based on the obtained image data.

[0172] The CPU frequency module, also known as the CPU frequency driver, CPU operating frequency driver, or CPUfreq driver, is used to manage and adjust the CPU frequency (or CPU operating frequency). For example, the CPU frequency module can increase the CPU frequency based on instructions from the AMS (Advanced Management System). It can also cancel CPU frequency increases based on instructions from the frequency adjustment event management module.

[0173] 5. The hardware layer includes the display screen, GPU, and CPU, etc.

[0174] The display screen can be used to display the interface.

[0175] It should be noted that the software architecture shown in Figure 3 is merely an example. The terminal device may also include more or fewer software modules; for example, the application layer may include applications such as maps, and the application framework layer may include package managers, etc. The software architecture shown in Figure 3 does not constitute a limitation on the embodiments of this application.

[0176] Based on the software architecture shown in Figure 3, the process of AMS identifying and instructing WMS on the scene will be explained in detail below with reference to Figure 4.

[0177] Figure 4 is a flowchart illustrating a method 400 for AMS scene recognition provided in an embodiment of this application. As shown in Figure 4, method 400 includes the following steps:

[0178] It is understandable that, based on the input operation that triggers the launch of application 3, such as clicking the application icon of application 3, the terminal device can launch application 3 through AMS, and S401 can be executed during the process of launching application 3 by AMS.

[0179] S401. If AMS determines that UI thread 1 calls the first method, AMS registers the scene recognition service for application 3. UI thread 1 is the main thread included in process 1 of application 3. The first method can be, for example, the performLaunchActivity method.

[0180] It should be understood that the `performLaunchActivity` method can be used to create an instance of an activity. UI thread 1 calls the first method, indicating that the terminal device is initializing and launching application 3. Therefore, during the phase (or timing) when UI thread 1 calls the first method, AMS can register the scene recognition service for application 3.

[0181] The scene recognition service of application 3 includes: recognizing scenes related to application 3, such as one or more of the following related to application 3: launching application 3, switching windows of application 3, or receiving input events such as swiping or clicking when displaying the interface of application 3.

[0182] It should also be understood that AMS can register the scene recognition service for application 3 during the cold start process of application 3. Subsequent warm or hot starts of application 3 do not require re-registration of the scene recognition service.

[0183] S402. After registering the scene recognition service of application 3, AMS determines whether the current timing is the first timing.

[0184] The first timing can be used to determine the current scenario as the application is launching. For example, the first timing could be when the terminal device begins to display the interface for launching application 3, such as when, in response to a user's input operation of clicking the application icon, the application icon enlarges on the screen and begins to display the relevant interface for application launch (e.g., when text, images, or animations during the application launch process begin to be displayed). At this point, the application has begun to launch, but has not yet completed the launch process.

[0185] For example, the first point in time can be the end of the Android App Startups process, which includes all the steps from when the user clicks the app icon to when the app is ready to interact with the user. Therefore, the end point of Android App Startups can be understood as the point at which the terminal device begins to display the interface of app 3.

[0186] It should be understood that the "first timing" is merely an example. In actual application scenarios, the "first timing" can also be replaced by any timing after AMS determines that the current scenario is the application startup. This application does not impose any specific limitations on this.

[0187] If AMS determines that the current timing is not the first timing, it will execute S402 repeatedly until it determines that the current timing is the first timing.

[0188] If AMS determines that the current timing is the first timing, it executes S403, which means that AMS indicates the package name of the first scenario and the first application to WMS.

[0189] It should be understood that AMS can execute S403 when the first opportunity is detected, regardless of whether the startup method is cold start, warm start, or hot start. Furthermore, when the terminal device starts application 3 using a warm start or hot start method, the difference between AMS's method for identifying the scenario and method 400 is that it does not include S401. This is because AMS had already registered the scenario identification service for application 3 during the previous cold start of application 3.

[0190] It should also be understood that since the first opportune moment can be the moment when the terminal device begins to display the interface for launching application 3, the terminal device has not yet finished launching application 3 before the first opportune moment. Therefore, AMS can indicate the first scene and the package name of application 3 to WMS at the first opportune moment, so that WMS can subsequently identify the tail frame in the target scene. Since the first opportune moment is a position or moment in the process of launching application 3, the first scene includes launching the application.

[0191] Optionally, the aforementioned first timing can be a scenario recognized by AMS, including the time when the application is launched, when AMS indicates the first scenario and package name to WMS. In other scenarios, such as when input events like swiping or clicking are recognized, AMS can indicate the first scenario and package name to WMS at other times. For example, if AMS recognizes a click event, then when AMS recognizes the click event, it indicates the first scenario and package name to WMS, where the first scenario includes the click event.

[0192] S404 and WMS use inter-process communication (IPC) to indicate the package name of the first scene and application 3 to the Choreographer class.

[0193] IPC can be used for inter-process communication, and the IPC mechanism can be, for example, the Binder mechanism. Since AMS and WMS belong to the system service process, and the Choreographer class runs in the process of application 3 and is a component used to coordinate threads in that process, WMS communicates with the Choreographer class through the IPC mechanism.

[0194] Furthermore, since the Choreographer class runs in process 1 of application 3, when the Choreographer class obtains the first scene and the package name of application 3, all threads in process 1 can obtain the first scene and the package name of the first application.

[0195] Thus, through method 400, WMS can determine the first scenario and the package name of application 3, and further determine that the current scenario includes launching application 3. Consequently, WMS can manage all windows displayed on the terminal device, which may include the window for application 3.

[0196] It should be understood that the embodiments in this application use WMS for tail frame recognition as an example. In actual application scenarios, other modules or threads can also perform tail frame recognition and instruct the frequency modulation event management module to cancel CPU frequency increase. For example, the package name of the first scene and application 3 can be obtained based on the Choreographer class. Since the Choreographer class runs in process 1 of application 3, the thread in process 1 can also obtain the package name of the first scene and application 3. Exemplarily, if the first scene includes a target scene (such as starting an application), sub-thread 1 in process 1 can trigger tail frame recognition. That is, based on the Choreographer class, the package name of the first scene and application 3 can be obtained, and sub-thread 1 can also determine the package name of the first scene and application 3, and thus perform tail frame recognition. In addition, when sub-thread 1 recognizes the tail frame, sub-thread 1 or the Choreographer class can instruct the frequency modulation event management module to cancel CPU frequency increase. This application does not specifically limit this.

[0197] The following section will take the target scenario as the starting application and WMS as the example to explain in detail how WMS identifies the end frame.

[0198] To more accurately identify the tail frame in a startup application, the tail frame can be divided into the following three types.

[0199] The first type of tail frame

[0200] It's understandable that for some types of applications, the interface might not change for a considerable period after startup. Therefore, using the Vsync mechanism, after WMS receives a Vsync signal, it determines if the time interval between receiving the previous Vsync signal and receiving it exceeds a certain threshold. If so, the current frame (the frame corresponding to that Vsync signal) is the last frame, indicating that the application may have finished starting.

[0201] Vsync is a mechanism used to coordinate the refresh and graphics rendering of terminal devices. The terminal device renders and displays one frame of image based on the Vsync signal. Therefore, WMS can identify the last frame based on the Vsync signal.

[0202] It should be noted that, in the embodiments of this application, the tail frame can be understood as the time when WMS identifies the cancellation of CPU frequency increase in the application startup scenario. The tail frame does not necessarily mean that it is the last frame of the application startup, but rather that the probability of the application having already started is relatively high at that tail frame. Therefore, WMS can instruct the frequency adjustment event management module to cancel CPU frequency increase at the tail frame. The tail frame can also be called the end frame, end timer, etc. This application does not specifically limit it in this regard.

[0203] Taking the gallery as an example, the process of launching the gallery on a terminal device can be shown in Figure 5.

[0204] When the terminal device displays the interface shown in Figure 5(a), the interface can be understood as a desktop, and the interface includes the gallery icon 501, and receives user input operations on the icon 501, such as click operations.

[0205] In response to user input on icon 501, the terminal device can launch the gallery, and after the gallery is launched, the terminal device can display the interface shown in Figure 5(b). The terminal device can continue to display the interface shown in Figure 5(b) until it receives a new input.

[0206] During the process of starting the gallery on the terminal device, some of the Vsync signals received by WMS can be seen in Figure 5(c).

[0207] After the terminal device receives the user's input operation on icon 501 and before displaying the interface shown in Figure 5(b), the Vsync signals received by the WMS may include: the a-th Vsync signal, the (a+1)-th Vsync signal, the (a+2)-th Vsync signal, and the (a+3)-th Vsync signal, where a can be a positive integer.

[0208] Each of these multiple Vsync signals can trigger the gallery to call the UI thread and the rendering thread to draw a frame of image data.

[0209] For example, based on the a-th Vsync signal, the gallery calls the UI thread and rendering thread to draw the UI components in the b-th frame image into a buffer. Based on the a-th Vsync signal, SF can read the data in the buffer and synthesize it to obtain a frame buffer. The frame buffer can include the image data of the b-th frame image to be displayed, where b can be a positive integer, and a and b can be the same or different. Based on the a-th Vsync signal, the image data can also be flushed to the display screen so that the terminal device can display the b-th frame image. Therefore, based on the a-th Vsync signal, the terminal device can display the b-th frame image. This can also be understood as the a-th Vsync signal triggering the display of the b-th frame image, with the a-th Vsync signal corresponding to the b-th frame image, or simply, the a-th Vsync signal corresponding to the b-th frame. For simplicity, this will not be elaborated further below.

[0210] And so on, the (a+1)th Vsync signal corresponds to the (b+1)th frame; the (a+2)th Vsync signal corresponds to the (b+2)th frame; the (a+3)th Vsync signal corresponds to the (b+3)th frame; and the (a+4)th Vsync signal corresponds to the (b+4)th frame.

[0211] Furthermore, the time interval between receiving two adjacent Vsync signals can be understood as a Vsync cycle. For example, the time interval between the a-th Vsync signal and the (a+1)-th Vsync signal can be called the a-th Vsync cycle, and based on the a-th Vsync signal, the terminal device can synthesize and display the b-th frame image within the a-th Vsync cycle. Similarly, the time interval between the (a+1)-th Vsync signal and the (a+2)-th Vsync signal can be called the (a+1)-th Vsync cycle, and the terminal device can synthesize and display the b+1-th frame image within the (a+1)-th Vsync cycle; the time interval between the (a+2)-th Vsync signal and the (a+3)-th Vsync signal can be called the (a+2)-th Vsync cycle, and the terminal device can synthesize and display the b+2-th frame image within the (a+2)-th Vsync cycle; the time interval between the (a+3)-th Vsync signal and the (a+4)-th Vsync signal can be called the (a+3)-th Vsync cycle, and the terminal device can synthesize and display the b+4-th frame image within the (a+3)-th Vsync cycle.

[0212] It is understandable that, referring to Figure 5, the (a+3)th Vsync signal corresponds to the (b+3)th frame. In the case where the (b+3)th frame is the interface shown in Figure 5(b), the gallery has already started when the terminal device displays the interface shown in Figure 5(b). Furthermore, the terminal device can continue displaying the interface until it receives a new input operation. Therefore, after the (a+3)th Vsync signal, the WMS may not receive the next Vsync signal (i.e., the (a+4)th Vsync signal) for a considerable period.

[0213] For example, after the (a+3)th Vsync signal, i.e., when displaying the interface shown in Figure 5(b), the terminal device may not receive user input for a relatively long period of time. In this case, the interface displayed by the terminal device will remain as shown in Figure 5(b) (the displayed information such as time and battery level may change). After a certain period, if the terminal device receives user input and the displayed interface changes, the WMS can receive the (a+4)th Vsync signal. The time interval between receiving the (a+4)th Vsync signal and receiving the (a+3)th Vsync signal may be greater than a certain threshold, such as the duration 1. Therefore, the (b+4)th frame corresponding to the (a+4)th Vsync signal can be understood as the tail frame.

[0214] Therefore, after receiving a Vsync signal, the WMS can determine whether the time interval between receiving the Vsync signal and receiving the previous Vsync signal is greater than or equal to a duration of 1. If the time interval is greater than or equal to a duration of 1, it indicates that the current frame corresponding to the Vsync signal is a type 1 tail frame, and the WMS can instruct the frequency modulation event management module to cancel CPU frequency increase. Alternatively, if the time interval is less than a duration of 1, it indicates that the current frame corresponding to the Vsync signal is not a type 1 tail frame.

[0215] In one possible implementation, the duration 1 can be a preset duration. For example, based on experience, during the application startup process, the Vsync cycle is usually no greater than or equal to a duration, which is duration 1.

[0216] In this way, WMS can easily determine the duration of 1.

[0217] In another possible implementation, duration 1 can be a duration determined by WMS based on the current frame rate (e.g., referred to as frame rate 1).

[0218] It is understandable that after triggering the tail frame recognition, the WMS can acquire the real-time frame rate once after receiving each Vsync signal. For example, the WMS can acquire a frame rate of 1 after receiving the (a+4)th Vsync signal.

[0219] It can also be understood that the Vsync cycle is usually synchronized with the frame rate. During the process of launching an application on a terminal device, the Vsync cycle usually does not exceed a duration of 1 determined based on the frame rate. Therefore, if the (a+3)th Vsync cycle is greater than or equal to the duration of 1, it indicates that the application may have already finished launching at the current moment. In this case, WMS identifies the current frame (the (b+4)th frame corresponding to the (a+4)th Vsync signal) as the first type of tail frame.

[0220] Optionally, duration 1 can be a duration determined based on frame rate 1 and empirical parameter 1.

[0221] Here, empirical parameter 1 can be a parameter preset based on experience. For example, duration 1, frame rate 1, and empirical parameter 1 satisfy the following formula: duration 1 = x1 × 1000 / fps1. Where fps1 is frame rate 1; 1000 / fps1 is the frame rate period (fps_period) calculated based on frame rate 1; and x1 is empirical parameter 1.

[0222] x1 can be a parameter preset based on experience. For example, based on experience, during application startup, with a fixed frame rate, the Vsync cycle usually does not exceed 70% of 20 frame rate cycles, so x1 can be 70% × 20 = 14. Or, it can also be understood as the Vsync cycle usually not exceeding 14 frame rate cycles during application startup.

[0223] It should be understood that since frame rate 1 is a real-time acquired frame rate, the accuracy of duration 1 determined by frame rate 1 and empirical parameter 1 is higher, and the accuracy of identifying the first type of tail frame based on duration 1 is higher.

[0224] Alternatively, the first type of tail frame can be determined in the following way.

[0225] For example, if the WMS receives a Vsync signal and does not receive the next Vsync signal within a duration of 1 or longer, the current frame corresponding to that Vsync signal can be a tail frame of the first type.

[0226] For example, after WMS receives a Vsync signal, it can start timer 1. The timing length of timer 1 is 1. If the next Vsync signal is received before timer 1 expires, it means that the current frame is not the first type of tail frame; if the next Vsync signal is not received after timer 1 expires, it means that the current frame is the first type of tail frame.

[0227] Referring to Figure 5(c), after the WMS receives the (a+3)th Vsync signal, it may not receive the next Vsync signal (i.e., the (a+4)th Vsync signal) within a duration of 1. Therefore, the (b+3)th frame corresponding to the (a+3)th Vsync signal is the first type of tail frame. The (b+3)th frame is, for example, the interface shown in Figure 5(b). Furthermore, the frame rate 1 used to calculate the duration of 1 can be obtained after receiving the (a+3)th Vsync signal.

[0228] In this way, WMS can determine that the current frame is a first-type tail frame when the Vsync period of the current frame is greater than or equal to the duration of 1. This enables WMS to efficiently identify the first-type tail frame and to promptly cancel CPU frequency boosting when the application has finished starting, helping to reduce resource waste and power consumption of the terminal device.

[0229] It is understood that after WMS recognizes the first type of tail frame, it can cancel the CPU frequency increase within the first type of tail frame; or, it can also cancel the CPU frequency increase in any frame after the first type of tail frame (such as the first or second frame after the first type of tail frame, etc.). This application does not make specific limitations on this.

[0230] The second type of tail frame

[0231] It is understandable that for some applications, once the application of this type is launched, the terminal device continuously refreshes frames according to a stable Vsync cycle.

[0232] For example, in short video applications, short videos can be played after the application starts. During video playback, the terminal device typically refreshes the screen continuously at a stable Vsync cycle. This stable Vsync cycle can be understood as multiple consecutive Vsync cycles approaching a certain value. Therefore, combined with the Vsync mechanism, when the Vsync cycles corresponding to multiple consecutive frames approach a certain value, it indicates that this type of application may have finished starting. WMS can then identify the current frame as a second type of end frame.

[0233] It should be understood that in this application, short videos are not used to limit the duration of videos. Short videos can be understood as videos played through short video applications. This application does not make specific limitations on the duration, format, etc. of short videos.

[0234] Taking short video applications as an example, the process of launching a short video application can be shown in Figure 6.

[0235] When the terminal device displays the interface shown in Figure 6(a), the interface can be understood as a desktop, and the interface includes an icon 601 for short video applications, and receives user input operations on the icon 601, such as click operations.

[0236] In response to the user's input on icon 601, the terminal device can launch a short video application, and after the short video application is launched, the terminal device can display the interface shown in Figure 6(b). This interface can be understood as the interface for the terminal device to play short videos through the short video application. That is, after the short video application is launched, the terminal device can play short videos.

[0237] It's understandable that the Vsync period can vary significantly during the startup process of short video applications, i.e., before the short video starts playing. During short video playback, the Vsync period may vary less, for example, stabilizing at a relatively short Vsync period, allowing the terminal device to play the short video smoothly.

[0238] For example, referring to (c) in Figure 6, assume that before the WMS receives the c-th Vsync signal, the terminal device is in the stage of launching a short video application; after receiving the c-th Vsync signal, the terminal device starts playing the short video. Therefore, after the c-th Vsync signal, the Vsync period stabilizes at a relatively small Vsync period, where c can be a positive integer.

[0239] It can be understood that in Figure 6(c), the period between the WMS receiving the c-th Vsync signal and receiving the (c+n)-th Vsync signal can be considered the stage where the terminal device plays a short video. Therefore, the c-th Vsync cycle to the (c+n-1)-th Vsync cycle may all be close to a relatively small Vsync cycle. The c-th Vsync cycle to the (c+n-1)-th Vsync cycle consists of n consecutive Vsync cycles or n consecutive frames, where n can be an integer greater than 1.

[0240] Therefore, after receiving the (c+n)th Vsync signal, the WMS determines that if condition 1 is satisfied for n consecutive Vsync cycles, the current frame (the (d+n)th frame corresponding to the (c+n)th Vsync signal) is a second type of tail frame. Condition 1 can be used to indicate that n consecutive Vsync cycles are stable within a relatively small Vsync cycle. d can be a positive integer, and d and c can be the same or different.

[0241] For example, condition 1 may include: parameter 1, determined based on n consecutive Vsync cycles, is less than or equal to threshold 1; and / or, the average period of n consecutive Vsync cycles is less than or equal to duration 2.

[0242] Parameter 1 indicates the dispersion and / or distribution characteristics of n consecutive Vsync cycles, and may include one or more of the following: standard deviation, variance, coefficient of variation, difference between maximum and minimum values, or mean absolute deviation. When parameter 1 includes multiple of these parameters, threshold 1 may also include multiple thresholds, each corresponding to one of the parameters. Threshold 1 can be a preset value.

[0243] It should be understood that an average period less than or equal to a duration of 2 can indicate that n consecutive Vsync periods are stable at a relatively low Vsync period.

[0244] In one possible implementation, duration 2 can be a preset duration. For example, based on experience, after launching a short video application, during the playback of a short video, the Vsync cycle is usually no greater than or equal to one duration, which is duration 2.

[0245] In this way, WMS can easily determine the duration of 2.

[0246] In another possible implementation, duration 2 can be a duration determined by WMS based on the current frame rate (e.g., referred to as frame rate 2).

[0247] It is understandable that after triggering tail frame recognition, the WMS can acquire the real-time frame rate once after receiving each Vsync signal. For example, the WMS can acquire the frame rate 2 after receiving the (c+n)th Vsync signal.

[0248] Optionally, duration 2 can be a duration determined based on frame rate 2 and empirical parameter 2. Empirical parameter 2 can be a parameter preset based on experience. For example, duration 2, frame rate 2, and empirical parameter 2 satisfy the following formula: duration 2 = x2 × 1000 / fps2. Where fps2 is frame rate 2; 1000 / fps2 is the frame rate period (fps_period) calculated based on frame rate 2; and x2 is empirical parameter 2.

[0249] x2 can be a parameter preset based on experience. For example, based on experience, the Vsync period is usually relatively stable during the playback of short videos, and when the frame rate is fixed, the Vsync period is usually less than and close to 115% of the frame rate period, so x2 can be 115%.

[0250] In addition, n can be a preset positive integer, such as 20. If WMS determines that condition 1 is satisfied for n consecutive Vsync cycles, it means that the short video application may have started and is playing a short video. In this case, WMS can determine that the current frame (i.e., the frame corresponding to the (n+c)th Vsync signal) is the last frame.

[0251] It should be understood that since frame rate 2 is a real-time acquired frame rate, the accuracy of duration 2 determined by frame rate 2 and empirical parameter 2 is higher, and the accuracy of the second type of tail frame identified based on duration 2 is higher.

[0252] The third type of end frame

[0253] It's understandable that during application runtime or startup, there might be multiple consecutive frames where only the logic thread is invoked, without calling the rendering thread. These frames can be called blank frames. In other words, a blank frame can be understood as a frame where the rendering thread is not invoked. For blank frames, since the rendering thread is not invoked, no buffer is generated; SF (Synchronizer) also does not retrieve data from the buffer for compositing. This results in no change to the interface displayed on the terminal device, and the user will not perceive any lag. Therefore, in this situation, the terminal device can also disable CPU frequency increases. This reduces the terminal device's power consumption without affecting the user experience.

[0254] Therefore, when WMS detects multiple consecutive blank frames, it can determine that the current frame is the last frame.

[0255] For example, some applications, such as banking apps, social networking apps, or game apps, may display a pop-up window during startup to prompt the user to log in with their account and / or password. When displaying this pop-up, the application may continuously call the logic thread for multiple frames without calling the rendering thread.

[0256] Referring to Figure 7, the interface shown in Figure 7(a) can be understood as a desktop, and the icon 701 displayed on the interface is the icon of a social application.

[0257] When the terminal device displays the interface shown in Figure 7(a), it receives input operations from the user on icon 701, such as a click operation.

[0258] In response to the user's input on icon 701, the terminal device can launch a social networking application and display the interface shown in Figure 7(b). This interface includes a pop-up window 702 through which the user can enter a password.

[0259] When pop-up window 702 is displayed on the terminal device, multiple consecutive blank frames may appear.

[0260] During the process of launching social applications on a terminal device, some of the Vsync signals received by WMS can be seen in Figure 7(c).

[0261] Before receiving the e-th Vsync signal, the terminal device is in the stage of launching a social application, and the social application can call the UI thread and rendering thread to draw image data. After receiving the e-th Vsync signal, the terminal device displays pop-up window 702. Therefore, after the e-th Vsync signal, WMS can determine that several consecutive frames are blank frames. That is, between the e-th Vsync signal and the (e+m)-th Vsync signal, the m frames are all blank frames. These m frames are the f-th to (f+m-1)-th frames. Here, e and m can be positive integers.

[0262] Taking frame f as an example, WMS can identify blank frames in the following way.

[0263] As can be understood from Figure 8, each frame can include two stages: the doFrame stage (execute frame logic) and the drawFrame stage (render frame). The doFrame stage can be understood as the stage where logic updates are performed within a frame. That is, the application can call the logic thread to update the internal state. The drawFrame stage typically occurs after the doFrame stage and can be understood as the stage where rendering takes place within a frame. For each frame, at the end of the doFrame stage, as shown at time t1 in Figure 8, the application can wake up the drawFrame stage (triggering entry into the drawFrame stage), such as by waking up the rendering thread.

[0264] For blank frames, the application will not wake up the DrawFrame phase at the end of the doFrame phase. Therefore, within frame f, WMS can determine at the end of the doFrame phase whether the DrawFrame phase has been woken up, such as whether the rendering thread has been woken up. If the DrawFrame phase has not been woken up, WMS can determine that frame f is a blank frame, meaning that no rendering thread has been scheduled within frame f. Furthermore, if the DrawFrame phase has been woken up, WMS can determine that frame f is not a blank frame, meaning that a rendering thread has been scheduled within frame f. Here, f can be a positive integer, and f and e can be the same or different.

[0265] It should be understood that for other frames, WMS can determine whether each frame is a blank frame in the same way as described above. For the sake of simplicity, it will not be elaborated on here.

[0266] After the WMS receives the (e+m+1)th Vsync signal, if the WMS determines that the previous m frames are all blank frames, that is, frames f to f+m-1 are all blank frames, then the WMS can determine that the current frame (i.e., the f+m frame corresponding to the (e+m)th Vsync signal) is a third type of tail frame. Alternatively, after the WMS receives the (e+m-1)th Vsync signal, if the WMS determines that the previous m-1 frames (frames f to f+m-2) and the current frame (f+m-1) are all blank frames, then the WMS can determine that the current frame (i.e., the f+m-1 frame corresponding to the (e+m-1)th Vsync signal) is a third type of tail frame.

[0267] It is understandable that m can be a preset value. A series of m blank frames indicates that an interface similar to Figure 7(b) may be displayed during application startup. Since the user will not perceive any lag in this case, the WMS can instruct the frequency modulation event management module to cancel CPU frequency boosting, thereby reducing the power consumption of the terminal device without causing a poor user experience.

[0268] It should be understood that the application launch methods shown in Figures 5 to 7 are merely examples, and terminal devices can also launch applications in other ways, which are not specifically limited in this application.

[0269] Based on the three types of tail frames shown above, WMS can identify tail frames during application startup according to the following process.

[0270] Understandably, since WMS cannot determine which type of end frame the current frame might be, during the end frame identification process, WMS may need to identify whether the current frame is a first type, a second type, and a third type of end frame. Specifically, as follows.

[0271] Figure 9 is a flowchart illustrating a tail frame recognition method 900 provided in an embodiment of this application. Method 900 can be executed by a WMS. As shown in Figure 9, method 900 includes the following steps:

[0272] S901 and WMS received the Kth Vsync signal.

[0273] Where K can be a positive integer, and the Kth Vsync signal can be understood as the Kth Vsync signal received after WMS triggers tail frame recognition.

[0274] S902, WMS determines whether the time interval between receiving the Kth Vsync signal and receiving the (K-1)th Vsync signal is greater than or equal to duration 1.

[0275] The time interval between the Kth Vsync signal and the receiving of the (K-1)th Vsync signal can also be understood as the Kth Vsync cycle.

[0276] Furthermore, K can be an integer greater than 1. That is, after WMS triggers tail frame recognition, S902 may not be executed after receiving the first Vsync signal.

[0277] It should be understood that, under normal circumstances, the application has not yet finished starting after the WMS receives the first Vsync signal, so the WMS may not execute S902, thus reducing the power consumption of the terminal device.

[0278] It should also be understood that the method for determining duration 1 can be found in the description of the first type of tail frame above, and will not be repeated here.

[0279] If the duration of the Kth Vsync cycle is greater than or equal to 1, it indicates that the current frame is the tail frame of the first type. The current frame is the frame corresponding to the Kth Vsync signal, such as the Gth frame.

[0280] If the Kth Vsync cycle is less than 1 in duration, it means that the application may not have finished starting. That is, the current frame (the Gth frame) is not the first type of tail frame, and WMS can execute S903.

[0281] Alternatively, S901 in the above text can also be replaced with: WMS receives the (K-1)th Vsync signal.

[0282] Furthermore, S902 can also be replaced with: If the WMS does not receive the Kth Vsync signal within a duration of 1 after receiving the K-1th Vsync signal, it indicates that the current frame is the tail frame of the first type. The current frame is the frame corresponding to the K-1th Vsync signal, such as the G-1th frame.

[0283] If the WMS receives the Kth Vsync signal within a time interval of 1 after receiving the (K-1)th Vsync signal, then the WMS can execute S903.

[0284] S903 and WMS determine whether the first n frames meet condition 1.

[0285] S903 can be understood as a step used to identify the second type of tail frame. n can be a preset value, or the number of frame windows, the number of frames, etc. The first n frames can be the n frames preceding the Kth Vsync signal, and these n frames are consecutive. The first n frames can also be replaced by n consecutive Vsync cycles.

[0286] Therefore, K can be an integer greater than or equal to n. That is, when K is less than n, the application has typically not yet finished starting, so WMS can skip S903 and receive the (K+1)th Vsync signal. This helps reduce the power consumption of the terminal device.

[0287] It should be understood that condition 1 can be interpreted as a condition indicating that the n consecutive Vsync cycles of the preceding n frames stabilize to a smaller value. Refer to the description in the second type of tail frame; it will not be repeated here.

[0288] If condition 1 is satisfied in the previous n frames, the current frame (the Gth frame) is a tail frame of the second type, that is, the Gth frame is the tail frame.

[0289] If condition 1 is not met in the first n frames, it means that the current frame is not the second type of tail frame, and the WMS can receive the (K+1)th Vsync signal.

[0290] S901 to S903 can be understood as the process by which the WMS identifies whether the current frame (frame G) is a type 1 or type 2 end frame. In addition to identifying whether the current frame (frame G) is a type 1 or type 2 end frame, after the WMS receives the Kth Vsync signal, it can also simultaneously execute S904 to S907 to identify whether the current frame (frame G) is a type 3 end frame. The details are as follows.

[0291] S904, WMS determines whether the Gth frame (current frame) corresponding to the Kth Vsync signal is a blank frame.

[0292] It should be understood that the implementation of S904 is similar to the method of identifying whether the f-th frame is a blank frame as described above, and can be referred to the description above, which will not be repeated here.

[0293] If frame G is not a blank frame, WMS can execute S905, which resets counter 1. For example, it sets counter 1 to its initial value.

[0294] It should be understood that counter 1 is used to record the number of consecutive blank frames. The initial value can be the value set for counter 1 when no blank frames have appeared, such as 0. This way, when a blank frame subsequently appears, WMS can update counter 1, such as by incrementing the count recorded by the counter, to accurately record the number of consecutive blank frames.

[0295] Since frame G is not a blank frame, the WMS sets counter 1 to its initial value to re-record the number of consecutive blank frames. It can be understood that for frame G-1, which may be a blank frame, the frame count recorded by counter 1 before the WMS executes S905 is not the initial value; or, frame G-1 may not be a blank frame, so the frame count recorded by counter 1 before the WMS executes S905 may be the initial value, and the WMS may not need to execute S905. This application does not specifically limit this.

[0296] It should also be understood that if the Gth frame is not a blank frame, it means that the current frame (the Gth frame) is not the third type of tail frame. Therefore, after S905, WMS can wait for the arrival of the K+1th Vsync signal.

[0297] If frame G is a blank frame, WMS executes S906, and WMS updates the frame number recorded by counter 1, for example, by incrementing the frame number recorded by counter 1 to obtain the updated frame number.

[0298] S907, WMS determines whether the number of frames recorded by counter 1 (i.e., the updated number of frames) is greater than or equal to m.

[0299] Where m can be a preset value, such as 5, 10, etc.

[0300] If the number of frames recorded by counter 1 in WMS is greater than or equal to m, it means that m consecutive blank frames have appeared, and the current frame (frame G) is the third type of end frame, that is, frame G is the end frame.

[0301] Thus, within frame G, if the updated frame number is greater than or equal to m, frame G can be identified as the last frame. The ability to efficiently identify this third type of last frame helps to quickly cancel CPU frequency increases, reducing power consumption of the terminal device while meeting performance requirements.

[0302] If the number of frames recorded by counter 1 in the WMS is less than m, it means that the number of consecutive blank frames is still small, and the WMS can wait for the arrival of the (K+1)th Vsync signal.

[0303] It should be understood that S904 to S907 and S901 to S903 can be implemented in parallel, or S904 to S907 can be implemented before or after S901 to S903. This application does not make any specific limitations in this regard.

[0304] It should also be understood that in method 900 above, if the WMS identifies the current frame (frame G) as not the end frame, the WMS can wait for the arrival of the (K+1)th Vsync signal. After receiving the (K+1)th Vsync signal, it can still determine whether the (G+1)th frame corresponding to the (K+1)th Vsync signal is the end frame according to the method of S901 value S907, until the WMS identifies the end frame. For the sake of simplicity, this will not be elaborated further here.

[0305] Alternatively, S902 can be replaced by: WMS determining whether the (K+1)th Vsync signal can be received within a duration of 1.

[0306] If the (K+1)th Vsync signal is not received within a duration of 1, then the Gth frame is the first type of tail frame.

[0307] If the (K+1)th Vsync signal is received within a duration of 1, then the Gth frame is not the first type of tail frame, and the WMS can execute S903. The preceding n frames can be understood as the consecutive n frames before the (K+1)th Vsync signal.

[0308] The method described above for identifying whether the G-th frame is a third type of tail frame via S904 to S907 is merely an example. In some possible implementations, the WMS may also identify whether the G-th frame is a third type of tail frame in the following ways.

[0309] For example, S01, after the WMS receives the Kth Vsync signal, it determines whether the number of frames recorded by counter 1 is greater than or equal to m.

[0310] If the number of frames recorded by counter 1 is greater than or equal to m, then the Gth frame is the third type of tail frame.

[0311] If the number of frames recorded by counter 1 is less than m, it means that the Gth frame is not the third type of tail frame, and WMS can execute S02 to S04.

[0312] S02, WMS determines whether frame G is a blank frame.

[0313] If frame G is a blank frame, WMS executes S03, which updates the frame number recorded by counter 1, such as by incrementing it by 1; and after updating the frame number recorded by counter 1, WMS can wait for the arrival of the (K+1)th Vsync signal.

[0314] If the Gth frame is not a blank frame, WMS executes S04, which resets counter 1; and after resetting counter 1, it can wait for the arrival of the K+1th Vsync signal.

[0315] It should be understood that the implementation type of the reset counter 1 and S905 above is an optional step, which can be referred to in the above description and will not be repeated here.

[0316] That is, S01 to S04 determine whether the number of frames recorded by counter 1 is greater than or equal to m before identifying whether the Gth frame is a blank frame.

[0317] In this way, if there are already m consecutive blank frames before the Gth frame, the WMS can determine that the Gth frame is the last frame, so that the WMS does not need to identify whether the Gth frame is a blank frame, which helps to reduce the power consumption of the terminal device.

[0318] Taking the scenario of launching application 3 as an example, the process of the terminal device controlling the CPU frequency during the launch of application 3 will be explained in detail below.

[0319] Figure 10 is a flowchart illustrating a CPU frequency control method 1000 during application startup according to an embodiment of this application. As shown in Figure 10, method 1000 includes the following steps:

[0320] S1001, Based on input operation 1, AMS starts application 3.

[0321] It should be understood that input operation 1 can be a user's input operation on the icon of application 3, such as clicking, or other input operations used to trigger the launch of application 3. This application does not specifically limit this.

[0322] When application 3 is launched via a cold start in S1001, the terminal device can execute S1002, which registers the scene recognition service for application 3. The implementation of S1002 is similar to that of S401, and can be referred to the description above, so it will not be repeated here.

[0323] When application 3 is launched in S1001 using either a warm start or a hot start, it indicates that AMS may have already registered the scene recognition service for application 3. In this case, the terminal device can execute S1003, which identifies the scene, and WMS can recognize the scene in which the application is launched.

[0324] After S1002 or S1003, the terminal device may execute S1004.

[0325] S1004, AMS instructs the CPU frequency module to issue a second instruction, which is used to instruct the CPU to increase its frequency. Additionally, the second instruction can also be used to indicate the package name of application 3.

[0326] The CPU frequency module can then adjust the CPU frequency to the target frequency based on the second instruction. Optionally, the target frequency can be a preset parameter, such as the maximum frequency, which can refer to the maximum value within the adjustable range of the CPU frequency.

[0327] It should be understood that a second timing event can be preset in the AMS, which is the timing when the CPU frequency module is instructed to increase the CPU frequency. That is, S1004 can be executed when the AMS recognizes the second timing event. The second timing event can be a timing event during the process of starting the application. The second timing event can also be understood as a "stub," which is a predefined position that can trigger the AMS to instruct the CPU frequency module to increase the CPU frequency. The embodiments of this application do not specifically limit the position of the second timing event.

[0328] After S1004, the terminal device can start application 3 according to the target frequency point increased after the CPU frequency is increased.

[0329] It is understood that after the CPU frequency module adjusts the CPU frequency to the target frequency based on the second instruction, and before the CPU frequency increase is canceled, the CPU frequency can remain at the target frequency or can change dynamically. This application does not impose specific limitations on this.

[0330] S1005, at the first opportune moment, AMS indicates the package name of application 3 and the scenario for launching the application to WMS, thereby triggering WMS to recognize the tail frame.

[0331] It should be understood that the implementation of S1005 is similar to that of S403, and can be referred to the description above, so it will not be repeated here.

[0332] It is understandable that in S1004, when the AMS instructs the CPU frequency module to increase the CPU frequency via the second instruction, the AMS can also instruct the CPU frequency module to specify the packet name of application 3; and in S1005, the AMS can also instruct the WMS to specify the packet name of application 3. This facilitates anomaly detection when the WMS subsequently instructs the CPU frequency module to cancel the CPU frequency increase. For example, the packet name and the flag bit function similarly; if the packet name of application 3 is used both when starting and canceling the CPU frequency increase, it indicates that no anomaly may have occurred.

[0333] S1006, In the scenario of launching an application based on AMS instructions, WMS identifies the tail frame through the process in method 900.

[0334] When WMS identifies the last frame, for example, if frame G is the last frame, WMS executes S1007, which means that through the frequency adjustment event management module, it sends a first instruction to the CPU frequency point module. The first instruction is used to indicate that the CPU frequency increase should be canceled.

[0335] This allows the CPU frequency module to cancel CPU frequency boosting in the last frame.

[0336] The frequency control method of this application allows the terminal device to identify the tail frame (the frame indicating the completion of application startup) during application startup and cancel CPU frequency boosting at the tail frame. This ensures sufficient resource allocation during application startup and allows for timely cancellation of CPU frequency boosting at the appropriate time (tail frame), reducing power consumption of the terminal device. It adapts to the different application requirements regarding CPU frequency boosting duration, helping to balance power consumption and performance in various scenarios and improving user experience.

[0337] For example, as shown in Table 1, Table 1 illustrates the latency and duration of CPU boost when launching a portion of the application via Method 1 and Method 2. In Method 1, the duration of CPU boost is a preset 1500ms; in Method 2, CPU boost is canceled based on the identified tail frame, similar to Method 1000.

[0338] As shown in Table 1, when launching a shopping application in Method 1, the CPU frequency boost lasts for a preset duration of 1500ms, and the latency of launching the shopping application is 3051ms.

[0339] When launching shopping applications using method 2, the CPU clock speed increase lasts for 2835.5ms, and the launch latency for shopping applications is 2646.5ms.

[0340] It can be seen that compared to launching shopping apps via method 1, launching shopping apps via method 2 results in a longer duration of CPU frequency boost and lower latency. This indicates that when launching shopping apps via method 2, the terminal device can extend the duration of CPU frequency boost to meet the performance requirements of launching shopping apps, thus reducing the latency.

[0341] When launching a short video application using Method 1, the CPU frequency boost lasts for a preset duration of 1500ms, and the launch latency for the short video application is 3670ms.

[0342] When launching a short video application using method 2, the CPU clock speed increase lasts for 2445ms, and the launch latency for the short video application is 2883ms.

[0343] It can be seen that compared to launching short video applications via method 1, launching short video applications via method 2 results in a longer duration of CPU frequency boost and lower latency. This indicates that when launching short video applications via method 2, the terminal device can extend the duration of CPU frequency boost to meet the performance requirements of launching short video applications, thus reducing the latency.

[0344] As is understandable, the above is an example of launching third-party applications. It can be seen that the frequency control method provided in this application, for some third-party applications, allows for a longer duration of CPU frequency boosting when the terminal device launches these applications in order to provide sufficient resources for launching them. This reduces the latency of launching these applications and helps improve the user experience.

[0345] When launching the SMS application using Method 1, the CPU frequency boost lasts for a preset duration of 1500ms, and the latency for launching short video applications is 592ms.

[0346] When launching the SMS application using method 2, the CPU frequency boost lasts for 882ms, and the latency for launching short video applications is 580ms.

[0347] As can be seen, compared to initiating SMS via Method 1, initiating SMS via Method 2 significantly reduces the duration of CPU frequency boost (from 1500ms to 882ms) and also reduces latency. This indicates that initiating SMS via Method 2 can significantly reduce the latency of SMS initiation while simultaneously reducing the duration of CPU frequency boost, thereby reducing the power consumption of the terminal device.

[0348] When starting the gallery using Method 1, the CPU frequency boost lasts for a preset duration of 1500ms, and the gallery startup latency is 625ms.

[0349] When starting the gallery using method 2, the CPU frequency boost lasts for 1259ms, and the gallery startup latency is 613ms.

[0350] As can be seen, compared to launching the gallery via method 1, launching the gallery via method 2 reduces the duration of CPU frequency boosting (from 1500ms to 1259ms) and also reduces latency. This indicates that launching the gallery via method 2 reduces both the latency of gallery launch and the duration of CPU frequency boosting, thereby reducing the power consumption of the terminal device.

[0351] As can be understood, the above is an example of launching system applications. It can be seen that the frequency control method provided in this application allows the terminal device to cancel CPU frequency boosting after recognizing the last frame for some system applications. This not only provides sufficient resources for launching these applications, resulting in lower latency, but also reduces the duration of CPU frequency boosting, thereby reducing the power consumption of the terminal device.

[0352] Table 1

[0353] It should be noted that the above description is based on the scenario of launching an application. In other scenarios, such as window switching, the terminal device can also perform end-frame recognition and cancel CPU frequency boosting when the end-frame is recognized. This application embodiment does not specifically limit this.

[0354] It should also be noted that the above description uses WMS for tail frame recognition as an example. In some possible implementations, tail frame recognition can also be performed by other execution entities, such as application-side sub-thread 1. This application embodiment does not specifically limit this.

[0355] It should be understood that the sequence numbers in the above embodiments do not imply the order of execution. The execution order of each process should be determined by its function and internal logic.

[0356] The frequency control method of the present application has been described above. The apparatus for executing the above-described frequency control method provided in the embodiments of the present application will now be described. Those skilled in the art will understand that the methods and apparatus can be combined with and referenced in each other, and the related apparatus provided in the embodiments of the present application can execute the steps in the above-described frequency control method.

[0357] To facilitate understanding of this solution, the hardware structure of the terminal device will first be explained with reference to Figure 11.

[0358] Figure 11 is a schematic diagram of the structure of the terminal device 1100 provided in an embodiment of this application. As shown in Figure 11, the terminal device 1100 may include a processor 1110, an external memory interface 1120, an internal memory 1121, a universal serial bus (USB) interface 1130, a charging management module 1140, a power management module 1141, a battery 1142, an antenna 1, an antenna 2, a mobile communication module 1150, a wireless communication module 1160, an audio module 1170, a sensor module 1180, a button 1190, a motor 1191, an indicator 1192, a camera 1193, a display screen 1194, and a subscriber identification module (SIM) card interface 1195, etc.

[0359] The audio module 1170 may include a speaker, receiver, microphone, and headphone jack. The sensor module 1180 may include a pressure sensor, gyroscope sensor, barometric pressure sensor, magnetic sensor, accelerometer, distance sensor, proximity sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, bone conduction sensor, etc.

[0360] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal device 1100. In other embodiments of this application, the terminal device 1100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0361] Processor 1110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0362] For example, method 1000 may be executed by processor 1110.

[0363] In some examples, processor 1110 may be a system-on-chip (SOC) of terminal device 1100.

[0364] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0365] The processor 1110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 1110 is a cache memory. This memory can store instructions or data that the processor 1110 has just used or that are used repeatedly. If the processor 1110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 1110, and thus improves the efficiency of the system.

[0366] In some embodiments, processor 1110 may include one or more interfaces.

[0367] The terminal device 1100 implements display functions through a GPU, a display screen 1194, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 1194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 1110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0368] Display screen 1194 is used to display images, videos, etc. Display screen 1194 includes a DDIC and a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, terminal device 1100 may include one or N displays 194, where N is a positive integer greater than 1.

[0369] The DDIC is one of the main control components of the display screen, often referred to as the "brain" of the display panel. Its primary function is to control the brightness and color of the display panel by sending drive signals and data to the panel in the form of electrical signals, enabling letters, pictures, and other image data to be displayed on the screen. In other words, the DDIC can acquire image data and send it to the display panel to display the image.

[0370] Internal memory 1121 can be used to store computer executable program code, which includes instructions. Internal memory 1121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of terminal device 1100 (such as audio data, phonebook, etc.). Furthermore, internal memory 1121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 1110 executes various functional applications and data processing of terminal device 1100 by running instructions stored in internal memory 1121 and / or instructions stored in memory located in the processor.

[0371] Figure 12 is a schematic block diagram of a frequency control device 1200 provided in an embodiment of this application. The device 1200 includes a processor 1201, a communication interface 1202, and a memory 1203. The processor 1201, communication interface 1202, and memory 1203 communicate with each other via internal connection paths. The memory 1203 is used to store instructions, and the processor 1201 is used to execute the instructions stored in the memory 1203. The communication interface 1202 can be used to send signals to other devices (e.g., the processor 1201 or the display screen of a terminal device) and to receive signals from other devices (e.g., the memory 1203). Exemplarily, the communication interface 1202 reads instructions stored in the memory 1203 and sends the instructions to the processor 1201.

[0372] It should be understood that the device 1200 may specifically be the terminal device in the above embodiments, and may be used to execute the various steps and / or processes corresponding to the terminal device in the above method embodiments. Optionally, the memory 1203 may include read-only memory and random access memory, and provide instructions and data to the processor. A portion of the memory may also include non-volatile random access memory. For example, the memory may also store device type information. The processor 1201 may be used to execute instructions stored in the memory, and when the processor 1201 executes instructions stored in the memory, the processor 1201 is used to execute the various steps and / or processes in the above method embodiments.

[0373] It should be understood that in the embodiments of this application, the processor can be a CPU, or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0374] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or as a combination of hardware and software modules within the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor executes the instructions in the memory, combining them with its hardware to complete the steps of the above method. To avoid repetition, detailed descriptions are omitted here.

[0375] The frequency control method provided in this application can be applied to terminal devices. The specific device form of the terminal device can be referred to the above-mentioned description, and will not be repeated here.

[0376] This application provides a terminal device, which includes a processor and a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, causing the terminal device to perform the above-described method.

[0377] This application provides a chip. The chip includes a processor, which is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those in the related embodiments described above, and will not be repeated here.

[0378] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the methods described above. The methods described in the above embodiments can be implemented wholly or partially by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored as one or more instructions or code on or transmitted over the computer-readable medium. The computer-readable medium can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.

[0379] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage or other magnetic storage devices, or any other medium targeted to carry or to store the required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. Combinations of the above should also be included within the scope of computer-readable media.

[0380] This application provides a computer program product, which includes a computer program that, when run, causes the computer to perform the above-described method.

[0381] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing device, create means for implementing the functions specified in one or more flowchart illustrations and / or one or more block diagrams.

[0382] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.

Claims

1. A frequency point control method, characterized in that, The method is applied to a terminal device, and the terminal device comprises a central processing unit (CPU). The method comprises the following steps: receiving a first operation; based on the first operation, enabling a first mechanism, the first mechanism being used to increase the frequency of the CPU; in a first target frame or a second target frame, the first mechanism is closed, and the second target frame is one frame after the first target frame; wherein the frame length of the first target frame is greater than a first time length, and the first time length is a time length determined based on a first frame rate, and the first frame rate is a frame rate in the first target frame or the second target frame.

2. The method of claim 1, wherein, The method further comprises: receiving a second operation; based on the second operation, enabling the first mechanism; in a third target frame or after the third target frame, the first mechanism is closed; wherein the frame length of the first Q frames before the third target frame satisfies: the discrete degree is less than or equal to a preset degree, and Q is an integer greater than 1.

3. The method according to claim 1 or 2, characterized in that, The method further comprises: receiving a third operation; based on the third operation, enabling the first mechanism; in a fourth target frame or after the fourth target frame, the first mechanism is closed, and the terminal device does not call a rendering thread in the fourth target frame and the first H frames before the fourth target frame, and H is a positive integer.

4. The method according to any one of claims 1 to 3, characterized in that, The first frame rate is a frame rate in the first target frame; The first mechanism is closed after the first target frame, comprising: obtaining a K1th vertical synchronization signal, the K1th vertical synchronization signal corresponding to the first target frame; in the case that no K1+1th vertical synchronization signal is received within the first time length after the K1th vertical synchronization signal is obtained, the first mechanism is closed in the first target frame.

5. The method according to any one of claims 1 to 3, characterized in that, The first mechanism is closed in the second target frame, comprising: obtaining a K1+1th vertical synchronization signal, the K1+1th vertical synchronization signal corresponding to the second target frame, and the second target frame being the next frame of the first target frame; in the case that the frame length of the first target frame is greater than the first time length, the first mechanism is closed in the second target frame.

6. The method according to claim 4 or 5, characterized in that, The method further comprises: in the case that the frame length of the first target frame is less than or equal to the first time length, it is judged whether the first condition is met by the Q frames before the second target frame; in the case that the first condition is met by the Q frames before the second target frame, the first mechanism is closed in the second target frame; wherein the first condition comprises: the average frame length of the Q frames before the second target frame is less than S times the second target frame length, and S is greater than 1; and / or, a first parameter is less than or equal to a first threshold value, the first parameter being used to represent the discrete degree of the Q frame lengths, and the Q frame lengths being the frame lengths of the Q frames before the second target frame; and the second target frame length is determined based on a second frame rate, and the second frame rate is the frame length of the second target frame.

7. The method of claim 6, wherein, The first parameter comprises one or more of the following of the Q frame lengths: standard deviation, variance, coefficient of variation, difference between maximum value and minimum value, or average absolute deviation.

8. The method according to any one of claims 4 to 7, characterized in that, After the K1+1th vertical synchronization signal is received, the method further comprises: If the terminal device does not invoke the rendering thread within the second target frame and the H frames preceding the second target frame, the first mechanism is disabled within the second target frame.

9. The method of claim 8, wherein, Disabling the first mechanism within the second target frame includes: If it is determined that the terminal device has not invoked the rendering thread within the second target frame, the first counter is updated. The first counter is used to record the number of consecutive frames in which the terminal device has not invoked the rendering thread. If the number of times recorded by the updated first counter is greater than or equal to H+1, the first mechanism is turned off within the second target frame.

10. The method according to any one of claims 1 to 9, characterized in that, The activation of the first mechanism includes: increasing the CPU frequency from a first value to a second value; wherein the second value is a preset value, or the difference between the first value and the second value is a preset value.

11. The method according to any one of claims 1 to 10, characterized in that, The first operation is used to launch the first application.

12. A terminal device, comprising: include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the terminal device to perform the method as described in any one of claims 1 to 11.

13. A computer-readable storage medium, the computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 11.

14. A computer program product, characterised in that, Includes a computer program that, when run, causes a computer to perform the method as described in any one of claims 1 to 11.