Data processing methods, apparatus, equipment, storage media and program products
By adding timed and canceled tasks to the message queue, the execution status of the drawing task is monitored, and the running resources of the user interface thread are increased in a timely manner. This solves the problem of frame dropping caused by sudden load on the user interface thread, and improves drawing efficiency and smoothness.
Patent Information
- Application Number
- CN202410386721.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-29
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-03-29
AI Technical Summary
During the execution of the user interface thread, frame drops may occur due to insufficient resources caused by sudden loads, which is difficult to solve effectively with existing technologies.
By adding scheduled tasks and canceling tasks in the message queue, the execution status of the drawing task is monitored, and the running resources of the user interface thread are increased in a timely manner to ensure the smooth execution of the drawing task.
It effectively reduces frame drops caused by sudden loads, improves the rendering efficiency of the user interface thread, and ensures smooth screen display.
Smart Images

Figure CN119248157B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic equipment technology, and in particular to a data processing method, apparatus, device, storage medium, and program product. Background Technology
[0002] Users can interact with electronic devices through a display screen. For example, they can perform interactive operations (such as clicking or swiping) on the screen to issue interactive commands to the electronic device. During the interaction, the user interface (UI) thread can perform the drawing operations of the displayed screen. The drawing operations of the screen consume certain computing resources. If a sudden load occurs during the execution of the UI thread, such as loading a large image or performing a database query, it may cause the UI thread to experience frame drops due to insufficient resources. Summary of the Invention
[0003] This application provides a data processing method, apparatus, device, storage medium, and program product to reduce frame dropping caused by insufficient UI thread resources.
[0004] In a first aspect, embodiments of this application provide a data processing method applicable to electronic devices, comprising: responding to user operations on an application interface to determine an image frame to be drawn; when a drawing frame trigger signal arrives, adding multiple drawing frame tasks corresponding to the image frame to a message queue of a user interface thread, wherein the message queue corresponds to at least one timed task, and each timed task is used to time the target drawing frame task to reach a set execution state; adding at least one cancellation task corresponding to at least one timed task to the message queue, wherein the cancellation task is used to cancel the corresponding timed task in advance when the corresponding target drawing frame task is in a set execution state; controlling the user interface thread to execute the multiple drawing frame tasks and at least one cancellation task in the message queue, wherein if any timed task finishes timing, increasing the running resources of the user interface thread to allow the user interface thread to continue executing the remaining drawing frame tasks.
[0005] In the data processing method provided in the first aspect, a cancellation task is added to the message queue for canceling the scheduled task. The execution status of the drawing frame task is timed by the scheduled task. If the drawing frame task is in the set execution state (e.g., execution completed or execution started) before the end of the scheduled task, the cancellation task cancels the scheduled task. If it cannot be in the set execution state before the end of the scheduled task, it indicates that a sudden load may occur, resulting in insufficient drawing resources for the UI thread, a long execution time for the drawing frame task, and the inability of the cancellation task to cancel the scheduled task. The UI thread needs more running resources. At this time, the running resources of the UI thread are increased in time so that the UI thread can continue to execute the remaining drawing frame tasks.
[0006] In one possible implementation, at least one cancellation task corresponding to at least one scheduled task is added to the message queue, including: for any scheduled task, adding the cancellation task corresponding to any scheduled task as the first or last target subtask in the target drawing frame task corresponding to any scheduled task to the message queue; adding cancellation tasks to the message queue for different scheduled tasks; if the cancellation task corresponding to the scheduled task is executed before the scheduled task ends, then the scheduled task is cancelled; if the cancellation task corresponding to the scheduled task is not executed in the message queue when the scheduled task ends, then the running resources of the UI thread are increased so that the UI thread can continue to execute the remaining drawing frame tasks in the message queue.
[0007] In one possible implementation, at least one timed task includes a first timed task, a second timed task, and / or a third timed task; wherein:
[0008] The first timed task is used to time all drawing frame tasks, and the time interval is the first time interval from the arrival of the drawing frame trigger signal. The first time interval is greater than the first preset duration from the arrival of the drawing frame trigger signal to the completion of at least two drawing frame tasks.
[0009] The second timed task is used to time the drawing frame task before the first drawing frame task, and the timed interval is the second time interval from the arrival of the self-drawing frame trigger signal. The second time interval is greater than the second preset time from the arrival of the self-drawing frame trigger signal to the start of the execution of the first drawing frame task.
[0010] The third timed task is used to time the second drawing frame task, and the timed interval is the third time interval from the start of the second drawing frame task. The third time interval is greater than the third preset duration from the start of the second drawing frame task to the completion of the second drawing frame task.
[0011] Optionally, the first time point is the time point that arrives earlier between the end of the third time interval and the predicted arrival time of the next frame trigger signal; when the first time point arrives, if the third timed task is not canceled in advance, the running resources of the UI thread are increased so that the UI thread can continue to execute the remaining frame drawing tasks.
[0012] Alternatively, the following provides a method for adding the cancellation task corresponding to a scheduled task to the message queue for various scheduled tasks:
[0013] For the first scheduled task, the first cancellation task corresponding to the first scheduled task is added to the message queue as the last target subtask in the target frame drawing task. The target frame drawing task refers to the last frame drawing task among all frame drawing tasks corresponding to the first scheduled task.
[0014] For the second scheduled task, the second cancellation task corresponding to the second scheduled task is added to the message queue as the first target subtask in the target frame drawing task. The target frame drawing task refers to the first frame drawing task corresponding to the second scheduled task.
[0015] For the third scheduled task, the third cancellation task corresponding to the third scheduled task is added to the message queue as the last target subtask in the target drawing frame task. The target drawing frame task refers to the second drawing frame task corresponding to the third scheduled task.
[0016] Optionally, during the execution of multiple frame drawing tasks, the execution status of each task in the message queue is monitored; if the execution reaches the target subtask in the target frame drawing task corresponding to any timed task, then any timed task is canceled.
[0017] In one possible implementation, at least one timing task further includes: a fourth timing task, the message queue including: a signal request task located after multiple drawing frame tasks; the signal request task is used to request the next drawing frame trigger signal; wherein, the timing interval of the fourth timing task is a fourth time interval from the arrival of the drawing frame trigger signal, the fourth time interval being greater than a preset fourth preset duration of the adjacent drawing frame trigger signal; the method includes:
[0018] When multiple drawing frame tasks in the message queue have been completed, a signal request task is executed to request the trigger signal for the next drawing frame; upon receiving the trigger signal for the next drawing frame, the fourth timed task is prematurely cancelled.
[0019] If the fourth timed task ends, increase the runtime resources of the user interface thread so that the user interface thread can continue to execute the remaining drawing frame tasks.
[0020] One possible implementation involves increasing the runtime resources of the UI thread, including:
[0021] Increase the target computing resource object corresponding to the UI thread from the current first frequency to the second frequency;
[0022] and / or
[0023] Increase the UI thread's utilization rate of the target computing resource object from the first utilization rate to the second utilization rate to increase the UI thread's runtime resources.
[0024] Optionally, after the message queue is cleared, the method can also restore the increased runtime resources to the initial runtime resources, and execute the drawing task of the next image frame using the initial runtime resources. Specifically, the frequency of the target computing resource object is restored from the second frequency to the first frequency, and the occupancy rate of the UI thread on the target computing resource object is restored from the second occupancy rate to the first occupancy rate.
[0025] Secondly, embodiments of this application also provide a data processing apparatus, which is applied to an electronic device. The apparatus includes, from top to bottom, an application layer, an application framework layer, a system library, and a kernel layer. The application layer includes a target application, the application framework layer includes a message queue, a frame drawing module, and a scheduling module, the system library includes an interface module for the scheduling module, and the kernel layer includes a resource adjustment module.
[0026] The drawing frame module is used to add multiple drawing frame tasks corresponding to an image frame to the message queue of the user interface thread when the drawing frame trigger signal arrives. The message queue corresponds to at least one timed task, and each timed task is used to time the target drawing frame task to reach a set execution state. It also calls the user interface thread to execute multiple drawing frame tasks and at least one cancellation task in the message queue. The image frame is the image frame to be drawn determined by the target application in response to user operation.
[0027] The scheduling module is used to add at least one cancellation task corresponding to at least one scheduled task to the message queue. The cancellation task is used to cancel the corresponding scheduled task in advance when the corresponding target drawing frame task is in the set execution state. In addition, if any scheduled task ends during the execution of multiple drawing frame tasks, the interface module notifies the resource adjustment module to increase the running resources of the user interface thread.
[0028] The resource adjustment module is used to increase the runtime resources of the user interface thread so that the UI thread can continue to execute the remaining drawing frame tasks.
[0029] Frequent communication between the application framework layer and the kernel layer can lead to significant overhead. In this embodiment, compared to adding at least one scheduled task and its corresponding cancellation task to the kernel layer, adding at least one scheduled task and its corresponding cancellation task to the application framework layer, when it is determined that this will increase the runtime resources for the UI thread, allows the application framework layer to interact with the kernel layer's resource adjustment module through an interface module in the system library. This reduces the communication overhead between the application framework layer and the kernel layer.
[0030] In one possible implementation, the resource adjustment module includes: a first adjustment module and / or a second adjustment module;
[0031] The first adjustment module is used to increase the target computing resource object corresponding to the UI thread from the current first frequency to the second frequency, so as to increase the running resources of the UI thread;
[0032] The second adjustment module is used to increase the UI thread's utilization rate of the target processor from the first utilization rate to the second utilization rate, so as to increase the UI thread's running resources.
[0033] Thirdly, embodiments of this application also provide an electronic device, including: a memory and a processor; the memory for storing a computer program; and the processor, coupled to the memory, for executing the computer program to implement the steps in the data processing method provided in embodiments of this application.
[0034] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the steps in the data processing method provided in embodiments of this application.
[0035] Fifthly, embodiments of this application also provide a computer program product, including a computer program / instructions, which, when executed by a processor, cause the processor to implement the steps in the data processing method provided in embodiments of this application.
[0036] It should be understood that the second to fifth aspects of the embodiments of this application are consistent with the technical solutions of the first aspect of the embodiments of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be described again. Attached Figure Description
[0037] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0038] Figure 1a A schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this application;
[0039] Figure 1b A flowchart illustrating a data processing method provided for an exemplary embodiment of this application;
[0040] Figure 2a A schematic diagram illustrating an embodiment of this application where the first scheduled task is not canceled, thereby increasing runtime resources;
[0041] Figure 2b A schematic diagram illustrating an embodiment of this application where the second scheduled task is not canceled, thereby increasing runtime resources;
[0042] Figure 2c A schematic diagram illustrating an embodiment of this application where a third scheduled task is not canceled, thereby increasing runtime resources;
[0043] Figure 2d A schematic diagram illustrating an embodiment of this application where a fourth scheduled task is not canceled, thereby increasing runtime resources;
[0044] Figure 3A software architecture diagram corresponding to an electronic device provided as an exemplary embodiment of this application;
[0045] Figure 4 A timing interaction diagram is provided for an exemplary embodiment of this application. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] To address frame drops caused by insufficient resources in the UI thread, increasing runtime resources is a direct solution. The key is knowing under what conditions to increase runtime resources. In this embodiment, a cancellation task is added to the message queue to cancel scheduled tasks. The scheduled task monitors the execution status of the drawing task, thus sensing the drawing progress. If the drawing task is in a set execution state (e.g., completed or started) before the scheduled task ends, the cancellation task cancels the scheduled task. If it cannot be in the set execution state before the scheduled task ends, it indicates a possible sudden load, leading to insufficient drawing resources for the UI thread, a longer drawing task execution time, and the inability of the cancellation task to cancel the scheduled task. The UI thread requires more runtime resources; therefore, the runtime resources for the UI thread are increased to allow it to continue executing the remaining drawing tasks.
[0048] Furthermore, during the frame drawing process, instrumentation is used in the frame drawing process at the upper layer of the electronic device (e.g., the application framework layer) to monitor the frame drawing progress, promptly identify frame drawing progress delays caused by sudden loads, and increase the running resources of the UI thread through modules in the kernel layer to accelerate frame drawing and reduce frame dropping.
[0049] Furthermore, by instrumenting the application framework layer and detecting a delay in the drawing frame progress, the kernel layer is notified to increase the running resources of the UI thread. Compared with the implementation method of instrumenting the drawing frame progress in the kernel layer, the method provided in this application can reduce the communication overhead between the application framework layer and the kernel layer.
[0050] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0051] Figure 1b This is a flowchart illustrating a data processing method provided for an exemplary embodiment of this application. Figure 1b As shown, the method includes:
[0052] R201: Respond to user actions on the application interface and determine the image frame to be drawn;
[0053] R202. When the frame trigger signal arrives, add multiple frame drawing tasks corresponding to the image frame to the message queue of the UI thread. The message queue corresponds to at least one timed task. Each timed task is used to time the target frame drawing task to reach the set execution state.
[0054] R203. Add at least one cancellation task corresponding to at least one scheduled task to the message queue. The cancellation task is used to cancel the corresponding scheduled task in advance when the corresponding target drawing task is in the set execution state.
[0055] R204 controls the UI thread to execute multiple frame drawing tasks and at least one cancellation task in the message queue. If any timed task ends on time, the UI thread's runtime resources are increased so that the UI thread can continue to execute the remaining frame drawing tasks.
[0056] In this embodiment, the electronic device can display the application's interface. The application can be any type of application, such as social media applications, game applications, video applications, and shopping applications. The application interface can be a homepage or other pages; there is no limitation on this. When the application interface is displayed on the electronic device, the user can perform user operations on the screen. For example, user operations can include, but are not limited to, swiping or clicking. Swiping operations can include, but are not limited to, zooming in, zooming out, or dragging, and clicking operations can include, but are not limited to, single-clicking or double-clicking.
[0057] In this embodiment, the electronic device can respond to user operations on the application interface to determine the image frame to be drawn. The image frame to be drawn is the image frame that can be displayed on the UI, determined in response to the user operation. For example, in a social application, a user can swipe up to view "more posts" or swipe down to "refresh content." The image frame to be drawn can be the image frame corresponding to the "more posts" option determined by the user's swipe up, or it can be the image frame corresponding to the "refresh content" option determined by the user's swipe up. One user operation can correspond to one image frame to be drawn, or it can correspond to multiple image frames to be drawn, such as two, three, or five.
[0058] In this embodiment, the frame trigger signal is a signal that can trigger an electronic device to draw an image frame. The frame trigger signal can be an On Vertical synchronization (OnVsync) signal. The frame trigger signal is generally triggered after the synchronization signal arrives. Specifically, after receiving the synchronization signal, the OnVsync method is called to generate the frame trigger signal. After calling the OnVsync method, a frame drawing (doFrame) operation can be performed. doFrame includes various frame drawing tasks, such as input, animation, and drawing.
[0059] Synchronization signals are used to synchronize the screen refresh rate and frame rate, preventing screen tearing. For example, a synchronization signal could be a vertical synchronization (Vsync) signal. Typically, an electronic device sends a synchronization signal (Vsync signal) every frame (e.g., 16.6ms). However, not all applications can receive this signal; only subscribed applications can. Each subscription allows the application to receive a synchronization signal, and resubscription is required to receive subsequent signals. The advantage of this is that if the UI thread remains unchanged, not subscribing to the synchronization signal prevents it from being received, reducing unnecessary drawing operations.
[0060] The screen refresh rate refers to the number of times the screen refreshes per second, measured in Hertz (Hz). The screen refresh rate depends on fixed hardware parameters and generally does not change. For example, the screen refresh rate can be 60Hz, 90Hz, or 120Hz. Correspondingly, if the screen refresh rate is 60Hz, the frame length is 1 / 60 = 16.7ms; if the screen refresh rate is 90Hz, the frame length is 1 / 90 = 11.1ms; and if the screen refresh rate is 120Hz, the frame length is 1 / 120 = 8.33ms. The frame rate refers to the number of frames drawn per second, measured in frames per second (fps). The frame rate changes dynamically. For example, when the screen is static and no drawing operations are performed, the data displayed after the screen refresh is still in the buffer.
[0061] Upon receiving the first frame trigger signal, the UI executes multiple frame-drawing tasks for the first image frame. Then, it waits for the second frame trigger signal to arrive and executes the same tasks for the second image frame. If all frame-drawing tasks are completed before the second frame trigger signal arrives, the UI will refresh to reflect the content of the first image frame when the second frame trigger signal arrives. Otherwise, the UI will not refresh and will still display the content of the previous image frame, indicating a frame drop. If a sudden load is detected on the UI thread before the second frame trigger signal arrives, and resources are promptly increased for the UI thread, allowing it to complete the multiple frame-drawing tasks for the second image frame before the second frame trigger signal arrives, then the frame drop will not occur.
[0062] In this embodiment, the image frame drawing progress is perceived based on a message queue, no longer relying on the native drawing logic of the electronic device. It does not need to perceive the application's own logic or the load brought by new drawing frameworks such as Flutter. It is no longer limited to being able to perceive sudden load situations, covering more application scenarios. It can more accurately increase runtime resources (e.g., increase frequency) for the UI thread, ensuring the supply of drawing frame resources. Flutter is a toolkit for building UIs.
[0063] In this embodiment, the UI thread has a corresponding message queue, which stores various tasks that the UI thread needs to execute. For example, the message queue may include frame drawing tasks. A frame drawing task is an operation involved in the drawing process of an image frame, and frame drawing tasks can be various callbacks. Frame drawing tasks may include, but are not limited to: input callback (CALLBACK_INPUT), animation callback (CALLBACK_ANIMATION), insert animation callback (CALLBACK_INSETS_ANIMATION), window refresh callback (CALLBACK_TRAVERSAL), commit callback (CALLBACK_COMMIT), drawing callback (CALLBACK_DRAWING), preloading (Recycler View prefetch, RVprefetch), scrolling (RV scroll), and binding view (RV on bind view), etc. Each image frame corresponds to multiple frame drawing tasks, and these multiple frame drawing tasks can include multiple of the above-mentioned frame drawing tasks. When a frame drawing trigger signal arrives, multiple frame drawing tasks corresponding to the image frame can be added to the UI thread's message queue.
[0064] In this embodiment, the message queue corresponds to at least one timed task, and each timed task is used to time the target rendering frame task to reach a set execution state. The execution state can be "started execution," "execution completed," or "in execution." Each timed task can time at least one rendering frame task, and the target rendering frame task can be the last rendering frame task among the at least one. It should be noted that when each timed task times a rendering frame task, that single rendering frame task is the target rendering frame task.
[0065] In this embodiment, in addition to adding multiple frame-drawing tasks to the message queue, at least one cancellation task corresponding to a timed task can also be added to the message queue. Each cancellation task is added to the message queue by instrumentation, specifically to the target frame-drawing task corresponding to each timed task. Each timed task corresponds to one cancellation task. Each cancellation task is used to cancel the corresponding timed task in advance when the corresponding target frame-drawing task is in the set execution state. The set execution state can be the target frame-drawing task being in the start execution state or the execution completed state. If the target frame-drawing task is in the set execution state before the timed task ends, it is considered that the initial running resources of the UI thread are sufficient for frame drawing, and frame dropping will not occur due to sudden load. There is no need to increase the running resources of the UI thread, and the cancellation task cancels the timed task. The canceled timed task no longer counts down. If the target frame-drawing task is not in the set execution state when the timed task ends, it is considered that a sudden load may occur, causing the initial running resources of the UI thread to be insufficient to complete the above multiple frame-drawing tasks. In this case, the running resources of the UI thread can be increased so that the UI thread can continue to execute the remaining frame-drawing tasks.
[0066] In this embodiment, the UI thread is controlled to execute tasks in the message queue sequentially. The message queue contains multiple frame-drawing tasks and cancellation tasks. During the execution of tasks in the message queue, the timing of at least one timer is monitored to see if it has ended. If the timing of any timed task ends, it indicates that the target frame-drawing task corresponding to that timed task or the task preceding it has been taking a long time, which may cause a sudden load and result in insufficient runtime resources for the UI thread to execute frame-drawing tasks. In this case, the runtime resources of the UI thread are increased to allow the UI thread to continue executing the remaining frame-drawing tasks.
[0067] Optionally, if any scheduled task is canceled by its corresponding cancellation task before it ends, it can be assumed that no sudden load has occurred, and the UI thread can execute the frame drawing task on time based on the initial running resources without increasing the running resources of the UI thread.
[0068] The runtime resources can be computing resources or memory resources, etc. The computing resource objects that provide computing resources can include, but are not limited to: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Data Processing Unit (DPU), Tensor Processing Unit (TPU), Cloud Infrastructure Processing Unit (CIPU), and Application Specific Integrated Circuit (ASIC), etc.
[0069] In this embodiment, a cancellation task is added to the message queue for canceling the scheduled task. The execution status of the drawing frame task is timed by the scheduled task. If the drawing frame task is in the set execution state (e.g., completed or started) before the end of the scheduled task, the cancellation task cancels the scheduled task. If it cannot be in the set execution state before the end of the scheduled task, it indicates that a sudden load may occur, resulting in insufficient drawing resources for the UI thread and a long execution time for the drawing frame task. The cancellation task cannot cancel the scheduled task, and the UI thread needs more running resources. At this time, the running resources of the UI thread can be increased in time so that the UI thread can continue to execute the remaining drawing frame tasks.
[0070] In one optional embodiment, the implementation of adding at least one cancellation task corresponding to at least one scheduled task to the message queue is not limited. For any scheduled task, the cancellation task corresponding to the scheduled task can be added to the message queue as the first target subtask in the target rendering task of the scheduled task, or the cancellation task corresponding to the scheduled task can be added to the message queue as the last target subtask in the target rendering task of the scheduled task, or the cancellation task corresponding to the scheduled task can be added to the message queue as the last task in the message queue.
[0071] For example, the message queue includes: drawing frame task B1, drawing frame task B2 and drawing frame task B3. Timed task A1 is used to time drawing frame task B2. Drawing frame task B2 can be used as the target drawing frame task. The cancellation task C1 corresponding to timed task A1 can be added to the message queue as the first target subtask of drawing frame task B2, or the cancellation task C1 can be added to the message queue as the last target subtask of drawing frame task B2.
[0072] For example, the message queue includes: frame drawing task D1, frame drawing task D2, frame drawing task D3 and frame drawing task D4. Timed task A2 is used to time frame drawing tasks D1, D2 and D3. Frame drawing task D3 can be used as the target frame drawing task, and the cancellation task C2 corresponding to timed task A2 can be added to the message queue as the last target subtask of frame drawing task D3.
[0073] In one optional embodiment, the scheduled task may include at least one of a first scheduled task, a second scheduled task, and a third scheduled task. The first, second, and third scheduled tasks are described exemplarily below.
[0074] The first timed task refers to timing all drawing frame tasks of the image frame, with the timing interval being the first time interval from the arrival of the self-drawing frame trigger signal. This first time interval is greater than a first preset duration for the UI thread to complete the execution of at least two drawing frame tasks. This first preset duration can be an empirical value, that is, the first preset duration can be the duration from the arrival of the self-drawing frame trigger signal to the completion of the at least two drawing frame tasks by the UI thread using initial runtime resources, under the condition of no sudden load. For example, if the current frame length is 16.67ms and the first preset duration is 4ms, then the first time interval can be greater than 4ms and less than 16.67ms; for example, the first time interval can be 8ms.
[0075] The second timed task is used to time the drawing frame tasks preceding the first drawing frame task. The time interval is the second time interval from the arrival of the self-drawing frame trigger signal. This second time interval is greater than the second preset duration from the arrival of the self-drawing frame trigger signal to the start of the UI thread executing the first drawing frame task. The second preset duration can be an empirical value, or it can be the preset duration from the arrival of the self-drawing frame trigger signal to the start of the UI thread executing the first drawing frame task using initial runtime resources, assuming no sudden load. The first drawing frame task can be a non-first drawing frame task among multiple drawing frame tasks. For example, the first drawing task is implemented as a drawing task, and the second preset duration is 1 / 3 of the frame length, such as (1 / 3)*16.67=5.56ms. The second time interval can be greater than 5.56ms and less than 16.67ms.
[0076] The third timed task is used to time the second frame drawing task, with the timing interval being a third time interval from the start of the second frame drawing task. The second frame drawing task can be any one of multiple frame drawing tasks. The start time of the second frame drawing task is uncertain and is influenced by the execution status of other tasks preceding it. These other tasks can be other frame drawing tasks preceding the second frame drawing task, tasks adding multiple image frames to the message queue, or tasks adding at least one cancellation task to the message queue; there are no restrictions on this. If other tasks execute quickly, the start time of the second frame drawing task will be relatively earlier; if other tasks execute slowly, the start time of the second frame drawing task will be relatively later. Therefore, the third time interval can be set to be greater than a third preset duration from the start of the second frame drawing task to the completion of the second frame drawing task by the UI thread. This third preset duration can be an empirical value, or it can be a preset duration from the start of the second frame drawing task to its completion under conditions of no sudden load. For example, the second frame drawing task is implemented as an animation task, and the third preset duration is 1 / 2 frame length, such as (1 / 2)*16.67=8.34ms. The third time interval can be greater than 8.34ms and less than 16.67ms.
[0077] Optionally, the start time of the second frame-drawing task is uncertain. If the second frame-drawing task starts late, the time from the start of the second frame-drawing task to the end of the third time interval may be later than the predicted arrival time of the next frame-drawing trigger signal. The implementation of the predicted arrival time of the next frame-drawing trigger signal is not limited; for example, a time interval of one frame length after the arrival of the frame-drawing trigger signal can be used as the predicted arrival time of the next frame-drawing trigger signal. This can be understood as follows: when the predicted time arrives, the second frame-drawing task has not yet been completed, resulting in the UI thread not completing all frame-drawing tasks in the message queue, leading to frame drops. Based on this, the earlier of the end time of the third time interval and the predicted arrival time of the next frame-drawing trigger signal is determined as the first time point. When the first time point arrives, if the third timed task has not been canceled in advance, the running resources of the UI thread are increased to allow the UI thread to continue executing the remaining frame-drawing tasks.
[0078] Optionally, for ease of distinction and description, the cancellation task corresponding to the first scheduled task is referred to as the first cancellation task, the cancellation task corresponding to the second scheduled task is referred to as the second cancellation task, and the cancellation task corresponding to the third scheduled task is referred to as the third cancellation task. The target drawing frame task differs depending on the scheduled task, and the implementation method for adding the cancellation task corresponding to the scheduled task to the message queue also differs. An example is described below.
[0079] For the first scheduled task, the target frame drawing task refers to the last frame drawing task among all frame drawing tasks corresponding to the first scheduled task; the first cancellation task is added to the message queue as the last target subtask in the target frame drawing task.
[0080] For the second scheduled task, the target drawing frame task refers to the first drawing frame task corresponding to the second scheduled task; the second cancellation task is added to the message queue as the first target subtask in the first drawing frame task.
[0081] For the third scheduled task, the target drawing frame task refers to the second drawing frame task corresponding to the third scheduled task. The third cancellation task corresponding to the third scheduled task is added to the message queue as the last target subtask in the second drawing frame task.
[0082] Optionally, during the execution of multiple frame-drawing tasks, the execution status of each task in the message queue can be monitored. If the execution reaches a target subtask within the target frame-drawing task corresponding to any scheduled task, indicating that the corresponding cancellation task can be executed, then any scheduled task is cancelled. This target subtask can be the first or the last target subtask. If, upon the termination of any scheduled task, the target subtask corresponding to that scheduled task has not been executed, then the runtime resources of the UI thread are increased to allow the UI thread to continue executing the remaining frame-drawing tasks.
[0083] The following is an illustrative description with reference to the accompanying drawings.
[0084] For example, the first timed task is used to time all drawing frame tasks of an image frame. The first timed interval is half the frame length from the arrival of the drawing frame trigger signal. If the frame length is 16ms, the first timed interval is 8ms. The first cancellation task can be the last target subtask of the last drawing frame task. If the target subtask is executed before the first timed task ends, the first timed task is cancelled early. If the target subtask is not executed when the first timed task ends, the runtime resources of the UI thread are increased so that the UI thread can continue to execute the remaining drawing frame tasks. Figure 2a Before the first scheduled task ends, the first cancellation task is not executed. When the first scheduled task ends, from the start of the frame drawing trigger signal until the 8ms interval arrives, the UI thread's runtime resources are increased. The white box represents the frame drawing task, and the black box represents the cancellation task.
[0085] For example, a second timed task is used to time the first drawing frame task. The first drawing frame task is implemented as a drawing operation. The second timer interval is 1 / 3 of the frame length from the arrival of the drawing frame trigger signal. If the frame length is 16ms, the second timer interval is 5ms. The second cancellation task can be the first target subtask of the first drawing frame task, which can be implemented as a beginDraw task. If the target subtask is executed before the second timed task ends, and the task has already started executing the first drawing frame task, then the second timed task is cancelled. If the target subtask has not been executed when the second timed task ends, it is assumed that the first drawing frame task has not yet started, and the UI thread's runtime resources are increased so that the UI thread can continue to execute the remaining drawing frame tasks. Figure 2b In the code, the first frame-drawing task does not begin execution until the second timed task ends. At the end of the second timed task's timeout period (i.e., from the start of the frame-drawing trigger signal until the 5ms interval arrives), the UI thread's runtime resources are increased. White boxes represent frame-drawing tasks, and black boxes represent canceled tasks.
[0086] For example, the third timed task is used to time the second frame-drawing task, which is an animation operation. The third timer interval is half the frame length starting from the start of the second frame-drawing operation. If the frame length is 12ms, half the frame length is 6ms. The third cancellation task can be the last target subtask of the second frame-drawing task, which can be the endAnim task. If the target subtask is executed before the third timed task ends, it means the second frame-drawing task has been completed, and the third timed task is cancelled. If the target subtask is not executed when the third timed task ends, it means the second frame-drawing task has not been completed, and the UI thread's runtime resources are increased so that the UI thread can continue to execute the remaining frame-drawing tasks. Figure 2c As shown, the second frame-drawing task is not completed before the third timed task ends. When the third timed task ends (i.e., from the start of the second frame-drawing task until the 6ms interval), the UI thread's runtime resources are increased. The white boxes represent frame-drawing tasks, and the black boxes represent canceled tasks.
[0087] In an optional embodiment, at least one timing task may include a fourth timing task in addition to the first, second, and third timing tasks described above. The fourth timing task is used to perform delay detection on the frame trigger signal. The timing interval of the fourth timing task is a fourth time interval from the arrival of the frame trigger signal. This fourth time interval is greater than a preset fourth preset duration of adjacent frame trigger signals. The preset fourth duration can be an empirical value; for example, the preset duration between adjacent frame trigger signals can be one frame. For example, the preset fourth duration is 16.7 ms, and the fourth time interval is greater than 16.7 ms. For example, the fourth time interval can be 16.7 ms plus 1 ms and then rounded up. This indicates rounding up to the nearest integer.
[0088] In addition to adding multiple drawing frame tasks and at least one cancellation task to the message queue, a signal request task can also be added to the message queue. For example, a signal request task can be added after multiple drawing frame tasks. The signal request task is used to request the next drawing frame trigger signal. Based on this, when multiple drawing frame tasks in the message queue have been completed, the signal request task is executed to request the next drawing frame trigger signal. After requesting the next drawing frame trigger signal, a synchronization signal can be requested (subscribed to). After the synchronization signal arrives, the OnVsync method is executed to generate the next drawing frame trigger signal. If the next drawing frame trigger signal is received before the fourth timed task ends, it indicates that multiple drawing frame tasks for the image frame have been completed, and the fourth timed task is canceled without increasing the UI thread's runtime resources. If the fourth timed task ends on time, it indicates that multiple drawing frame tasks for the image frame have not been completed, and the UI thread's runtime resources are increased so that the UI thread can continue to execute the remaining drawing frame tasks. Figure 2d As shown, the fourth timed task is used to detect the delay of the frame trigger signal, with a fourth time interval of 18ms. If the next frame trigger signal is not received by the end of the fourth timed task, the runtime resources of the UI thread are increased.
[0089] In one alternative embodiment, the method for increasing the runtime resources of the UI thread is not limited. An exemplary description follows.
[0090] For example, the target computing resource object (e.g., CPU) corresponding to the UI thread can be increased from its current first frequency to a second frequency to increase the runtime resources of the UI thread. For example, the CPU frequency can be increased from 2 gigahertz (GHz) to 3 GHz, or to the CPU's maximum frequency.
[0091] For example, the utilization rate of the UI thread on the target computing resource object can be increased from a first utilization rate to a second utilization rate to increase the runtime resources of the UI thread. This can be achieved by setting the UI thread's utilization rate on the target computing resource object using the utilization clamping parameter (UCLAMP). The UCLAMP parameter includes an upper limit (UCLAMP_MAX) and a lower limit (UCLAMP_MIN). The UI thread's utilization rate on the target computing resource object can fall between these two values. UCLAMP_MIN means increasing the UI thread's utilization rate, while UCLAMP_MAX means limiting the UI thread's utilization rate. This can be achieved by increasing the lower limit, for example, by adjusting it to 80%, 90%, or 100%.
[0092] For example, the target computing resource object corresponding to the UI thread can be increased from the current first frequency to the second frequency; and the occupancy rate of the UI thread on the target computing resource object can be increased from the first occupancy rate to the second occupancy rate, so as to increase the running resources of the UI thread.
[0093] Optionally, after the message queue is cleared, the frequency of the target computing resource object can be restored from the second frequency to the first frequency, and the occupancy rate of the UI thread on the target computing resource object can be restored from the second occupancy rate to the first occupancy rate, so as to reset the running resources of the UI thread and enable the UI thread to perform drawing operations on the next image frame through the initial running resources.
[0094] Regarding the embodiments provided in this application Figure 1b The detailed implementation methods and beneficial effects of each step in the method shown have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0095] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps S201 to S203 can be device A; or the execution subject of steps S201 and S202 can be device A, and the execution subject of step S203 can be device B; and so on.
[0096] Furthermore, in some processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as S201, S202, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0097] In addition to providing data processing method embodiments, this application also provides a data processing apparatus. The process of the data processing apparatus provided in this application embodiment will be described below.
[0098] Figure 3 This application provides a schematic diagram of a data processing device, which, from top to bottom, includes: an application layer, an application framework layer, a system library, and a kernel layer. Each layer has a clear role and division of labor. Layers communicate with each other through software interfaces.
[0099] The application layer includes the target application, which can be any application within the application layer.
[0100] The application framework layer may also include: a message queue, a frame rendering module, and a scheduling module. The message queue can be the UI thread's message queue, the frame rendering module can be implemented as a Choreographer module, and the scheduling module can be a FrameAwareSched module.
[0101] The system library includes: an interface module for the scheduling module;
[0102] The kernel layer includes: a resource adjustment module.
[0103] The frame drawing module is used to add multiple frame drawing tasks corresponding to an image frame to the message queue of the UI thread when a frame drawing trigger signal arrives. The message queue corresponds to at least one timed task, and each timed task is used to time the target frame drawing task to reach a set execution state. It also calls the UI thread to execute multiple frame drawing tasks and at least one cancellation task in the message queue. The image frame is the image frame to be drawn determined by the target application in response to user operation.
[0104] The scheduling module is used to add at least one cancellation task corresponding to at least one scheduled task to the message queue. The cancellation task is used to cancel the corresponding scheduled task in advance when the corresponding target drawing frame task is in the set execution state. In addition, if any scheduled task ends during the execution of multiple drawing frame tasks, the resource adjustment module is notified through the interface module to increase the running resources of the UI thread.
[0105] The resource adjustment module is used to increase the runtime resources of the UI thread so that the UI thread can continue to execute the remaining drawing frame tasks.
[0106] In this embodiment, frequent communication between the application framework layer and the kernel layer will result in significant overhead. In this embodiment, compared to adding at least one scheduled task and its corresponding at least one cancellation task to the kernel layer, adding at least one scheduled task and its corresponding at least one cancellation task to the application framework layer, when it is determined that this can increase the runtime resources of the UI thread, allows the application framework layer to interact with the kernel layer's resource adjustment module through an interface module in the system library, thus reducing the communication overhead between the application framework layer and the kernel layer.
[0107] Optionally, the resource adjustment module includes: a first adjustment module and a second adjustment module.
[0108] The first adjustment module is used to increase the target computing resource object corresponding to the UI thread from the current first frequency to the second frequency, so as to increase the running resources of the UI thread;
[0109] The second adjustment module is used to increase the UI thread's utilization rate of the target computing resource object from the first utilization rate to the second utilization rate, thereby increasing the UI thread's runtime resources. The first and second adjustment modules can coexist or exist independently.
[0110] For a detailed description of the implementation methods and effects of the aforementioned data processing device, please refer to the foregoing embodiments, which will not be repeated here.
[0111] In some embodiments, when the data processing device is applied to the Android system, in addition to the application layer, application framework layer, system library, and kernel layer described above, the device also includes the Android runtime at the layer containing the system library, such as... Figure 3 As shown. Among them, the application framework layer, system libraries, and kernel layer, in addition to containing... Figure 3 In addition to the modules shown, other modules may also be included, but they are not listed here. Figure 3 As shown in the image.
[0112] Detailed information about each layer is as follows:
[0113] The application layer includes a series of applications, which may include, but are not limited to: camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS and other applications.
[0114] The application framework layer provides APIs and a programming framework for applications in the application layer. The application framework layer includes predefined functions. It may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0115] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0116] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.
[0117] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0118] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0119] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0120] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0121] 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.
[0122] 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.
[0123] 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.
[0124] System libraries can include multiple functional modules. Examples include: a surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), and 2D graphics engines (e.g., SGL). Figure 3 Only a portion is shown.
[0125] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0126] The media library supports playback and recording of various common audio and video formats, as well as still image files. It also supports multiple audio and video encoding formats.
[0127] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0128] A 2D graphics engine is a graphics engine for 2D drawing.
[0129] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0130] In addition to the internal architecture diagram described above, this embodiment also provides a timing interaction diagram, combined with... Figure 3 The structure shown is as follows: Figure 4 As shown, the timing interaction diagram includes the following steps:
[0131] S1. The user initiates a swipe operation on the application interface.
[0132] S2. The target application responds to user actions on the application interface and determines the image frame to be drawn.
[0133] S3, the frame drawing module determines multiple frame drawing tasks for image frames.
[0134] S4. When the frame drawing trigger signal arrives, the frame drawing module adds the multiple frame drawing tasks to the message queue of the UI thread.
[0135] S5. The scheduling module maintains at least one scheduled task corresponding to a message queue; each scheduled task is used to time the target drawing frame task to reach a set execution state.
[0136] S6. The scheduling module adds at least one cancellation task to the message queue. The cancellation task is used to cancel the corresponding timed task in advance when the corresponding target drawing frame task is in the set execution state.
[0137] S7, the frame drawing module calls the UI thread to execute tasks in the message queue;
[0138] S8. During the execution of multiple frame drawing tasks, the scheduling module monitors the execution status of each task in the message queue.
[0139] S9. If the scheduling module encounters any canceled task, it will cancel the scheduled task corresponding to that canceled task.
[0140] S10. If any scheduled task terminates at its designated time, the scheduling module notifies the UI thread to increase its runtime resources via the interface module in the system library; however, the interface module does not... Figure 4 As shown in the image.
[0141] S11. The first adjustment module increases the target computing resource object corresponding to the UI thread from the current first frequency to the second frequency;
[0142] S12. The second adjustment module increases the occupancy rate of the target computing resource object from the first occupancy rate to the second occupancy rate, so as to increase the running resources of the UI thread and allow the UI thread to continue to execute the remaining drawing frame tasks.
[0143] S13. After the message queue is cleared, the scheduling module notifies the reset of the frequency increase state and restores the initial running resources of the UI thread.
[0144] S14. The first adjustment module restores the frequency of the target computing resource object from the second frequency to the first frequency;
[0145] S15. The second adjustment module restores the UI thread's occupancy rate of the target computing resource object from the second occupancy rate to the first occupancy rate.
[0146] This application embodiment also provides an electronic device, which corresponds to... Figure 1a The electronic device 100 shown has Figure 1aThe electronic device 100 shown includes various modules and components. When the processor in this electronic device executes computer programs / instructions stored in its memory, it can perform the following operations: responding to user operations on the application interface and determining the image frame to be drawn; when a drawing frame trigger signal arrives, adding multiple drawing frame tasks corresponding to the image frame to the message queue of the user interface thread, the message queue corresponding to at least one timed task, each timed task used to time the target drawing frame task to reach a set execution state; adding at least one cancellation task corresponding to at least one timed task to the message queue, the cancellation task used to cancel the corresponding timed task in advance when the corresponding target drawing frame task is in the set execution state; controlling the user interface thread to execute multiple drawing frame tasks and at least one cancellation task in the message queue; if any timed task finishes timing, increasing the running resources of the user interface thread to allow the user interface thread to continue executing the remaining drawing frame tasks.
[0147] For details on the specific implementation methods of the processor performing the above operations, please refer to the foregoing. Figure 1b The descriptions in the illustrated method embodiments will not be repeated here.
[0148] The embodiments provided in this application are described below. Figure 1a The electronic devices shown will be introduced.
[0149] The electronic device may be a mobile phone, tablet computer, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), or dedicated camera (such as SLR camera, point-and-shoot camera), etc. This application does not impose any restrictions on the specific type of the electronic device.
[0150] Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.
[0151] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 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.
[0152] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0153] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0154] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 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 110, and thus improves the efficiency of the system.
[0155] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0156] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0157] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface to enable the function of answering phone calls through a Bluetooth headset.
[0158] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0159] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface to enable music playback through Bluetooth headphones.
[0160] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the electronic device 100 to capture images. The processor 110 and the display screen 194 communicate via the DSI interface to enable the electronic device 100 to display images.
[0161] The GPIO interface can be configured via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to a camera 193, a display screen 194, a wireless communication module 160, an audio module 170, a sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0162] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0163] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0164] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0165] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0166] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0167] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0168] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0169] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0170] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0171] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. Wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. GNSS can include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0172] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0173] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may 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 miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0174] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0175] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0176] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0177] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0178] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0179] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0180] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0181] Internal memory 121 can be used to store executable program code, including instructions. Internal memory 121 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 electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 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 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located within the processor.
[0182] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0183] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0184] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0185] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0186] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0187] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0188] Pressure sensor 180A is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, pressure sensor 180A may be disposed on display screen 194. Pressure sensor 180A
[0189] There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may consist of at least two parallel plates with conductive material. When force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to the display screen 194, the electronic device 100 detects the touch operation intensity based on the pressure sensor 180A. The electronic device 100 can also calculate the touch position based on the detection signal from the pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.
[0190] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100. In some embodiments, the gyroscope sensor 180B can determine the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes). The gyroscope sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the shake of the electronic device 100, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the electronic device 100 by moving in the opposite direction, thus achieving image stabilization. The gyroscope sensor 180B can also be used in navigation and motion-sensing game scenarios.
[0191] The barometric pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates altitude using the air pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.
[0192] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover using the magnetic sensor 180D. Then, based on the detected opening and closing state of the cover or the flip cover, features such as automatic flip unlocking can be set.
[0193] The 180E accelerometer can detect the magnitude of acceleration of electronic device 100 in various directions (typically three axes). When electronic device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic devices and applied to applications such as screen orientation switching and pedometers.
[0194] A distance sensor 180F is used to measure distance. Electronic device 100 can measure distance via infrared or laser. In some embodiments, during a shooting scene, electronic device 100 can utilize the distance sensor 180F to measure distance for rapid focusing.
[0195] The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 100 emits infrared light outward through the LED. The electronic device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 may use the proximity sensor 180G to detect when a user holds the electronic device 100 close to their ear for a call, so as to automatically turn off the screen to save power. The proximity sensor 180G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.
[0196] The ambient light sensor 180L is used to sense the brightness of ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 based on the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also work with the proximity sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0197] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.
[0198] Temperature sensor 180J is used to detect temperature. In some embodiments, electronic device 100 uses the temperature detected by temperature sensor 180J to execute a temperature handling strategy. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, electronic device 100 performs thermal protection by reducing the performance of a processor located near temperature sensor 180J to reduce power consumption. In other embodiments, when the temperature is below another threshold, electronic device 100 heats battery 142 to prevent abnormal shutdown of electronic device 100 due to low temperature. In still other embodiments, when the temperature is below yet another threshold, electronic device 100 boosts the output voltage of battery 142 to prevent abnormal shutdown due to low temperature.
[0199] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0200] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals from the vibrating bone segments of the human vocal cords. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals. In some embodiments, the bone conduction sensor 180M can also be incorporated into headphones to form bone conduction headphones. The audio module 170 can parse the voice signals from the vibrating bone segments of the vocal cords acquired by the bone conduction sensor 180M to realize voice functionality. The application processor can parse heart rate information from the blood pressure signals acquired by the bone conduction sensor 180M to realize heart rate detection functionality.
[0201] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0202] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.
[0203] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0204] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0205] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be performed by an electronic device in the above method embodiments.
[0206] Accordingly, embodiments of this application also provide a computer program product, including a computer program / instruction, which, when executed by a processor, causes the processor to perform the steps that can be executed by an electronic device in the above method embodiments.
[0207] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0208] This application is described 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 processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more flowchart illustrations and / or one or more block diagrams.
[0209] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0210] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0211] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0212] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0213] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0214] It should also be noted that 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 process, method, article, or apparatus. Unless otherwise specified, 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.
[0215] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A data processing method, characterized in that, Applicable to electronic devices, including: Responding to user actions on the application interface, determine the image frame to be drawn; When the frame trigger signal arrives, multiple frame drawing tasks corresponding to the image frame are added to the message queue of the user interface thread. The message queue corresponds to at least one timed task, and each timed task is used to time the target frame drawing task to reach the set execution state. Add at least one cancellation task corresponding to the at least one timed task to the message queue. The cancellation task is used to cancel the corresponding timed task in advance when the corresponding target drawing frame task is in a set execution state. The user interface thread is controlled to execute multiple drawing frame tasks and at least one cancellation task in the message queue. If any timed task ends at the designated time, the running resources of the user interface thread are increased so that the user interface thread can continue to execute the remaining drawing frame tasks. The at least one timed task includes at least a third timed task, which is used to time the second frame task, and the timed interval is a third time interval from the start of the second frame task, which is greater than a third preset time from the start of the second frame task to the completion of the second frame task. The first time point is the time point that arrives earlier between the end of the third time interval and the predicted arrival time of the next frame trigger signal. When the first time point arrives, if the third timed task has not been cancelled in advance, the running resources of the user interface thread are increased so that the user interface thread can continue to execute the remaining frame drawing tasks.
2. The method according to claim 1, characterized in that, Adding at least one cancellation task corresponding to the at least one scheduled task to the message queue includes: For any scheduled task, the cancellation task corresponding to the scheduled task is added to the message queue as the first or last target subtask in the target drawing task corresponding to the scheduled task.
3. The method according to claim 1, characterized in that, The at least one scheduled task includes a first scheduled task, a second scheduled task, and / or a third scheduled task; wherein: The first timed task is used to time all drawing frame tasks, and the timed interval is the first time interval from the arrival of the drawing frame trigger signal. The first time interval is greater than the first preset time from the arrival of the drawing frame trigger signal to the completion of the at least two drawing frame tasks. The second timed task is used to time the drawing frame task preceding the first drawing frame task, and the timed interval is the second time interval from the arrival of the self-drawing frame trigger signal. The second time interval is greater than the second preset time from the arrival of the self-drawing frame trigger signal to the start of the execution of the first drawing frame task.
4. The method according to claim 3, characterized in that, Also includes: For the first scheduled task, the first cancellation task corresponding to the first scheduled task is added to the message queue as the last target subtask in the target frame drawing task. The target frame drawing task refers to the last frame drawing task in all frame drawing tasks corresponding to the first scheduled task. For the second scheduled task, the second cancellation task corresponding to the second scheduled task is added to the message queue as the first target subtask in the target drawing frame task. The target drawing frame task refers to the first drawing frame task corresponding to the second scheduled task. For the third scheduled task, the third cancellation task corresponding to the third scheduled task is added to the message queue as the last target subtask in the target drawing frame task. The target drawing frame task refers to the second drawing frame task corresponding to the third scheduled task.
5. The method according to claim 4, characterized in that, Also includes: During the execution of the multiple drawing frame tasks, the execution status of each task in the message queue is monitored; If the execution reaches the target subtask in the target drawing task corresponding to any timed task, then that timed task is cancelled.
6. The method according to claim 3, characterized in that, The at least one timed task further includes: a fourth timed task, wherein the message queue includes: a signal request task located after the plurality of frame-drawing tasks; the signal request task is used to request the next frame-drawing trigger signal; wherein the timing interval of the fourth timed task is a fourth time interval from the arrival of the frame-drawing trigger signal, and the fourth time interval is greater than a preset fourth preset duration of the adjacent frame-drawing trigger signal; the method includes: When multiple drawing frame tasks in the message queue have been completed, the signal request task is executed to request the next drawing frame trigger signal; upon receiving the next drawing frame trigger signal, the fourth timed task is cancelled in advance. If the fourth timed task ends, the runtime resources of the user interface thread are increased so that the user interface thread can continue to execute the remaining drawing frame tasks.
7. The method according to claim 1, characterized in that, Increase the runtime resources of the user interface thread, including: Increase the target computing resource object corresponding to the user interface thread from the current first frequency to the second frequency; and / or The user interface thread's utilization rate of the target computing resource object is increased from a first utilization rate to a second utilization rate, thereby increasing the runtime resources of the user interface thread.
8. The method according to claim 7, characterized in that, After the message queue is cleared, the method further includes: The frequency of the target computing resource object is restored from the second frequency to the first frequency, and the occupancy rate of the user interface thread on the target computing resource object is restored from the second occupancy rate to the first occupancy rate.
9. A data processing apparatus, characterized in that, The device is applied to an electronic device, and from top to bottom, it includes: an application layer, an application framework layer, a system library, and a kernel layer; the application layer includes a target application, the application framework layer includes a message queue, a frame drawing module, and a scheduling module; the system library includes: an interface module for the scheduling module; and the kernel layer includes: a resource adjustment module. The drawing module is used to add multiple drawing tasks corresponding to an image frame to the message queue of the user interface thread when a drawing frame trigger signal arrives. The message queue corresponds to at least one timed task, and each timed task is used to time the target drawing frame task to reach a set execution state. The module is also used to call the user interface thread to execute multiple drawing frame tasks and at least one cancellation task in the message queue. The image frame is the image frame to be drawn determined by the target application in response to user operation. The scheduling module is used to add at least one cancellation task corresponding to the at least one scheduled task to the message queue. The cancellation task is used to cancel the corresponding scheduled task in advance when the corresponding target drawing frame task is in a set execution state. During the execution of the multiple drawing frame tasks, if any scheduled task ends at the set time, the interface module is used to notify the resource adjustment module to increase the running resources of the user interface thread. The resource adjustment module is used to increase the running resources of the user interface thread so that the user interface thread can continue to execute the remaining drawing frame tasks. The at least one timed task includes at least a third timed task, which is used to time the second frame task, and the timed interval is a third time interval from the start of the second frame task, which is greater than a third preset time from the start of the second frame task to the completion of the second frame task. The scheduling module is further configured to: take the earlier of the end time of the third time interval and the arrival time of the predicted next frame trigger signal as the first time point; when the first time point arrives, if the third timed task has not been cancelled in advance, notify the resource adjustment module through the interface module to increase the running resources of the user interface thread so that the user interface thread can continue to execute the remaining frame drawing tasks.
10. The apparatus according to claim 9, characterized in that, The resource adjustment module includes: a first adjustment module and / or a second adjustment module; The first adjustment module is used to increase the target computing resource object corresponding to the user interface thread from the current first frequency to the second frequency, so as to increase the running resources of the user interface thread; The second adjustment module is used to increase the utilization rate of the target processor by the user interface thread from a first utilization rate to a second utilization rate, so as to increase the running resources of the user interface thread.
11. An electronic device, characterized in that, include: Memory and processor; The memory is used to store a computer program; the processor, coupled to the memory, is used to execute the computer program to implement the steps of the method according to any one of claims 1-8.
12. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it causes the processor to perform the steps of the method according to any one of claims 1-8.
13. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-8.
Citation Information
Patent Citations
Timing method and device and electronic equipment
CN106933687A
Application cold starting method, mobile terminal and computer readable storage medium
CN110162418A