Drawing method and device, electronic equipment, storage medium and program product
By creating drawing tasks during the sliding operation and skipping non-drawing tasks, combined with the EEVDF algorithm and dynamic frequency adjustment, the stuttering and power consumption issues caused by CPU resource preemption during the sliding process are solved, achieving a smooth visual experience with low power consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- VIVO MOBILE COMM CO LTD
- Filing Date
- 2026-02-14
- Publication Date
- 2026-05-15
AI Technical Summary
During the sliding operation, CPU resources are preempted by non-drawing tasks, causing system stuttering and increased power consumption. Existing methods are unable to improve smoothness under low power consumption.
By creating drawing tasks and skipping non-drawing tasks during execution, the EEVDF algorithm is used to prioritize the scheduling of drawing tasks. Combined with dynamic frequency adjustment to optimize CPU resource allocation, this avoids preemption and contention of CPU resources by non-drawing tasks.
While reducing unnecessary power consumption, it also reduces system lag and improves the smoothness of scrolling, achieving a high-efficiency visual experience with low power consumption.
Smart Images

Figure CN122049162A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of electronic equipment technology, specifically relating to a drawing method, apparatus, electronic device, storage medium, and program product. Background Technology
[0002] With the advancement of technology, smartphones have become ubiquitous, and various mobile applications are emerging in endless streams. However, during the process of users swiping on their phones, drawing tasks that must be completed within a very short time are triggered, as well as a chain of tasks such as loading content and decoding data. This leads to a concentrated competition for the computing resources of the Central Processing Unit (CPU) within a short period of time, causing system lag and causing the CPU to run at a high frequency continuously, resulting in increased power consumption and device overheating. To address these issues, the current approach is to limit the CPU's highest and lowest frequencies after recognizing the swiping scenario, thus confining the CPU frequency within a certain range.
[0003] However, while limiting the CPU's maximum frequency helps control heat generation, it can also exacerbate lag when high performance is needed due to insufficient computing power. Conversely, limiting the CPU's minimum frequency can improve performance, but it can lead to unnecessary power consumption waste in low-load scenarios. A balance between the two is often difficult to achieve. Therefore, how to improve the smoothness of scrolling while maintaining low power consumption is a pressing issue that needs to be addressed. Summary of the Invention
[0004] The purpose of this application is to provide a drawing method, apparatus, electronic device, storage medium, and program product that can improve the smoothness of the scrolling process with low power consumption.
[0005] In a first aspect, embodiments of this application provide a drawing method, the method comprising: in response to a sliding operation in a display interface, creating at least one drawing task, the drawing task being used to draw a screen frame to be displayed on the display interface; executing at least one drawing task, and skipping the execution of non-drawing tasks during the execution of at least one drawing task, the non-drawing tasks being tasks unrelated to drawing the screen frame to be displayed.
[0006] Secondly, embodiments of this application provide a drawing apparatus, comprising a generation module and an execution module. The generation module is configured to create at least one drawing task in response to a sliding operation on a display interface. The drawing task is used to draw a screen frame to be displayed on the display interface. The execution module is configured to execute the at least one drawing task generated by the generation module, and skip executing non-drawing tasks during the execution of the at least one drawing task. The non-drawing tasks are tasks unrelated to drawing the screen frame to be displayed.
[0007] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0008] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0009] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.
[0010] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.
[0011] In this embodiment, at least one drawing task can be created in response to a sliding operation on the display interface. This drawing task is used to draw the screen frame to be displayed on the display interface. Then, the at least one drawing task is executed, and non-drawing tasks, which are tasks unrelated to drawing the screen frame to be displayed, are skipped during the execution of the at least one drawing task. In this solution, since the drawing task is used to draw the screen frame to be displayed on the display interface, it is a core element to ensure the smoothness of the user's visual experience. Non-drawing tasks are unrelated to drawing the screen frame to be displayed, and their execution timing has a certain degree of flexibility and can be delayed. Therefore, by actively skipping the scheduling of non-drawing tasks during the execution of drawing tasks, the preemption and competition of CPU resources by non-drawing tasks can be effectively avoided, allowing the CPU computing power to be concentrated on serving the drawing task. This reduces unnecessary power consumption and system lag caused by resource contention, thereby improving the smoothness of the sliding process with low power consumption. Attached Figure Description
[0012] Figure 1 This is a schematic diagram of an existing solution provided in the embodiments of this application;
[0013] Figure 2 This is one of the flowcharts of the drawing method provided in the embodiments of this application;
[0014] Figure 3 This is one of the schematic diagrams of the drawing process provided in the embodiments of this application;
[0015] Figure 4 This is a second schematic diagram of the drawing process provided in the embodiments of this application;
[0016] Figure 5 This is the third schematic diagram of the drawing process provided in the embodiments of this application;
[0017] Figure 6 This is the fourth schematic diagram of the drawing process provided in the embodiments of this application;
[0018] Figure 7 This is a flowchart of adjusting the CPU operating frequency provided in an embodiment of this application;
[0019] Figure 8 This is the second flowchart of the drawing method provided in the embodiments of this application;
[0020] Figure 9 This is one of the schematic diagrams of CPU load provided in the embodiments of this application;
[0021] Figure 10 This is a second schematic diagram of CPU load provided in the embodiments of this application;
[0022] Figure 11 This is a schematic diagram illustrating the execution process of the drawing method provided in the embodiments of this application;
[0023] Figure 12 This is a schematic diagram of the drawing apparatus provided in an embodiment of this application;
[0024] Figure 13 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;
[0025] Figure 14 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0026] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0027] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0028] The terms "at least one," "at least one," etc., in this application refer to any one, any two, or a combination of two or more of the included objects. For example, at least one of a, b, and c can mean: "a," "b," "c," "a and b," "a and c," "b and c," and "a, b, and c," where a, b, and c can be single or multiple. Similarly, "at least two" refers to two or more, and its meaning is similar to that of "at least one."
[0029] The drawing method, apparatus, electronic device, storage medium, and program product provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0030] The embodiments of this application can be applied to scenarios in electronic devices where high screen smoothness is required.
[0031] The following uses some specific scenarios from the embodiments of this application as examples to illustrate the drawing method provided in the embodiments of this application.
[0032] Scenario 1: Users browse news and information apps on their mobile phones, switching between different news articles by swiping up and down and scrolling through the article content.
[0033] Scenario 2: Users use a video playback application on a tablet to fast forward or rewind the video by swiping, and view different frames of the video while swiping.
[0034] Scenario 3: Users use map navigation apps on their phones and zoom in, zoom out, or pan the map by swiping their fingers on the screen to view detailed information about different areas.
[0035] It should be noted that scenarios 1 to 3 above are merely exemplary examples of some scenarios that may be applied to the embodiments of this application. In actual implementation, the embodiments of this application can also be applied to any possible scenario with more requirements. The embodiments of this application are not limited here.
[0036] In some embodiments of this application, the above-mentioned sliding process refers to the entire process of a user performing a sliding operation on the display interface, which is divided into sliding start and sliding end. The sliding process includes multiple sequentially cyclical drawing and non-drawing processes. Specifically, the sliding process includes multiple screen frames, and each frame includes a loop of drawing and non-drawing processes. Each drawing process includes a frame rendering stage (doFrame), a pixel drawing stage (drawFrame), and a GPU stage.
[0037] With the widespread use of smartphones, various mobile applications have emerged in endless streams, varying greatly in quality. Furthermore, frequent application updates often introduce new problems. For example, a common issue users encounter is choppy or even laggy scrolling, leading to overheating, especially during scenarios like watching videos or browsing products online. This is primarily because during the scrolling and rendering process, multiple tasks compete for CPU resources, resulting in higher CPU frequencies, which in turn cause power consumption and system lag.
[0038] To address the power consumption and lag issues caused by task contention for CPU resources during the sliding drawing process, such as... Figure 1 As shown, the current solution is:
[0039] 1. If a sliding scene is detected, the highest and lowest frequencies are limited, so that the CPU frequency is limited to a certain range.
[0040] 2. Set the drawing-related threads as real-time threads. The kernel classifies tasks, and real-time tasks have higher priority than normal tasks. Setting the drawing-related threads as real-time threads will allow them to be scheduled with priority.
[0041] 3. By increasing the minimum load of the drawing-related threads, the load is accumulated onto the CPU. When the CPI load changes, frequency adjustment will be triggered to increase the CPU frequency.
[0042] However, the existing solutions have the following problems:
[0043] 1. Too many real-time tasks were set up, resulting in a lack of clear priority among the tasks.
[0044] 2. Limiting the highest frequency reduces heat generation, but it can worsen lag.
[0045] 3. Limiting the lowest frequency can guarantee the lowest performance, but it also causes unnecessary power consumption waste.
[0046] 4. Treating the sliding process as a whole, once a sliding scenario is identified, frequency limiting and frequency boosting strategies are uniformly applied, resulting in inaccurate resource allocation. This may lead to blind frequency boosting or frequency limiting in non-critical stages, exacerbating stuttering or wasting power.
[0047] This application provides a drawing method, apparatus, electronic device, storage medium, and program product. Since the drawing task is used to draw the screen frame to be displayed on the display interface, it is a core element to ensure the smoothness of the user's visual experience. The non-drawing task is a task unrelated to drawing the screen frame to be displayed. Its execution timing has a certain degree of flexibility and can be delayed. Therefore, by actively skipping the scheduling of non-drawing tasks during the execution of the drawing task, the preemption and competition of non-drawing tasks for CPU resources can be effectively avoided, so that the CPU computing power can be concentrated on serving the drawing task. This reduces unnecessary power consumption and system lag caused by resource contention, thereby improving the smoothness of the scrolling process under low power consumption.
[0048] The entity executing the drawing method provided in this application can be a drawing device, which can be an electronic device, or a functional module or functional entity within an electronic device. The following description uses an electronic device as an example to illustrate the technical solution provided in this application.
[0049] Figure 2 A flowchart of a drawing method provided in an embodiment of this application is shown, such as... Figure 2 As shown, the drawing method provided in this application embodiment may include the following steps 201 and 202.
[0050] Step 201: In response to a swipe operation on the display interface, the electronic device creates at least one drawing task.
[0051] In some embodiments of this application, the aforementioned display interface refers to the interface on an electronic device used to display visual content, such as an application's list page or history page. During a swiping operation, the electronic device needs to dynamically update the content displayed on the display interface based on the user's actions to ensure that the display interface updates promptly and smoothly.
[0052] In some embodiments of this application, the above-mentioned swiping operation refers to the horizontal or vertical movement operation performed by the user in the display interface of the electronic device using a finger or other input device. It is often used to quickly browse content, such as switching or scrolling to view different information in web pages, pictures, videos or application interfaces.
[0053] In some embodiments of this application, the above-mentioned drawing task is used to draw the screen frame to be displayed on the display interface. Here, the drawing task is a task of the display interface related to the display screen frame, and the screen frame to be displayed refers to the single image content that will be presented on the display interface in the next frame.
[0054] In some embodiments of this application, when a user begins to perform a swipe operation on the display interface, the electronic device can detect the swipe event through a sensor. Then, the electronic device can respond to the swipe event and subsequently create corresponding drawing tasks based on factors such as the swipe direction, speed, and distance. These tasks are then scheduled to be executed on processing units such as CPUs or graphics processing units (GPUs) to generate new screen frames.
[0055] Step 202: The electronic device performs at least one drawing task and skips non-drawing tasks while performing at least one drawing task.
[0056] In some embodiments of this application, the aforementioned non-drawing tasks may also be referred to as unrelated threads or unrelated tasks, which are tasks unrelated to drawing the screen frame to be displayed. For example, they may be background data collection, log reporting, or other tasks, and their execution timing is flexible and can be delayed. In embodiments of this application, the electronic device can provide a configuration interface, through which the business party can specify whether the task to be executed is a non-drawing task, thereby achieving flexible definition of non-drawing tasks.
[0057] In some embodiments of this application, the process of performing at least one drawing task can be simply referred to as the drawing process, which refers to the stage where the CPU and GPU are mainly busy completing drawing-related tasks such as drawing, rendering, and displaying. Conversely, the non-drawing process refers to the stage where the electronic device is processing non-drawing-related tasks, and is an interval between drawing processes, such as a background big data acquisition module. The sum of the time required for one drawing process and one non-drawing process is the duration of one frame drawing; for example, in a scenario where 60 frames are displayed per second, the duration of one frame drawing is 1 / 60 of a second.
[0058] In some embodiments of this application, such as Figure 3 As shown, the above drawing process is divided into three stages: doFrame, drawFrame, and GPU stage. The duration of each frame drawing includes a drawing process and a non-drawing process, and each drawing process includes the above three stages: doFrame, drawFrame, and GPU.
[0059] In some embodiments of this application, the aforementioned skip execution is a scheduling strategy, not a complete prohibition of execution. Rather, it refers to actively delaying or pausing the execution of non-drawing tasks when the system detects drawing tasks to be executed during the drawing process. Specifically, this means keeping non-drawing tasks in a queue through the scheduler, prioritizing the scheduling of drawing tasks, and setting a timeout mechanism to prevent non-drawing tasks from being delayed indefinitely.
[0060] It should be noted that in sliding scenes, the display interface needs to be refreshed continuously to present smooth animation, such as displaying 60 frames per second. Therefore, electronic devices need to complete the rendering of frames within a specified time. For example, if 60 frames per second are displayed, the rendering time of each frame cannot exceed 1 / 60 of a second, which is approximately 16.67 milliseconds (ms). Otherwise, it may cause "frame drops", that is, stuttering.
[0061] In some embodiments of this application, since drawing tasks are tasks related to displaying screen frames, while non-drawing tasks are tasks unrelated to drawing the screen frames to be displayed, when a drawing task is not completed in a timely manner, it will directly cause the display interface to lag, while when a non-drawing task is not completed in a timely manner, it will not cause the display interface to lag. Therefore, in order to ensure the smoothness of the display interface when the user performs a swiping operation, the electronic device can prioritize the execution of drawing tasks when the user performs a swiping operation.
[0062] In some embodiments of this application, the electronic device can actively postpone or block the scheduling and execution of non-drawing tasks during the execution of drawing tasks through a scheduler.
[0063] In some embodiments of this application, each CPU of the above-mentioned electronic device is configured with an independent task scheduling queue, and when executing at least one drawing task, it is preferentially scheduled from the task scheduling queue of the CPU corresponding to the drawing task.
[0064] In some embodiments of this application, the kernel uses the Earliest Eligible Virtual Deadline First (EEVDF) algorithm to select the next task to be executed from the independent queue of the CPU. If the scheduler identifies the next task to be executed as a non-drawing task, and the current process is drawing with other drawing tasks to be executed, the non-drawing task will be kept in the task queue of the corresponding CPU and given priority to the drawing task.
[0065] In some embodiments of this application, EEVDF sorts tasks within a Red-Black Tree (RB Tree) according to their deadlines. The deadlines take into account factors such as weight, virtual runtime, and slice, and can be considered as the expected CPU time that a task is expected to occupy.
[0066] In some embodiments of this application, the red-black tree described above is an efficient self-balancing binary search tree. The EEVDF algorithm uses a red-black tree to sort tasks in a queue, based on their deadlines. This allows the scheduler to quickly find the task with the earliest deadline and make a scheduling decision.
[0067] In some embodiments of this application, the deadline for the aforementioned task is not a fixed time, but a calculated value that integrates multiple factors. It represents the task's "expected CPU time" or scheduling priority, determined by three key factors: weight, virtual runtime, and time slice. Wherein:
[0068] 1. Weight: Represents the basic priority of a task. The higher the weight, the greater its right to CPU time, the more pressing its calculated deadline will be, i.e., earlier, and thus more likely to be scheduled first.
[0069] 2. Virtual runtime: This refers to the time a task has actually spent executing on the CPU, weighted according to its respective weight. It ensures that, over long time scales, each task receives a fair share of CPU time proportional to its weight.
[0070] 3. Time slice: refers to the length of time that the task expects to execute continuously on the CPU for this request.
[0071] The scheduler can use a complex formula to combine these three factors to calculate a deadline. The task with the earliest deadline, i.e. the smallest value, will be the first in the red-black tree and will be selected for execution first.
[0072] In some embodiments of this application, the EEVDF algorithm also introduces a lag value, which is the difference between the expected and actual CPU time of a task. If the value is positive, it means that the task failed to use its full CPU time for some reason. From a fairness perspective, it is being treated unfairly. Therefore, electronic devices can give priority to such processes when considering the next scheduling to ensure scheduling fairness.
[0073] In some embodiments of this application, Lag = expected CPU time to be used by the task - actual CPU time used by the task. If this value is positive, it means that the task did not fully utilize its expected CPU time for some reason. For example, frequent preemption by a high-priority task may cause a normal task to remain unexecuted for a long time, with its expected CPU time being much greater than its actual CPU time, and the Lag value will become positive. When the Lag value is positive, it means that the task has been "unfairly treated". As compensation, the scheduler will make its deadline earlier when calculating its deadline next time, thereby increasing its probability of being selected and ensuring that all tasks can obtain a fair share of CPU time during long-term operation.
[0074] In some embodiments of this application, the EEVDF scheduling mechanism is the cornerstone of the dynamic scheduling control scheme, directly solving the problem that too many real-time tasks lead to a lack of clear priority among tasks. Electronic devices no longer need to simply set the drawing thread as a real-time task, but instead utilize EEVDF's fine-grained sorting and Lag value compensation mechanism to intelligently distinguish task priorities. When the system recognizes that a drawing process is underway and there is a more important task E, such as a drawing task, even if the deadline for a non-drawing task A has arrived, the scheduler can prioritize the execution of the drawing task according to the strategy. At the same time, it uses the Lag value to record the "unfair" treatment of non-drawing tasks, and compensates them after the drawing process is completed, thus perfectly balancing drawing smoothness and scheduling fairness.
[0075] In some embodiments of this application, combined with Figure 3 ,like Figure 4 As shown, assuming that during the drawing process, the current task queue is sorted by importance as taskD, taskC, taskB, and taskA, the electronic device will execute taskD, taskC, and taskB in sequence. Combined with... Figure 4 ,like Figure 5 As shown, when task B is executed, a drawing task task E is added to the task queue. At this time, the scheduler recognizes that the next selected task A to be executed is an irrelevant thread, i.e., a non-drawing task, which is still in the drawing process and has a more important drawing task E to execute. Therefore, the scheduler can keep task A in the queue to wait for execution, i.e., skip its execution. Figure 5 ,like Figure 6 As shown, taskE is executed first, thus ensuring that the drawing task can run continuously and without interruption, avoiding delays caused by task switching or resource contention.
[0076] This application provides a drawing method. Since drawing tasks are used to draw the screen frames to be displayed on the display interface, they are the core element to ensure the smoothness of the user's visual experience. Non-drawing tasks are tasks unrelated to drawing the screen frames to be displayed, and their execution timing has a certain degree of flexibility and can be delayed. Therefore, by actively skipping the scheduling of non-drawing tasks during the execution of drawing tasks, it is possible to effectively avoid the preemption and competition of CPU resources by non-drawing tasks, so that the CPU computing power can be concentrated on serving the drawing tasks. This reduces unnecessary power consumption and system lag caused by resource contention, thereby improving the smoothness of the scrolling process under low power consumption.
[0077] In some embodiments of this application, the drawing method provided in this application further includes the following step 301.
[0078] Step 301: When executing the first drawing task, if the execution duration of the first drawing task is greater than or equal to the first duration threshold, the electronic device increases the CPU's operating frequency.
[0079] In some embodiments of this application, the first drawing task is one of the at least one drawing task.
[0080] In some embodiments of this application, the aforementioned first drawing task refers to the task corresponding to any stage of the drawing process. The first drawing task can be the main task of doFrame or drawFrame, and the characteristic of this task is that it is directly related to the generation efficiency of the screen frame, and its execution progress directly determines whether frames will be dropped.
[0081] In some embodiments of this application, the execution duration refers to the actual time elapsed from when the first rendering task was scheduled to run on the CPU until the current moment, typically measured in milliseconds. This duration can be measured and tracked in real time by a high-precision timer in the electronic device's kernel, such as a Performance Monitoring Unit (PMU). The execution duration reflects the complexity of the current rendering task and the system load. The electronic device can continuously monitor the actual execution time of the rendering task as a quantitative basis for determining whether there is a risk of frame drops.
[0082] In some embodiments of this application, the aforementioned first duration threshold is a duration threshold set for doFrame or drawFrame to trigger CPU frequency adjustment. It is a key criterion for distinguishing between normal execution and execution delay. Its setting needs to balance performance and power consumption to avoid premature frequency increase causing waste or late frequency increase causing frame drops.
[0083] In some embodiments of this application, the above-mentioned at least one drawing task includes a drawing task in the frame rendering stage and a drawing task in the pixel drawing stage. The above-mentioned first duration threshold is divided into a first sub-threshold corresponding to the doFrame stage and a second sub-threshold corresponding to the drawFrame stage, which are set separately for the two stages. For the frequency increase triggered by the doFrame stage, the lower limit of the CPU utilization rate of the User Interface Thread (UI Thread) is adjusted. For the frequency increase triggered by the drawFrame stage, the lower limit of the CPU utilization rate of the Render Thread is adjusted.
[0084] In some embodiments of this application, the first duration threshold is an empirical value determined based on experimental measurements and actual optimization. Specifically, actual tests can be conducted in advance under different frame rate scenarios, such as 30 frames per second (fps), 60fps, 90fps, 120fps, and other common frame rate scenarios. The execution duration distribution of the rendering task in various typical sliding scenarios, such as video playback, web browsing, and map scrolling, can be measured. Combined with multi-dimensional indicators such as frame drop rate, power consumption, and temperature, the most suitable threshold setting can be comprehensively evaluated and determined to fully consider the actual hardware performance, software load characteristics, and user experience requirements. This avoids threshold deviations caused by the simplification of theoretical models and ensures the best balance between timely frequency increase to avoid frame drops and avoiding premature frequency increase that leads to power waste.
[0085] For example, taking 60fps as an example, each frame needs to be completed within 16.67ms, of which doFrame is expected to take 7ms and drawFrame is also expected to take 7ms. The remaining time is reserved for the GPU and non-drawing processes. Taking the first duration threshold as the duration threshold of doFrame as an example, assuming that the first duration threshold is set to 5ms in the case of 60fps, in order to reserve 2ms for frequency boosting response and accelerated execution buffer time, if doFrame is not completed within the specified time, that is, within the first duration threshold of 5ms, the electronic device is considered to be likely to drop frames, thereby triggering the electronic device to boost the frequency and speed up the processing of doFrame to ensure completion, so as to prevent frame drops and stuttering.
[0086] In some embodiments of this application, when executing a first drawing task, if the execution duration of the first drawing task is greater than or equal to a first duration threshold and the first drawing task is not completed, the electronic device may increase the CPU's operating frequency.
[0087] In some embodiments of this application, increasing the CPU's operating frequency refers to actively increasing the CPU core's operating frequency through a Dynamic Voltage and Frequency Scaling (DVFS) mechanism. When the electronic device determines that the first rendering task has timed out, i.e., the execution time has reached a first time threshold and is still not completed, the electronic device can be triggered to perform a frequency increase operation. This differs from traditional passive frequency adjustment based on load accumulation; it is a proactive intervention strategy for timely frequency increases, thereby providing more sufficient computing resources for the rendering task, accelerating the completion of the remaining work, and ensuring that the task is completed before the frame submission deadline.
[0088] In some embodiments of this application, the electronic device can track the execution of rendering tasks in real time through the monitoring mechanism of the upper-layer application framework, such as hook technology. When the electronic device starts executing the first rendering task, it can immediately start a timer corresponding to the task. During task execution, the electronic device can continuously read the timer value and calculate the execution duration. Simultaneously, the electronic device compares the execution duration with a preset first duration threshold in real time. If the execution duration is less than the first duration threshold, it indicates that the task is completed within the expected time and no intervention is needed. However, if the execution duration is detected to be greater than or equal to the first duration threshold and the task has not yet been completed, it indicates that the task processing is too slow and may not be able to complete rendering before the frame deadline, posing a risk of dropped frames. When the execution duration is detected to exceed the first duration threshold, the electronic device can respond immediately by increasing the CPU's operating frequency.
[0089] In some embodiments of this application, after the CPU frequency is increased, the execution speed of the drawing task is accelerated, and the electronic device can continue to monitor the task progress. If the task is completed before the next time checkpoint, the frequency can be gradually reduced according to the subsequent load; if the task is still not completed, the electronic device can continue to increase the frequency or maintain a high-frequency state until the task is completed or the frame deadline is missed.
[0090] In this way, by monitoring the execution time of the rendering task in real time, the system maintains the status quo to save power when no timeout risk is detected, and dynamically increases the CPU frequency when a timeout risk is detected, thereby accelerating the rendering process in an emergency. Predictive frequency modulation avoids the frequency modulation delay caused by passively responding to load changes, avoids possible frame drops, and avoids the stuttering or power waste caused by blindly limiting the frequency in traditional solutions, thus ensuring a smooth sliding experience and a balance between power consumption.
[0091] In some embodiments of this application, the "increasing the operating frequency of the CPU in the electronic device" in step 301 above can be specifically implemented through the following steps 301a and 301b.
[0092] Step 301a: The electronic device adjusts the lower limit of CPU utilization of the drawing thread corresponding to the first drawing task from the first value to the second value.
[0093] In some embodiments of this application, the second value is greater than the first value.
[0094] In some embodiments of this application, the aforementioned drawing thread is a scheduling entity in the kernel responsible for executing drawing tasks, that is, an execution unit that carries out specific drawing work. For example, in the Android system, the UI Thread is responsible for handling the interface layout and is the main task in the doFrame stage, while the Render Thread is responsible for generating graphics data and is the main task in the drawFrame stage. These threads directly participate in the rendering of screen frames.
[0095] In some embodiments of this application, the aforementioned CPU utilization lower limit can also be referred to as the minimum utilization clamp (uclamp) or minimum load. It is a minimum load guarantee value set by the kernel scheduler for a task, used to constrain the minimum load contribution that a task should be identified when running on the CPU. The CPU utilization lower limit is a dimensionless weighted value that affects the scheduler's estimation of the total CPU load. This parameter defines the minimum contribution of a thread in the CPU load calculation; that is, regardless of how much work a thread actually performs, its statistical value of CPU load will not be lower than this lower limit. In embodiments of this application, the CPU utilization lower limit is used to affect the sum of the loads of all running tasks within the sampling window, i.e., the total CPU load. When the total CPU load changes, it triggers CPU frequency adjustment, thus allowing electronic devices to influence CPU frequency decisions through changes in the CPU utilization lower limit.
[0096] In some embodiments of this application, the first value mentioned above is the original CPU utilization lower limit of the drawing thread before adjustment. It is the default CPU utilization lower limit assigned to the drawing thread when it is created or initialized. It is usually a low base value to avoid unnecessary power consumption and reflects the CPU resource demand level of the drawing task under normal circumstances.
[0097] In some embodiments of this application, the second value is the adjusted lower limit of CPU utilization for the new drawing thread. This value is preset through experience or experimentation, with the aim of proactively improving the system's perception of the drawing thread's load. A second value greater than the first value indicates that the system determines the current drawing task requires stronger CPU resource guarantees, and proactively triggers a frequency increase by artificially increasing its load contribution.
[0098] In some embodiments of this application, when the electronic device detects that the execution time of the first drawing task has reached a first duration threshold, i.e., frame drops may occur, it can first locate the drawing thread corresponding to the first drawing task through the Hook mechanism of the upper-layer framework, and then call the kernel interface to modify the minimum value of the uclamp of the thread from the first value to the second value, so as to artificially increase the weight of the drawing thread in the system load calculation and amplify its load contribution.
[0099] In some embodiments of this application, if the execution duration of the first drawing task is greater than or equal to a first duration threshold, the lower limit of the CPU utilization rate of the drawing thread corresponding to the first drawing task is adjusted from a first value to a second value, and then the working frequency of the CPU is increased according to the second value.
[0100] In some embodiments of this application, when performing a drawing task in the frame rendering stage, the drawing thread corresponding to the first drawing task is a user interface thread; when performing a drawing task in the pixel drawing stage, the drawing thread corresponding to the first drawing task is a rendering thread.
[0101] In some embodiments of this application, the at least one drawing task mentioned above includes a doFrame stage drawing task and a drawFrame stage drawing task, and the first duration threshold includes a first sub-threshold matching the doFrame stage and a second sub-threshold matching the drawFrame stage.
[0102] In some embodiments of this application, when executing a doFrame stage drawing task, if the execution duration of the doFrame stage drawing task is greater than or equal to a first sub-threshold, the lower limit of the CPU utilization rate of the UIThread of the doFrame stage drawing task is adjusted from the first value to the second value.
[0103] In some embodiments of this application, when executing a drawFrame stage drawing task, if the execution duration of the drawFrame stage drawing task is greater than or equal to a second sub-threshold, the lower limit of the CPU utilization rate of the Render Thread of the drawFrame stage drawing task is adjusted from a first value to a second value.
[0104] Step 301b: The electronic device increases the CPU's operating frequency according to the second value.
[0105] In some embodiments of this application, after the electronic device adjusts the lower limit of CPU utilization of the drawing thread corresponding to the first drawing task from a first value to a second value, the system kernel scheduler can calculate the total CPU load in real time, wherein the load contribution of a thread is constrained by its uclamp value. As the load contribution of the drawing thread increases, the total CPU load rises accordingly.
[0106] In some embodiments of this application, the DVFS mechanism is triggered when the total load exceeds the load threshold corresponding to the current frequency level. This mechanism is a core component of CPU power management, which automatically adjusts the frequency based on the real-time load. When the load increases, DVFS drives the CPU to increase from its current low frequency state to a higher frequency, such as from 1.2 gigahertz (GHz) to 1.4 GHz. After the frequency is increased, the CPU computing power is enhanced, and the execution speed of drawing tasks is accelerated, thereby ensuring that the doFrame or drawFrame stages are completed in a timely manner.
[0107] In some embodiments of this application, the drawing process is divided into two stages: doFrame and drawFrame, which can be collectively referred to as the xFrame stage. Based on the dot information of the upper-layer application framework, the electronic device can specifically distinguish each process and start timing at the beginning of xFrame based on the drawing duration of one frame. If the xFrame process is not completed within the specified time, it is considered a possible frame drop, and the CPU frequency should be increased in time to ensure that no frame drops occur. Specifically, as shown in... Figure 7 The flowchart shown is for adjusting the CPU operating frequency, including steps 10 to 16.
[0108] Step 10: The electronic device obtains three key monitoring points based on the hook mechanism: before doFrame (s0), after doFrame (s1), and drawFrame (s2).
[0109] Here, s0 represents the preparation phase before the doFrame phase begins. During this phase, the system performs initialization operations, such as setting a timer to trigger when the first sub-threshold t1 corresponding to doFrame is reached, in order to monitor the triggering timing of the doFrame phase. s0 is the starting point of the drawing process, used to ensure that subsequent phases can be executed on time. s1 represents the transition phase after the completion of the doFrame phase, used to set the next timer as the triggering condition for monitoring the drawFrame phase, indicating the completion of doFrame. If a timeout occurs, it means that the phase was not completed within t1, and optimization measures are triggered. s2 represents the drawFrame completion phase, indicating the completion of drawFrame. If drawFrame is not completed within the second sub-threshold t2 corresponding to drawFrame, the system will determine it as a risk of frame drops and take action.
[0110] Step 11: Identify the trigger frequency of electronic devices.
[0111] Step 12: The electronic device sets timer t1 in phase s0.
[0112] Step 13: If t1 expires, the electronic device checks whether s1 has been triggered.
[0113] If s1 is not triggered, proceed to step 14; if s1 is triggered, proceed to step 16.
[0114] Step 14: Improve the UI thread of the electronic device using Uclamp.
[0115] In some embodiments of this application, increasing the UI thread Uclamp can prioritize UI thread resources.
[0116] Step 15: Electronic devices trigger CPU frequency increase.
[0117] Step 16: The electronic device sets timer t2 in phase s0.
[0118] Step 17: If t2 expires, the electronic device checks whether s2 has been triggered.
[0119] If s2 is not triggered, proceed to step 18; if s2 is triggered, the process ends.
[0120] Step 18: Electronic devices enhance Render thread Uclamp.
[0121] Step 19: Electronic devices trigger CPU frequency increase.
[0122] In this way, electronic devices can trigger a CPU frequency increase by adjusting the lower limit of CPU utilization of the drawing thread, skipping the lag of traditional passive load accumulation, and responding more promptly to the real-time performance requirements of drawing tasks. This ensures that the frame is rendered before the deadline, effectively avoiding scrolling stutters. At the same time, the frequency is precisely increased only in critical drawing stages, avoiding the power waste caused by global high-frequency operation, thus achieving a dynamic balance between smoothness and energy efficiency.
[0123] In some embodiments of this application, combined with Figure 1 ,like Figure 8 As shown, after step 202 above, the drawing method provided in this application embodiment further includes step 401 or step 501 as described below.
[0124] Step 401: If the duration of skipping the execution of non-drawing tasks is greater than or equal to the second duration threshold, the electronic device executes non-drawing tasks.
[0125] In some embodiments of this application, the aforementioned duration for skipping non-drawing tasks refers to the cumulative time from the first time the non-drawing task is delayed (i.e., skipped) to the current moment. In embodiments of this application, the electronic device can record the waiting start time for each skipped non-drawing task and calculate the waiting duration in real time.
[0126] In some embodiments of this application, the aforementioned second duration threshold is a preset maximum hunger tolerance time, representing the maximum duration for which non-drawing tasks are allowed to be skipped, used to balance drawing smoothness and task fairness. The second duration threshold can be determined through experimental tuning, for example, set to 50ms, 100ms, or longer. When this threshold is exceeded, the electronic device must temporarily execute non-drawing tasks to prevent data loss or functional abnormalities due to prolonged waiting, i.e., being hung up.
[0127] In some embodiments of this application, during the drawing process, the electronic device prioritizes drawing tasks and actively skips non-drawing tasks. In this case, the system records the timestamp of the first delayed execution of each skipped non-drawing task and continuously monitors the waiting time.
[0128] In some embodiments of this application, the electronic device can compare the skip duration of non-drawing tasks with a second duration threshold in real time. If the skip duration is less than the second duration threshold, it indicates that the task waiting time is within the allowable range, and the electronic device continues to skip the task, prioritizing the drawing task; if the skip duration is greater than or equal to the second duration threshold, it indicates that the task is approaching the risk of being hung up, triggering an intervention mechanism.
[0129] In some embodiments of this application, when the skip duration is greater than or equal to a second duration threshold, the electronic device can "pull" the delayed non-drawing task from the waiting queue through the kernel scheduler and allocate a CPU time slice for its execution, ensuring that the non-drawing task can obtain a minimum amount of CPU resources to maintain the normal operation of the system. After it finishes running or its time slice is exhausted, it is marked as a skippable non-drawing task again, the timer is reset, and it continues to run with a drawing task priority strategy, forming a dynamically balanced closed-loop control.
[0130] In some embodiments of this application, in order to prevent non-drawing tasks from being "hung out" due to long waiting times, the system records the first time the thread is delayed. After a preset time period, the thread is pulled out of the queue and executed for a certain period of time, which ensures the priority of drawing tasks and avoids task starvation.
[0131] In this way, electronic devices can monitor timeout thresholds and execute non-drawing tasks with a skip duration greater than or equal to the second timeout threshold. This ensures that drawing tasks are executed first while preventing non-drawing tasks from being delayed indefinitely, thus achieving a balance between system smoothness and system stability.
[0132] Step 501: After completing at least one drawing task, the electronic device performs a non-drawing task.
[0133] In some embodiments of this application, the above-mentioned execution of at least one drawing task is as follows: during the sliding process, the electronic device completes one or more drawing task sequences, such as completing the doFrame and drawFrame stages of a frame and the GPU stage.
[0134] In some embodiments of this application, the electronic device tracks the execution status of the drawing task in real time through the monitoring mechanism of the upper-layer application framework, such as Hook technology. When the electronic device detects that at least one drawing task has been successfully completed, that is, the drawing task of a frame has ended, it means that the rendering work of the current frame has ended, and the drawing process has temporarily come to an end.
[0135] In some embodiments of this application, after a drawing task is completed, the electronic device can automatically transition from the drawing process to the non-drawing process. The sliding process is finely divided into drawing and non-drawing processes, where the non-drawing process is the window for the system to process non-drawing related tasks. At this time, the electronic device can remove the skipping restriction on non-drawing tasks, allowing the scheduler to select non-drawing tasks from the queue for execution.
[0136] In this way, electronic devices can switch to non-drawing processes normally after the drawing task is completed, and execute the delayed non-drawing tasks. This ensures the smoothness of the interface while maintaining the integrity of system functions, and ensures the reasonable flow of CPU resources between drawing and non-drawing tasks.
[0137] In some embodiments of this application, the drawing method provided in this application further includes the following step 601.
[0138] Step 601: When performing a non-drawing task, if the execution duration of the non-drawing task is greater than or equal to the third duration threshold, the electronic device reduces the CPU's operating frequency.
[0139] In some embodiments of this application, the aforementioned third duration threshold is a preset upper limit value for determining whether non-drawing tasks have excessively occupied the CPU. This threshold can be set through experience or experimentation to balance task execution requirements and power consumption control.
[0140] In some embodiments of this application, during the execution of non-drawing tasks, the electronic device can start a dedicated timer through the kernel scheduler to track the cumulative execution time of the non-drawing tasks.
[0141] In some embodiments of this application, the electronic device can compare the execution time of a non-drawing task with a third time threshold in real time. If the skipped time is less than the third time threshold, it indicates that the task execution time is within the allowable range, and the electronic device allows the task to continue execution to ensure basic functions; if the execution time is greater than or equal to the third time threshold, it indicates that the task may be excessively consuming CPU resources, and the electronic device can reduce the CPU frequency through DVFS.
[0142] In some embodiments of this application, when performing non-drawing tasks that consume a lot of CPU resources, the electronic device can reduce the CPU's operating frequency to reduce power consumption and heat generation. In other words, reducing the CPU's operating frequency is primarily targeted at non-drawing tasks that consume a lot of CPU resources, and is triggered when the electronic device is running such tasks to reduce power consumption and heat generation.
[0143] In this way, when entering the non-drawing stage and having been processing background tasks for a long time, electronic devices can actively reduce the CPU frequency to avoid maintaining an unnecessary high-performance state when there is no urgent drawing requirement, thereby reducing power consumption and heat generation, achieving energy efficiency management in sliding scenarios, and reducing resource waste while ensuring the integrity of background service functions.
[0144] In some embodiments of this application, the "lowering the CPU operating frequency of the electronic device" in step 601 above can be specifically implemented through steps 601a and 601b below.
[0145] Step 601a: The electronic device adjusts the upper limit of CPU utilization of the non-drawing thread corresponding to the non-drawing task from the third value to the fourth value.
[0146] In some embodiments of this application, the fourth value is less than the third value.
[0147] In some embodiments of this application, the aforementioned upper limit of CPU utilization can also be referred to as the maximum uclamp value or maximum load, which is the maximum load limit set by the kernel scheduler for a task, used to constrain the maximum load contribution that a task can be identified when running on the CPU. This value is a dimensionless weighting parameter that directly affects the system's calculation of the total CPU load.
[0148] In some embodiments of this application, the CPU operating frequency of the electronic device is determined by the sum of the loads of all running tasks within a preset sampling window. When the upper and lower limits of the CPU utilization rate of a task are adjusted, the load contribution of that task within the sampling window changes, thereby causing a change in the total CPU load and triggering the DVFS mechanism to complete frequency adjustment.
[0149] In some embodiments of this application, the third value mentioned above is the original upper limit of CPU utilization of the non-drawing thread before adjustment. It is the default upper limit of CPU utilization assigned to the non-drawing thread when it is created or initialized. It is usually a high base value, reflecting the level of CPU resource demand of the non-drawing task under normal circumstances.
[0150] In some embodiments of this application, the aforementioned fourth value is a new adjusted lower limit for CPU utilization of non-drawing threads. This value is preset through experience or experimentation, with the aim of proactively reducing the system's perception of the load on non-drawing threads. If the fourth value is less than the third value, it indicates that the system determines that the current non-drawing task execution time is already relatively long, and stricter resource control measures need to be taken, proactively triggering a frequency reduction by artificially reducing its load contribution.
[0151] In some embodiments of this application, when the electronic device is in a non-drawing process, it begins executing non-drawing tasks. At this time, the electronic device monitors the execution duration of the non-drawing tasks in real time. If the duration exceeds a third duration threshold, it indicates that the non-drawing tasks may be excessively consuming CPU resources. The electronic device can use the kernel interface to lower the maximum value of the uclamp for the non-drawing thread from the third value to the fourth value.
[0152] Step 601b: The electronic device lowers the CPU's operating frequency according to the fourth value.
[0153] In some embodiments of this application, after the electronic device adjusts the upper limit of CPU utilization of non-drawing threads from the third value to the fourth value, the system kernel scheduler can calculate the total CPU load in real time. As the load contribution of non-drawing threads decreases, the total CPU load decreases accordingly.
[0154] In some embodiments of this application, when the total load is lower than the load threshold corresponding to the current frequency level, the DVFS mechanism will be triggered to automatically adjust the frequency according to the real-time load, driving the CPU to reduce from the current high frequency state to a lower frequency, such as from 1.4GHz to 1.2GHz, in order to reduce CPU power consumption.
[0155] For example, such as Figure 9As shown, assuming the CPU is currently running tasks C, D, and E at different times, with task C having a CPU utilization of 50%, task D having 160%, and task E having 50%, the total utilization (total util) is 50(C) + 160(D) + 50(E) = 260, and the CPU frequency (freq) is 1.4GHz. Assuming task D is a non-drawing task, since the electronic device kernel calculates the workload of tasks running on the CPU in real time, the result is the sum of the task loads within the sampling window. In other words, the CPU frequency is determined by the sum of the task loads within the sampling window. Therefore, if task D runs for too long, the load will accumulate on the CPU, causing it to run at a high frequency of 1.4GHz, resulting in power consumption. The CPU load in the diagram represents the statistical value of the task load within the preset sampling window, and the total load is the cumulative value of the task loads within the sampling window. Changes in the total load directly trigger adjustments to the CPU frequency. Figure 9 ,like Figure 10 As shown, an electronic device can trigger CPU downclocking, for example, to 1.2GHz, by limiting the load of irrelevant task D, such as adjusting its CPU utilization to 120, so that the total utilization total util = 50(C) + 120(D) + 50(E) = 220.
[0156] In this way, electronic devices can actively limit the load contribution of non-drawing tasks by lowering the upper limit of CPU utilization of non-drawing threads from the higher third value to the lower fourth value, thereby indirectly triggering the CPU frequency to be reduced. This prevents background tasks from causing unnecessary functions due to excessive CPU resource consumption, so that the CPU can be stabilized at a lower and more reasonable frequency level during the non-drawing phase, thereby reducing heat generation and extending battery life.
[0157] This application provides a dynamic scheduling control scheme based on a sliding process, mainly including:
[0158] 1. Electronic devices can delay the execution of unimportant business threads during the sliding process, preventing them from monopolizing CPU resources and allowing the CPU to be allocated to tasks that truly need it. Unimportant tasks are defined as whether they are related to drawing. If they are not related to drawing, they are considered unimportant by default. Electronic devices can also provide configuration interfaces so that businesses can specify whether a task is unimportant.
[0159] 2. Electronic devices can divide the sliding process into drawing and non-drawing processes. During the drawing process, the CPU and GPU are primarily busy completing drawing-related tasks such as drawing, rendering, and display. The non-drawing process can be considered as the system handling non-drawing-related tasks, such as running a big data acquisition module in the background. Furthermore, the drawing process can be subdivided into doFrame and drawFrame processes. doFrame mainly handles screen rendering frames, while drawFrames are mainly responsible for converting user interface (UI) drawing instructions into actual pixel data. This allows for more refined control over each step of the sliding process.
[0160] 3. For non-drawing processes, since the tasks running at this time will not cause screen stuttering or tearing, electronic devices can limit the CPU usage time and load of tasks that consume a lot of CPU resources, so that non-critical tasks will not cause serious heat problems.
[0161] Figure 11 A schematic diagram illustrating the execution process of the drawing method provided in an embodiment of this application is shown, such as... Figure 11 As shown, the drawing method provided in this application embodiment may include the following steps 20 to 24.
[0162] Step 20: Slide to start.
[0163] Step 21: Irrelevant threads are scheduled during non-drawing processes.
[0164] Step 22: Increase the frame rate in time when the drawing process is about to drop frames.
[0165] Step 23: Restrict tasks that are not related to the drawing process.
[0166] Step 24: Slide to end.
[0167] This application provides a sliding-based dynamic scheduling control scheme, which can effectively avoid the problem of tasks vying for CPU resources during the sliding process. While ensuring the smoothness of the system, it effectively controls the reasonable distribution of system resources and solves the problems of stuttering and overheating during the sliding process.
[0168] Each of the above-described method embodiments, or various possible implementations of each method embodiment, can be executed individually or in combination of any two or more. The specific implementation can be determined according to actual usage requirements, and this application does not impose any restrictions on this.
[0169] The drawing method provided in this application can be executed by a drawing device. This application uses the example of a drawing device executing the drawing method to illustrate the drawing device provided in this application.
[0170] Figure 12 A schematic diagram of a possible structure of the drawing apparatus involved in some embodiments of this application is shown. For example... Figure 12 As shown, the drawing device 70 may include a generation module 71 and an execution module 72.
[0171] The aforementioned generation module 71 is used to create at least one drawing task in response to a sliding operation on the display interface. The drawing task is used to draw the screen frame to be displayed on the display interface.
[0172] The execution module 72 is used to execute at least one drawing task generated by the generation module 71, and during the execution of at least one drawing task, skips the execution of non-drawing tasks, which are tasks unrelated to drawing the screen frame to be displayed.
[0173] In one possible implementation, the execution module 72 is further configured to, when executing a first drawing task, increase the operating frequency of the central processing unit (CPU) if the execution duration of the first drawing task is greater than or equal to a first duration threshold, wherein the first drawing task is one of at least one drawing task.
[0174] In one possible implementation, the execution module 72 is specifically used to: adjust the lower limit of CPU utilization of the drawing thread corresponding to the first drawing task from a first value to a second value, wherein the second value is greater than the first value; and, according to the second value, increase the CPU operating frequency.
[0175] In one possible implementation, the execution module 72 is further configured to execute a non-drawing task if the duration of skipping the execution of the non-drawing task is greater than or equal to a second duration threshold after skipping the execution of the non-drawing task; or, execute a non-drawing task if at least one drawing task has been completed.
[0176] In one possible implementation, the execution module 72 is further configured to reduce the CPU's operating frequency if the execution duration of a non-drawing task is greater than or equal to a third duration threshold when performing a non-drawing task.
[0177] In one possible implementation, the execution module 72 is specifically used to: adjust the upper limit of CPU utilization of the non-drawing thread corresponding to the non-drawing task from a third value to a fourth value, wherein the fourth value is less than the third value; and, according to the fourth value, reduce the CPU operating frequency.
[0178] In one possible implementation, the at least one drawing task includes a drawing task in the frame rendering stage and a drawing task in the pixel drawing stage. The first duration threshold includes a first sub-threshold matching the frame rendering stage and a second sub-threshold matching the pixel drawing stage. When executing a drawing task in the frame rendering stage, the drawing thread corresponding to the first drawing task is a user interface thread. When executing a drawing task in the pixel drawing stage, the drawing thread corresponding to the first drawing task is a rendering thread.
[0179] In one possible implementation, each CPU of the aforementioned electronic device is configured with an independent task scheduling queue, and when executing at least one drawing task, priority is given to scheduling from the task scheduling queue of the CPU corresponding to the drawing task.
[0180] This application provides a drawing device. Since drawing tasks are used to draw the screen frames to be displayed on the display interface, they are the core element to ensure the smoothness of the user's visual experience. Non-drawing tasks are tasks unrelated to drawing the screen frames to be displayed, and their execution timing has a certain degree of flexibility and can be delayed. Therefore, by actively skipping the scheduling of non-drawing tasks during the execution of drawing tasks, it is possible to effectively avoid the preemption and competition of CPU resources by non-drawing tasks, so that the CPU computing power can be concentrated on serving the drawing tasks. This reduces unnecessary power consumption and system lag caused by resource contention, thereby improving the smoothness of the scrolling process under low power consumption.
[0181] The drawing device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the scope of the device.
[0182] The drawing device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0183] The drawing apparatus provided in this application embodiment can implement all the processes implemented in the above method embodiments, and will not be described again here to avoid repetition.
[0184] Optionally, such as Figure 13 As shown, this application embodiment also provides an electronic device 1000, including a processor 1001 and a memory 1002. The memory 1002 stores a program or instructions that can run on the processor 1001. When the program or instructions are executed by the processor 1001, they implement the various steps of the above drawing method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0185] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0186] Figure 14 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.
[0187] The electronic device 100 includes, but is not limited to, components such as: radio frequency unit 101, network module 102, audio output unit 103, input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, and processor 110.
[0188] Those skilled in the art will understand that the electronic device 100 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 110 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 14 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0189] The processor 110 is configured to create at least one drawing task in response to a sliding operation on the display interface, the drawing task being used to draw the screen frame to be displayed on the display interface.
[0190] The processor 110 described above is configured to perform at least one drawing task and skip the execution of non-drawing tasks during the execution of at least one drawing task. The non-drawing tasks are tasks unrelated to drawing the screen frame to be displayed.
[0191] Optionally, the processor 110 is further configured to, when executing a first drawing task, increase the operating frequency of the central processing unit (CPU) if the execution duration of the first drawing task is greater than or equal to a first duration threshold, wherein the first drawing task is one of at least one drawing task.
[0192] Optionally, the processor 110 is specifically configured to: adjust the lower limit of CPU utilization of the drawing thread corresponding to the first drawing task from a first value to a second value, wherein the second value is greater than the first value; and, according to the second value, increase the operating frequency of the CPU.
[0193] Optionally, the processor 110 is further configured to execute a non-drawing task if the duration of skipping the execution of the non-drawing task is greater than or equal to a second duration threshold after skipping the execution of the non-drawing task; or, execute a non-drawing task if at least one drawing task has been completed.
[0194] Optionally, the processor 110 is further configured to reduce the CPU's operating frequency if the execution duration of a non-drawing task is greater than or equal to a third duration threshold when performing a non-drawing task.
[0195] Optionally, the processor 110 is specifically configured to: adjust the upper limit of CPU utilization of the non-drawing thread corresponding to the non-drawing task from a third value to a fourth value, wherein the fourth value is less than the third value; and, according to the fourth value, reduce the operating frequency of the CPU.
[0196] Optionally, the above-mentioned at least one drawing task includes a drawing task in the frame rendering stage and a drawing task in the pixel drawing stage, and the above-mentioned first duration threshold includes a first sub-threshold matching the frame rendering stage and a second sub-threshold matching the pixel drawing stage; when executing a drawing task in the frame rendering stage, the drawing thread corresponding to the first drawing task is a user interface thread, and when executing a drawing task in the pixel drawing stage, the drawing thread corresponding to the first drawing task is a rendering thread.
[0197] Optionally, each CPU of the aforementioned electronic device is configured with an independent task scheduling queue, and when executing at least one drawing task, priority is given to scheduling from the task scheduling queue of the CPU corresponding to the drawing task.
[0198] This application provides an electronic device. Since drawing tasks are used to draw the screen frames to be displayed on the display interface, they are a core element in ensuring the smoothness of the user's visual experience. Non-drawing tasks are tasks unrelated to drawing the screen frames to be displayed, and their execution timing has a certain degree of flexibility and can be delayed. Therefore, by actively skipping the scheduling of non-drawing tasks during the execution of drawing tasks, it is possible to effectively avoid the preemption and competition of CPU resources by non-drawing tasks, so that the CPU computing power can be concentrated on serving the drawing tasks. This reduces unnecessary power consumption and system lag caused by resource contention, thereby improving the smoothness of the scrolling process under low power consumption.
[0199] The electronic device provided in this application embodiment can implement all the processes implemented in the above method embodiments and achieve the same technical effects. To avoid repetition, it will not be described again here. The beneficial effects of the various implementation methods in this embodiment can be found in the beneficial effects of the corresponding implementation methods in the above method embodiments. To avoid repetition, it will not be described again here.
[0200] It should be understood that, in this embodiment, the input unit 104 may include a graphics processing unit (GPU) 1041 and a microphone 1042. The GPU 1041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 106 may include a display panel 1061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
[0201] The memory 109 can be used to store software programs and various data. The memory 109 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 109 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 109 in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.
[0202] Processor 110 may include one or more processing units; optionally, processor 110 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 110.
[0203] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described drawing method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0204] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0205] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described drawing method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0206] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0207] This application provides a computer program product that is stored in a storage medium and executed by at least one processor to implement the various processes of the above-described drawing method embodiments, and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0208] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0209] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0210] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A drawing method, characterized in that, include: In response to a swipe operation in the display interface, at least one drawing task is created, the drawing task being used to draw a frame of the screen to be displayed in the display interface; Execute at least one drawing task, and skip non-drawing tasks during the execution of the at least one drawing task, wherein the non-drawing tasks are tasks unrelated to drawing the screen frame to be displayed.
2. The method according to claim 1, characterized in that, The method further includes: When executing the first drawing task, if the execution duration of the first drawing task is greater than or equal to a first duration threshold, the operating frequency of the central processing unit (CPU) is increased; the first drawing task is one of the at least one drawing task.
3. The method according to claim 2, characterized in that, Increasing the CPU's operating frequency includes: The lower limit of CPU utilization of the drawing thread corresponding to the first drawing task is adjusted from the first value to the second value, where the second value is greater than the first value; Based on the second value, the operating frequency of the CPU is increased.
4. The method according to claim 1, characterized in that, After skipping the execution of non-drawing tasks, the method further includes: If the duration of skipping the execution of the non-drawing task is greater than or equal to the second duration threshold, the non-drawing task shall be executed. Alternatively, if the at least one drawing task has been completed, the non-drawing task may be executed.
5. The method according to claim 4, characterized in that, The method further includes: When performing the non-drawing task, if the execution duration of the non-drawing task is greater than or equal to the third duration threshold, the CPU operating frequency is reduced.
6. The method according to claim 5, characterized in that, Lowering the CPU operating frequency includes: The upper limit of CPU utilization of the non-drawing thread corresponding to the non-drawing task is adjusted from the third value to the fourth value, where the fourth value is less than the third value; Based on the fourth value, the operating frequency of the CPU is reduced.
7. The method according to claim 3, characterized in that, The at least one drawing task includes a drawing task in the frame rendering stage and a drawing task in the pixel drawing stage. The first duration threshold includes a first sub-threshold matching the frame rendering stage and a second sub-threshold matching the pixel drawing stage. When executing a drawing task in the frame rendering stage, the drawing thread corresponding to the first drawing task is the user interface thread. When executing a drawing task in the pixel drawing stage, the drawing thread corresponding to the first drawing task is the rendering thread.
8. The method according to claim 1, characterized in that, Each CPU of the electronic device is configured with an independent task scheduling queue. When executing the at least one drawing task, the task is preferentially scheduled from the task scheduling queue of the CPU corresponding to the drawing task.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the drawing method as described in any one of claims 1 to 8.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the drawing method as described in any one of claims 1 to 8.