A thread priority management method, an electronic device, and a readable storage medium

By increasing the thread priority of transition animation tasks, the stuttering and frame dropping issues during page transitions on electronic devices were resolved, resulting in a smoother interface switching experience and improved user operation.

CN120066737BActive Publication Date: 2025-11-14HONOR DEVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510505344.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-11-14
Estimated Expiration
2045-04-22

AI Technical Summary

Technical Problem

When electronic devices navigate between pages, transition effects are prone to stuttering or frame drops, resulting in a discontinuous visual experience for users and affecting operational performance.

Method used

By increasing the priority of the thread executing transition animation tasks to be higher than or equal to the priority of other threads, the real-time performance and smoothness of transition animation playback tasks are ensured, avoiding resource contention and stuttering caused by lower priority.

Benefits of technology

It improves the visual continuity and user experience of user interface transitions, avoids stuttering and frame drops in transition animations, and enhances the performance stability of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066737B_ABST
    Figure CN120066737B_ABST
Patent Text Reader

Abstract

This application provides a thread priority management method, an electronic device, and a readable storage medium, relating to the field of terminal technology. The method is applied to an electronic device. The electronic device can display a first interface, and the first interface displayed in the electronic device includes a first control used to trigger a jump from the first interface to a second interface. After the user operates the first control, the electronic device jumps from the first interface to the second interface. During this process, the electronic device displays a transition animation effect from the first interface to the second interface to improve visual continuity. The first interface and the second interface are interfaces of different applications; the task of displaying the transition animation effect is executed by a first thread. During the execution of the display task, the priority of the first thread is greater than or equal to the priority of the thread used to execute the display task of the second interface. The first thread can preferentially use running resources to ensure the smooth playback of the transition animation effect and improve the user's operating experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and in particular to a thread priority management method, an electronic device, and a readable storage medium. Background Technology

[0002] With the widespread use of electronic devices, users have higher expectations for the user experience. Currently, in scenarios where pages switch in response to user actions, electronic devices can use transition effects to connect two different pages, thereby reducing the user's perception of interface jumps through visual continuity. Furthermore, transition effects can also reinforce the relationship between the two pages and provide user feedback.

[0003] However, when electronic devices switch from one page to another, the transition effects sometimes stutter or drop frames, resulting in a discontinuous visual experience for the user and leading them to believe that the electronic devices have poor performance. Summary of the Invention

[0004] In view of this, this application provides a thread priority management method, an electronic device, and a readable storage medium to improve the priority of threads executing transition animation playback tasks, avoid stuttering or frame dropping during transition animations, and improve the user's operating experience.

[0005] Firstly, this application provides a thread priority management method applied to an electronic device. The electronic device can display a first interface, and the first interface displayed in the electronic device includes a first control used to trigger a jump from the first interface to a second interface. After the user operates the first control, the electronic device can jump from the first interface to the second interface. During the jump, the electronic device can display a transition animation effect from the first interface to the second interface, so as to achieve a connection between the two interfaces through the transition animation effect, thereby improving visual continuity. The first interface and the second interface are interfaces of different applications; the display task of the transition animation effect is executed by a first thread, and during the execution of the display task, the priority of the first thread is greater than or equal to the priority of the second thread, which is the thread used to execute the display task of the second interface.

[0006] The first and second interfaces are interfaces of different applications. Therefore, after switching from the first interface to the second interface, the application in the foreground of the electronic device becomes the application of the second interface, so that users can interact with the application of the second interface.

[0007] In some embodiments, after the application belonging to the second interface becomes the foreground application, the application belonging to the first interface becomes the background application. Here, an application in the foreground of an electronic device refers to an application that is currently directly interacting with the user, such as an application that is visible, accepting user input, or performing critical rendering tasks; an application in the foreground of an electronic device can also be called a foreground application. An application in the background of an electronic device refers to an inactive application, which may be paused, hibernating, or only performing lightweight tasks; an application in the background of an electronic device can also be called a background application.

[0008] In the above implementation, in response to the user's operation on the first control, the electronic device can jump from the first interface to the second interface, and play a transition animation during the jump to achieve a smooth connection between the two interfaces. The task of displaying the transition animation is executed by the first thread, and the first thread has a higher priority than the second thread during the execution of the display task. This allows the first thread to use runtime resources first, ensuring the real-time performance of the transition animation playback task, thereby guaranteeing the smoothness of the transition animation playback and improving the user experience.

[0009] In one possible implementation of the first aspect, in response to a user's operation on the first control, the electronic device may further perform the following process to update the priority of the first thread and ensure that the priority of the first thread is greater than or equal to the priority of the second thread. Specifically, the electronic device may configure the priority of the first thread to a first level and suspend the priority update function of the first thread; wherein the first level is greater than or equal to the priority level of the second thread; when the priority update function of the first thread is suspended, the electronic device does not respond to the task of updating the priority of the first thread.

[0010] The electronic device includes a scheduling module, which can configure the priority of the first thread to the first level and suspend the priority update function of the first thread.

[0011] In some embodiments, the electronic device can pause the priority update function of the first thread by setting a global flag. Similarly, if the electronic device does not need to ensure that the priority of the first thread is greater than or equal to the priority of the second thread, the electronic device can clear the set global flag to resume the priority update function of the first thread.

[0012] In the above implementation, the electronic device configures the priority of the first thread to the first level, and this first level is greater than or equal to the priority level of the second thread. Thus, the first thread can use runtime resources preferentially over the second thread, or both threads can use runtime resources preferentially. Furthermore, this implementation also suspends the electronic device's priority update function for the first thread, preventing its priority from being updated from the first level to a lower level, and avoiding any reduction in the real-time performance of the first thread's transition effect playback tasks.

[0013] In one possible implementation of the first aspect, the electronic device includes a scheduling module. Before configuring the priority of the first thread to the first level and suspending the priority update function of the first thread, in response to a user's operation on a first control, the first thread sends a first instruction to the scheduling module. The first instruction carries the application identifier of the application to which the interface displayed before and after the interface jump belongs, and the application identifiers of the interfaces displayed before and after the interface jump are different. Based on the received first instruction, the scheduling module determines that the first interface and the second interface are interfaces of different applications. In this case, the scheduling module can configure the priority of the first thread to the first level and suspend the priority update function of the first thread.

[0014] In the above implementation, it can be ensured that the first thread has the highest priority during the transition from the first interface to the second interface, and the electronic device is prevented from updating the priority of the first thread during this process, thus avoiding a decrease in the priority of the first thread. In this way, by fixing the priority of the first thread, it can be ensured that the first thread is not interfered with by priority scheduling during the execution of the transition animation playback task, preventing the transition animation from stuttering due to a decrease in the priority of the first thread. This effectively improves the perceived smoothness for the user.

[0015] In one possible implementation of the first aspect, before configuring the priority of the first thread to the first level and pausing the priority update function of the first thread, the electronic device also needs to determine that the current scene meets preset conditions; wherein, the preset conditions include one or more of the following conditions: the first thread that executes the display task before the jump is a preset thread, and the second thread that executes the display task after the jump is a preset thread.

[0016] In some embodiments, the first instruction carries the application identifier of the application to which the interface ...

[0017] For example, the first instruction carries the application identifier V1 of the application belonging to the first interface and the application identifier V2 of the application belonging to the second interface. Furthermore, the important thread list stored in the electronic device includes application identifier V1, so the electronic device can determine that the first thread is a preset thread. Similarly, the first instruction carries the application identifier V1 of the application belonging to the first interface and the application identifier V2 of the application belonging to the second interface. Furthermore, the important thread list stored in the electronic device includes application identifier V2, so the electronic device can determine that the first thread is a preset thread. Thus, the electronic device can further configure the priority of the first thread to the first level and suspend the priority update function of the first thread.

[0018] In the above implementation, the electronic device will only configure the priority of the first thread to the first level and suspend the priority update function of the first thread when the preset conditions are met. In this way, the first thread can be prevented from occupying high-priority resources for a long time.

[0019] In one possible implementation of the first aspect, after displaying the transition animation from the first interface to the second interface, the electronic device can enable the priority update function of the first thread; when the priority update function of the first thread is enabled, the electronic device responds to the task of updating the priority of the first thread. In this way, it can be ensured that the electronic device can configure the priority of the first thread.

[0020] In one possible implementation of the first aspect, the electronic device can display a third interface, and the third interface displayed in the electronic device includes a second control used to trigger a transition from the third interface to a fourth interface. In response to the user's operation on the second control, a transition animation from the third interface to the fourth interface is displayed. The third and fourth interfaces are interfaces of the same application; the task of displaying the transition animation from the third interface to the fourth interface is executed by a third thread. During the transition from the third interface to the fourth interface, the priorities of the third and fourth threads do not change, and the fourth thread is the thread used to execute the display task of the fourth interface.

[0021] In the above implementation, in response to user interaction with the second control, the electronic device can jump from the third interface to the fourth interface, playing a transition effect during the transition to seamlessly connect the two interfaces. The display of the transition effect is executed by the third thread, and the priorities of the third and fourth threads remain unchanged during this process. Since the third and fourth interfaces belong to the same application, there is a possibility that the user will interact with the application again within a short period, resulting in another interface jump. Therefore, maintaining the unchanged priorities of the third and fourth threads avoids the system overhead caused by priority switching and ensures overall performance stability.

[0022] In one possible implementation of the first aspect, in response to the user's operation on the second control, the electronic device can control the priorities of the third and fourth threads to remain unchanged via a scheduling module.

[0023] In one possible implementation of the first aspect, before the scheduling module in the electronic device maintains the priorities of the third and fourth threads, in response to the user's operation on the second control, the third thread sends a fourth instruction to the scheduling module in the electronic device. This fourth instruction carries the application identifier of the application to which the interfaces displayed before and after the interface transition belong, and the application identifiers of the interfaces displayed before and after the transition are the same. Based on the received fourth instruction, the scheduling module determines that the third and fourth interfaces belong to the same application. In this way, the electronic device can maintain the priorities of the third and fourth threads while ensuring that the interfaces displayed before and after the transition belong to the same application, avoiding the system overhead caused by priority switching.

[0024] In one possible implementation of the first aspect, the first interface is the interface of a camera application, and the second interface is the interface of a gallery application; or, the first interface is the interface of a desktop or application, and the second interface is the interface of a notification center; or, the first interface is the interface of a desktop or application, and the second interface is the interface of a control center.

[0025] Because camera and gallery apps have high performance requirements for electronic devices, the thread priority management method provided in the first aspect above can be used to manage thread priorities during the switch from the camera app to the gallery app. This ensures that the thread for transition animation playback has a higher priority during the switch, preventing stuttering or frame drops in the transition animation. Similarly, the notification center and control center also have high performance requirements for electronic devices. Therefore, when switching from the desktop or other applications to the notification center or control center, the thread priority management method provided in the first aspect above can also be used to manage thread priorities.

[0026] Secondly, this application provides a thread priority management method applied to an electronic device. The electronic device can display a third interface, and the third interface displayed in the electronic device includes a second control used to trigger a jump from the third interface to a fourth interface. In response to the user's operation on the second control, a transition animation effect from the third interface to the fourth interface is displayed. The third and fourth interfaces are interfaces of the same application; the task of displaying the transition animation effect from the third interface to the fourth interface is executed by a third thread. During the jump from the third interface to the fourth interface, the priorities of the third and fourth threads do not change, and the fourth thread is the thread used to execute the display task of the fourth interface.

[0027] In the above implementation, in response to user interaction with the second control, the electronic device can jump from the third interface to the fourth interface, playing a transition effect during the transition to seamlessly connect the two interfaces. The display of the transition effect is executed by the third thread, and the priorities of the third and fourth threads remain unchanged during this process. Since the third and fourth interfaces belong to the same application, there is a possibility that the user will interact with the application again within a short period, resulting in another interface jump. Therefore, maintaining the unchanged priorities of the third and fourth threads avoids the system overhead caused by priority switching and ensures overall performance stability.

[0028] Thirdly, this application provides an electronic device, which includes a display screen, a memory, and one or more processors; the display screen, the memory, and the processor are coupled; the display screen is used to display an image generated by the processor, and the memory is used to store computer program code, which includes computer instructions; when the processor executes the computer instructions, it causes the electronic device to perform the method of the first aspect and any possible design of the second aspect and any possible design of the third aspect.

[0029] Fourthly, this application provides a readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the first and any possible design methods described above, as well as the second and any possible design methods described above.

[0030] Fifthly, this application provides a computer program product, including a computer program / instruction, which, when executed by a processor, causes an electronic device to perform the first aspect and any possible design of the above, as well as the second aspect and any possible design of the above.

[0031] Sixthly, this application provides an apparatus included in an electronic device, which has the function of implementing the behavior of the electronic device in any of the above aspects and possible implementations. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, a display module or unit, a configuration module or unit, a transmission module or unit, a control module or unit, and a storage module or unit, etc.

[0032] In a seventh aspect, embodiments of this application provide a chip system including a processor and potentially a memory, for implementing any of the methods provided in the first aspect, as well as the methods of the second aspect and any possible design thereof. The chip system may be composed of chips or may include chips and other discrete devices.

[0033] Understandably, the electronic device of the third aspect and any possible design thereof, the readable storage medium of the fourth aspect, and the computer program product of the fifth aspect are all used to perform the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. Attached Figure Description

[0034] Figure 1 A schematic diagram illustrating camera application scene switching as provided in an embodiment of this application;

[0035] Figure 2 A thread priority management process provided in this application embodiment Figure 1 ;

[0036] Figure 3 This application provides an illustration of thread priority management in an embodiment. Figure 1 ;

[0037] Figure 4 A schematic diagram illustrating the playback of a magnified animation effect, provided as an embodiment of this application;

[0038] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0039] Figure 6 A software structure block diagram of an electronic device provided in an embodiment of this application;

[0040] Figure 7 A thread priority management process provided in this application embodiment Figure 2 ;

[0041] Figure 8 This application provides an illustration of thread priority management in an embodiment. Figure 2 ;

[0042] Figure 9 This is a schematic diagram illustrating a scene switching method for a pull-down notification center, as provided in an embodiment of this application. Detailed Implementation

[0043] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

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

[0045] Before introducing the embodiments of this application, the technologies involved in the embodiments of this application will be described in detail.

[0046] An activity component is an application component in an application that is responsible for displaying the user interface and handling user interactions. An activity component can be responsible for implementing one or more functions; therefore, an application can include at least one activity component.

[0047] In the case of an activity component included in an application, that activity component can perform multiple functions. For example, a shopping application may include an activity component that is responsible for displaying products, managing the shopping cart, managing orders, and managing user login status.

[0048] In applications containing multiple activity components, these components can collaborate. For example, a news media application might include a homepage activity component and a news details page activity component. The homepage activity component is responsible for displaying the news list, trending topics, category navigation, and other content on the homepage, as well as providing user interaction entry points such as search, refresh, and category filtering. The news details page activity component is responsible for displaying the news details and also provides user interaction entry points such as likes, comments, shares, and back navigation.

[0049] The homepage activity component and the news details page activity component can switch between each other. For example, the homepage activity component can display a homepage with a news list, including entertainment news. In response to a user's action on an entertainment news item in the homepage news list, the news details page activity component can be launched, displaying a news presentation interface containing the specific content of that entertainment news item. The news presentation interface may include a back control; in response to a user's action on the back control, the homepage activity component can be launched, allowing the homepage to reappear. The specific switching process between the homepage activity component and the news details page activity component can be found in relevant technical documentation and will not be elaborated upon here.

[0050] In the example above, switching between two activity components in the news media application allows for the switching of different functions within the same application. Switching between different activity components within different applications can also be achieved, enabling cross-application functional interaction and seamless collaboration between different applications.

[0051] In some embodiments, the camera activity component in the camera app and the gallery activity component in the gallery app can be switched. When the camera app is running, the camera activity component is responsible for displaying the interface related to taking photos. For example... Figure 1 As shown, the camera activity component is responsible for displaying the shooting preview interface 101 on the phone, and the displayed shooting preview interface 101 includes thumbnails 102 corresponding to the captured photos. In response to a user's triggering operation on the thumbnails 102, the camera activity component can switch to the gallery activity component, so that the gallery activity component can be responsible for displaying thumbnails 102 on the phone. Figure 1 The photo display interface shown is 103.

[0052] To improve the smoothness of the user experience, a transition animation can be added during the switch from the camera activity component to the gallery activity component. This reduces the abruptness of the interface transition and improves visual continuity. For example... Figure 1 As shown, in response to the user's trigger operation on the thumbnail 102, the mobile phone can display a zoom-in animation that gradually enlarges the thumbnail 102 and transforms it into a photo display interface 103.

[0053] However, during use, it was found that when the phone displays the zoom-in animation, there are issues with stuttering and frame drops during playback.

[0054] Analysis of the issue revealed that the zoom-in animation is executed by the camera's main thread. However, during the playback of this animation, the camera's main thread experienced a decrease in priority. Consequently, the camera's main thread, with its lower priority, had to compete for resources with other threads on the phone. This caused it to wait while playing the zoom-in animation, resulting in stuttering and dropped frames.

[0055] For details on the causes of stuttering and frame drops in the zoom-in animation, please refer to [link / reference]. Figures 2-4 And the following analysis.

[0056] like Figure 2 As shown, at time T1, the user triggers the camera app icon. In response to the user's triggering action on the camera app icon, the phone can run the camera app. At this time, the camera activity component starts and runs in the camera main thread.

[0057] The scheduling module can detect when the camera activity component starts running in the camera's main thread. If so, it can set the camera's main thread's priority to real-time level, ensuring it has priority access to runtime resources and allowing the camera application to run smoothly in the foreground. Furthermore, the scheduling module can also lower the priority of other threads besides the camera's main thread to prevent them from competing for runtime resources.

[0058] It should be noted that the priorities involved in the embodiments of this application include real-time level and normal level, and the real-time level is higher than the normal level. However, the actual embodiments of this application do not limit the specific type of priority or the rules for determining the priority level. Priority rules can be set according to the actual application scenario. For example, in one priority rule, the thread priority can be divided into 256 levels. Any integer value from 0 to 256 can represent a priority. The smaller the value, the higher the priority, with 0 being the highest priority and 256 being the highest priority. Under this priority rule, if the priority of the camera main thread is 98 and the priority of the gallery main thread is 110, it means that the priority of the camera main thread is higher than the priority of the gallery main thread.

[0059] The camera activity component can be used to display a shooting preview interface on the phone, and this preview interface can include camera controls. The camera activity component can also be used to sense user actions. For example, if the camera main thread senses a user action on the camera controls in the preview interface through the camera activity component, the camera main thread can notify the camera application's background thread to capture the raw image from the camera hardware and process it to obtain a photo. Upon obtaining the photo, the camera application's background thread can also generate a thumbnail corresponding to the photo and send this thumbnail to the camera main thread, so that the camera main thread can display the thumbnail in the preview interface through the camera activity component. Figure 1 The thumbnail 102 shown in the shooting preview interface 101 serves as a notification to the user that the photo has been taken. Additionally, the user can access the photo viewing interface via the thumbnail for easier operation.

[0060] It's important to note that once the camera app is launched, both the main camera thread and background threads are created to support its operation. The main camera thread handles tasks related to user interface display and interaction, such as displaying the shooting preview screen and executing zoom-in animations based on user input. The camera app's background threads run in the phone's background, handling tasks related to image acquisition and processing.

[0061] The camera application runs in the foreground, and the main camera thread is responsible for rendering and displaying the shooting preview interface, so its priority is real-time. The tasks handled by the camera application's background threads are more time-consuming than those handled by the main camera thread, and their tasks are less related to the real-time displayed content; therefore, their priority is normal.

[0062] The embodiments of this application mainly involve the tasks executed by the camera's main thread and the priority of task execution. The tasks executed by the background thread corresponding to the camera application and the priority of task execution are less relevant to the embodiments of this application. Therefore, for the content related to the background thread corresponding to the camera application, please refer to the relevant technology, and will not be described in detail here.

[0063] Furthermore, because the camera app needs to work in conjunction with the gallery app to perform photo-taking tasks, the gallery app, as an associated app of the camera app, is launched after the camera app is started. At this time, the camera app runs in the foreground of the phone, while the gallery app runs in the background. The gallery app's main thread also runs in the background, so the gallery main thread has a lower priority than the camera main thread, and is at a normal level.

[0064] like Figure 3 As shown, from time T1 to T2, the camera main thread is responsible for displaying the preview interface; therefore, its priority is real-time. The gallery main thread runs in the background of the phone; therefore, its priority is normal.

[0065] Combination Figure 2 and Figure 3 As shown, at time T2, the user's... Figure 1 The thumbnail 102 shown in the figure triggers the operation.

[0066] The camera activity component can sense user activity. Figure 1 The trigger operation for thumbnail 102. Responding to user input. Figure 1 The triggering operation of thumbnail 102 can be achieved by the camera main thread sending instruction A to the gallery main thread to start the gallery activity component.

[0067] Since communication between the camera app and the gallery app is cross-process communication, the instruction A sent from the camera main thread to the gallery main thread is implemented through an asynchronous binder service. Specifically, the camera activity component triggers the camera main thread to execute an asynchronous binder communication task by calling `startActivity(intent)`, in order to pass instruction A, carrying the intent, to the Activity Manager Service (AMS). The intent is the intention used to launch the gallery activity component. Afterwards, AMS, based on the intent, can notify the gallery main thread to launch the gallery activity component via the asynchronous binder service. Furthermore, AMS can also notify the camera main thread to put the camera activity component into a paused state (`onPause()`) via the asynchronous binder service.

[0068] Because the communication process implemented by the asynchronous binder service is time-consuming, there is a time difference between the moment the camera main thread sends command A and the moment the gallery main thread starts the gallery activity component. For example, at time T2 when the user triggers the operation on thumbnail 102, the camera main thread immediately sends command A to the gallery main thread. Therefore, it can be considered that the camera main thread sends command A at time T2. However, if... Figure 2 As shown, the main thread of the gallery receiving instruction A and starting the gallery activity component may be completed at a time after time T2, such as time T3.

[0069] In some embodiments, the scheduling module can adjust the priority of the thread corresponding to the activity component when the activity component is switched. Specifically, AMS can determine whether the activity component has been switched and update the process state when the activity component is switched, so that the scheduling module can adjust the thread priority when it detects a change in the process state.

[0070] In some examples, AMS notifies the gallery main thread to launch the gallery activity component via an asynchronous binder service, and also notifies the camera activity component to enter a paused state (onPause()) via the same asynchronous binder service. Afterwards, AMS can determine from the activity component stack that the gallery main thread has launched the gallery activity component and that the camera activity component in the camera main thread has entered a paused state. Then, AMS can adjust the process of the gallery application associated with the gallery activity component to a foreground process, and the process of the camera application associated with the camera activity component to a background process. In this way, the scheduling module can detect that the gallery application process has become a foreground process and the camera application process has become a background process. At this point, the scheduling module can set the priority of the gallery main thread corresponding to the gallery application to real-time level and the priority of the camera main thread corresponding to the camera application to normal level.

[0071] Using the above method, the scheduling module can adjust the priority of the camera main thread and the gallery main thread when the camera activity component is paused and the gallery activity component is started. For example... Figure 2 As shown, at time T3, the scheduling module can reduce the priority of the camera main thread corresponding to the camera activity component and increase the priority of the gallery main thread corresponding to the gallery activity component, so as to ensure that the gallery main thread can use the running resources first, so as to support the gallery activity component to respond to the user's operation in a timely manner.

[0072] At time T3, the gallery main thread receives instruction A and launches the gallery activity component. At this point, AMS can determine that the activity component has switched and update the gallery application's process to the foreground. Thus, the scheduling module can detect that the gallery application's process has become the foreground process, while the camera application's process has become the background process. The process by which AMS determines that the activity component has switched and updates the process state is very short, and the time it takes for the scheduling module to detect that the gallery application's process has become the foreground process through AMS is also very short. Therefore, it can be assumed that the scheduling module changed the thread priority at time T3.

[0073] After the scheduling module adjusts the thread priorities, it can send a priority change instruction to the kernel, allowing the kernel to allocate runtime resources to the threads based on this instruction. Specifically, upon receiving the priority change instruction, the kernel can pass it to the system-on-chip (SOC) via a relevant interface, enabling the SOC to allocate resources. The communication time between the scheduling module and the kernel is very short; therefore, it can be assumed that the kernel begins allocating runtime resources to the higher-priority gallery main thread at time T3.

[0074] like Figure 3 As shown, after the gallery activity component starts, the scheduling module changes the priority of the camera main thread from real-time to normal, and sets the priority of the gallery main thread from normal to real-time.

[0075] In response to user Figure 1 In addition to triggering the operation of thumbnail 102, the camera main thread can also begin executing the playback task of the zoom-in animation. The time difference between the moment the camera main thread sends instruction A to the gallery main thread and the moment the camera main thread begins executing the playback task of the zoom-in animation is small, and in this embodiment, they can be considered as the same moment.

[0076] like Figure 2 As shown, at time T2, in response to the user's trigger operation on thumbnail 102, the camera main thread can begin executing the zoom-in animation playback task, so that the camera activity component can display the zoom-in animation. Thus, the user can see the zoom-in animation on the phone's screen. Figure 1 The process of gradually enlarging the thumbnail 102 and transforming it into the photo display interface 103.

[0077] Based on the above analysis, we know that the camera main thread begins executing the zoom-in animation playback task at time T2, and its priority remains at the real-time level. However, because the camera main thread needs to send command A via an asynchronous binder service, and there is a delay in sending command A, the gallery main thread will not immediately launch the gallery activity component after the camera main thread sends command A. It's possible that the gallery main thread doesn't receive command A and launch the gallery activity component until time T3. At this point, the camera activity component used for foreground display switches to the gallery activity component, and as mentioned earlier, the scheduling module sets the camera main thread's priority to the normal level.

[0078] like Figure 3As shown, in response to the user's trigger operation on thumbnail 102, during the process of the camera main thread executing the zoom-in animation playback task from time T2 to T3, the camera main thread has a real-time priority. Therefore, the phone kernel prioritizes allocating running resources to the camera main thread, so there will be no stuttering during the process of the camera main thread playing the zoom-in animation.

[0079] If the camera's main thread completes the zoom-in animation playback task at time Tm, the gallery's main thread can handle the photo viewing interface display task at time Tm. Therefore, if... Figure 3 As shown, from time T3 to time Tm, the camera's main thread is still executing the zoom-in animation playback task, and during this process, the camera's main thread has a normal priority. From time T3 to time Tm, the gallery's main thread is not executing any tasks related to the interface display, but because the scheduling module sets the gallery's main thread's priority to real-time level at time T3, the phone kernel will prioritize allocating runtime resources to the higher-priority gallery main thread. Therefore, the camera's main thread, with a normal priority, needs to compete for runtime resources with other threads with normal priorities. Thus, from time T3 to time Tm, while the camera's main thread is competing for runtime resources, it needs to queue and wait for the phone kernel to allocate runtime resources. While the camera's main thread is waiting for runtime resources, it cannot execute the zoom-in animation playback task, resulting in stuttering and frame drops during the playback of the zoom-in animation.

[0080] like Figure 4 As shown in (a), if the zoom-in animation plays at normal speed, it can play from time T2 to time Tn, playing a total of 8 frames of animation during the entire playback process. However, due to a decrease in the camera's main thread priority at time T3, as... Figure 4 As shown in (b), the zoom-in animation played from time T2 to time T3, a total of 3 frames of animation were played, and no frame drops or stuttering occurred during this process. From time T3 to time Tm, a total of 3 frames of animation were played during the entire playback process. Among them, 3 frames of animation were dropped because the camera's main thread waited for a long time to run resources. When the time interval between the third and fifth frames of animation was greater than the effective stuttering interval visible to the human eye (e.g., 50ms), the user could see as follows: Figure 4 The magnification effect shown in (b) exhibits noticeable stuttering during playback.

[0081] Furthermore, because the camera's main thread needs to queue for resource allocation, the actual end time (Tm) of the zoom-in animation may be later than the expected end time (Tn). This can lead to a longer playback time for the zoom-in animation, resulting in a less-than-ideal user experience.

[0082] Based on this, this application provides a thread priority management method. The first interface displayed by the electronic device includes a first control. After the user operates the first control, the electronic device jumps from the first interface to a second interface. During this process, the electronic device displays a transition animation from the first interface to the second interface to improve visual continuity. The first interface and the second interface are interfaces of different applications; the task of displaying the transition animation is executed by a first thread. During the execution of the display task, the priority of the first thread is greater than or equal to the priority of the thread used to execute the display task of the second interface. Thus, the first thread can preferentially utilize runtime resources, ensuring the smooth playback of the transition animation and improving the user experience.

[0083] Furthermore, the third interface displayed on the electronic device includes a second control. In response to user interaction with the second control, the electronic device displays a transition animation from the third interface to the fourth interface. The third and fourth interfaces are interfaces of the same application. The task of displaying the transition animation from the third to the fourth interface is executed by a third thread. During the transition, the priorities of the third and fourth threads remain unchanged; the fourth thread is specifically used to execute the display task for the fourth interface. In this way, even with frequent switching within the application, thread priorities are not frequently adjusted, avoiding resource waste and performance lag.

[0084] The thread priority management method provided in this application can be applied to electronic devices. For example, the electronic device may specifically be a mobile phone, tablet computer, smart screen, laptop computer, in-vehicle device, wearable device (such as a smartwatch), ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), artificial intelligence (AI) device, or other terminal device with display and interactive functions. The operating system installed on the electronic device includes, but is not limited to, iOS®, Android®, Windows®, Linux®, or other operating systems. This application does not limit the specific type of electronic device or the operating system installed.

[0085] Figure 5 A schematic diagram of the structure of the electronic device 100 is shown.

[0086] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identity module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0087] It is understood that the structures illustrated in the embodiments of this application 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.

[0088] Processor 110 may include one or more graphics processing units (GPUs) that execute program instructions to generate or modify display information. Processor 110 may also include an application processor. The GPU is a microprocessor for image processing, connected to display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Electronic device 100 implements display functions through the GPU, display screen 194, and application processor, etc.

[0089] Electronic device 100 can perform shooting functions through an image signal processor (ISP), camera 193, video codec, GPU, display screen 194, and application processor.

[0090] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android® system as an example to illustrate the software structure of electronic device 100.

[0091] Figure 6 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.

[0092] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android® system is divided into four layers, from top to bottom: the application layer, the framework layer, the native layer, and the kernel layer.

[0093] It should be noted that the embodiments of this application use the Android® system as an example. In other operating systems (such as Harmony® system, iOS® system, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of this application, the solution of this application can also be implemented.

[0094] The application layer can include a series of application packages. For example, the application layer can include system applications and third-party applications. System applications can include camera applications, gallery applications, desktop applications, notification centers, control centers, etc. Third-party applications can include camera applications, media applications, social applications, game applications, etc., developed by third parties.

[0095] Applications can be switched between, and when switching from one application to another, the electronic device can display transition effects to connect the different interfaces displayed by the two different applications. For example, Figure 1 As shown, a user can switch from the camera app to the gallery app. During this switch, the phone can display a zoom-in animation where the thumbnail 102 gradually enlarges and transforms into the photo display interface 103. Similarly, an electronic device can switch from a desktop app to a game app, displaying a transition animation during the switch. Likewise, an electronic device can switch from a desktop app to the control center, displaying a transition animation during the switch. The following embodiments use the switch from the camera app to the gallery app as an example, but the use of this application is not limited to this.

[0096] In some embodiments, during the switch from one application L1 to another application L2, the main thread of application L1 can send instructions to the main thread of application L2 through the interface provided by the asynchronous binder service. For example... Figure 6 As shown, in response to the user's triggering operation on the thumbnail, the camera main thread can send instruction A to the gallery main thread through the interface provided by the asynchronous binder service.

[0097] When an application is started, a thread corresponding to that application is created.

[0098] For example, when a camera application is launched, the camera main thread and other related threads are created, enabling the camera application to respond to user actions and perform various tasks such as activating photo mode, activating video mode, sliding the shooting angle, zooming the shooting angle, taking a picture, starting video recording, and pausing video recording. Specifically, the camera main thread in the camera application can perform the above tasks. During this process, the camera main thread can call related processes or threads for collaborative processing. For example, the camera main thread can call the background thread corresponding to the camera application to handle image acquisition and image processing tasks. Image processing tasks may include performing camera algorithm post-processing on the image, adding address watermarks to the image, generating thumbnails based on the image, acquiring Joint Photographic Experts Group (JPEG) format photos from the post-processed image, and storing the JPEG format photos to the gallery, etc.

[0099] For example, when the camera app is launched, the gallery app, as an associated app of the camera app, will also be launched, at which point the gallery main thread can be created. Alternatively, the gallery main thread can be created when the gallery app is launched. The gallery main thread can store photos and their corresponding information. After the zoom-in animation finishes playing, the gallery main thread can also perform tasks related to displaying the larger image corresponding to the thumbnail, or tasks related to animation playback within the gallery, etc.

[0100] The framework layer provides an application programming interface (API) and programming framework for applications in the application layer. Implemented in Java, the framework layer includes predefined functions. In some embodiments, the framework layer includes an asynchronous binder service, a scheduling module, and AMS.

[0101] The asynchronous binder service at the framework layer can provide interfaces for applications at the application layer. The interfaces provided by the asynchronous binder service are defined using the Android Interface Definition Language (AIDL) and are used for inter-process communication (IPC).

[0102] The native layer, located between the framework layer and the kernel layer, mainly consists of core libraries and a runtime environment written in C / C++, responsible for high-performance computing, hardware interaction, and low-level system service support. In some embodiments, the native layer includes a native layer asynchronous binder service and a native layer scheduling module.

[0103] In the aforementioned framework layer and native layer, the framework layer asynchronous binder service provides an application-layer interface through a series of Java classes to encapsulate the lower-level details of asynchronous binder service communication, allowing developers to easily implement communication using the asynchronous binder service in Java. The native layer asynchronous binder service uses C++ to implement the underlying asynchronous binder service mechanism, and can directly interact with the kernel layer asynchronous binder driver. Both the framework layer and native layer asynchronous binder services jointly implement asynchronous binder communication between the application layer and the kernel layer. Therefore, for simplicity and ease of understanding, the diagram below illustrates... Figure 6 As shown, the framework layer and the native layer are merged, and the asynchronous binder service of the framework layer and the asynchronous binder service of the native layer are referred to together as the asynchronous binder service.

[0104] Similarly, the framework-level scheduling module also provides an application-layer interface through a series of Java classes to encapsulate lower-level priority scheduling details. The native-level scheduling module, on the other hand, can directly interact with the kernel scheduler at the kernel level, allowing the kernel scheduler to adjust thread execution resources based on updated priorities, thereby achieving thread priority scheduling. For simplicity and ease of understanding, the accompanying diagram is shown below. Figure 6 As shown, after merging the framework layer and the native layer, the framework layer scheduling module and the native layer scheduling module can be referred to together as the scheduling module.

[0105] The scheduling module is responsible for scene identification and adjusting thread priorities based on the electronic device's performance scheduling strategy and resource allocation. For example, as mentioned earlier, the scheduling module can adjust thread priorities when activity components switch. Specifically, when the camera's main thread sends an application identifier carrying the application of the interface displayed before and after the interface transition to the scheduling module, the scheduling module can identify the scene corresponding to this instruction. Furthermore, the scheduling module can set the priority of the thread executing the transition animation to the real-time level based on the important thread list stored in the phone and set a global flag to pause the camera's main thread's priority update function. Specific implementation details for this part can be found in the detailed description below and will not be repeated here.

[0106] In some embodiments, such as Figure 2 As shown, the process by which the scheduling module sends the changed priority to the kernel is... Figure 6 The diagram illustrates the process by which the scheduling module sends the modified priority to the kernel scheduler in the kernel layer. In some embodiments, after receiving the modified priority, the kernel scheduler can pass it to the SOC through a relevant interface to achieve the scheduling of runtime resources.

[0107] The following example illustrates the workflow of an electronic device using a scenario of communication between a camera app and a gallery app.

[0108] When the touch sensor receives a touch operation, the camera activity component in the camera application can detect this touch operation. If the camera main thread determines that the touch operation triggered a user interaction with the thumbnail, it can send instruction A to the gallery main thread. For example, ... Figure 6 As shown, the camera main thread can send command A to AMS through the interface provided by the asynchronous binder service. AMS then forwards command A to the gallery main thread through the asynchronous binder service and asynchronous binder driver. For a more detailed explanation of how the camera main thread sends commands to the gallery main thread, please refer to relevant technical documentation. Figure 6 The process is shown only briefly.

[0109] The following uses a mobile phone as an example of an electronic device, combined with... Figure 1 The illustrated photo-taking scenario will be used to introduce the thread priority management method provided in this application embodiment.

[0110] After the user opens the camera application, the camera activity component is launched and runs on the camera's main thread. As mentioned above... Figure 1 as well as Figure 2 The related description states that the camera activity component is responsible for displaying the shooting preview interface 101 on the phone. Furthermore, after the user performs the action of taking a photo, the camera activity component is also responsible for displaying a thumbnail 102 on the shooting preview interface 101, with the thumbnail 102 corresponding to the captured photo. For a detailed explanation of how the camera activity component on the phone handles the display of the interface from the start of the camera application until the user triggers the action on the thumbnail 102, please refer to the above. Figure 2 The relevant descriptions will not be repeated here.

[0111] At time T2, the camera activity component can detect the user's trigger action on thumbnail 102. At this point, the phone can display a zoom-in animation transitioning from the camera app to the gallery app. During this process, the phone can increase the priority of the camera's main thread, which is executing the zoom-in animation playback task, to real-time level to avoid stuttering or frame drops in the zoom-in animation.

[0112] After the zoom-in animation finishes playing, the camera's main thread priority is set to normal, while the gallery's main thread priority is set to real-time, allowing the phone to display the gallery interface that shows photos in the gallery app.

[0113] In the above embodiments, the shooting preview interface 101 can be the first interface in this application. The thumbnail 102 can be the first control in this application. The display interface for showing photos can be the second interface in this application. The zoom-in animation effect for the transition from the camera application to the gallery application can be the transition animation effect in this application. The camera main thread can be the first thread in this application. The gallery main thread can be the second thread in this application.

[0114] In the above implementation, in response to the user's operation on the first control, the electronic device can jump from the first interface to the second interface, and play a transition animation during the jump to achieve a smooth connection between the two interfaces. The task of displaying the transition animation is executed by the first thread, and during the execution of the display task, the priority of the first thread is greater than or equal to the priority of the second thread. In this way, the first thread can use runtime resources first, thereby ensuring the real-time performance of the transition animation playback task, thus guaranteeing the smoothness of the transition animation playback and improving the user experience.

[0115] The real-time level can be the first level in this application. It should be noted that in other cases, the first level can be a higher priority level. For example, in the examples regarding priorities mentioned above, the camera main thread has a priority of 98, and the gallery main thread has a priority of 110, with 98 representing a higher priority than 110. Here, 98 refers to the first level in this application. Of course, this application does not impose specific restrictions on the specific levels and values ​​of priority.

[0116] Specifically, at time T2, in response to the user's trigger operation on thumbnail 102 in the shooting preview interface, such as... Figure 7 As shown, the mobile phone can execute the following S701-S706:

[0117] S701, The camera main thread sends instruction A to the gallery main thread to enable the gallery activity component.

[0118] When a user triggers an action on thumbnail 102 in the shooting preview interface, the camera activity component running in the camera's main thread can detect this action. Subsequently, the camera activity component can trigger the camera's main thread to send instruction A to the gallery's main thread to enable the gallery activity component. For a description of instruction A, please refer to the above. Figure 2 The relevant descriptions will not be elaborated here.

[0119] As described above, the instruction A sent from the camera main thread to the gallery main thread is an inter-process communication, and inter-process communication has a certain latency. For example, the camera main thread sends instruction A to the gallery main thread via an asynchronous binder service, such as... Figure 6 As shown, instruction A needs to pass through the framework layer + native layer, and then the kernel layer, before being sent to the gallery main thread from the kernel layer through the framework layer + native layer. This process takes some time. Therefore, after S701, the gallery activity component will not start immediately. After instruction A is successfully sent to the gallery main thread, the gallery main thread starts the gallery activity component. At this point, it is already some time after time T2, such as time T3. Figure 7 As shown, there is a long time interval between time T2 and time T3.

[0120] Because the asynchronous binder communication mechanism involves framework layer encapsulation and asynchronous callbacks, it can achieve asynchronous effects in business logic. In other words, after the camera main thread sends command A to the gallery main thread via the asynchronous binder service, the camera main thread does not need to wait for feedback from the gallery main thread and can execute other tasks.

[0121] Therefore, after the camera main thread sends instruction A to the gallery main thread, the phone can execute the following S702-S705 to ensure that the priority of the camera main thread is not reduced before the gallery activity component is launched.

[0122] S702, The camera's main thread sends instruction B to the scheduling module.

[0123] After the camera activity component senses a user interaction with thumbnail 102, the camera main thread can send instruction B to the scheduling module. Instruction B carries the application identifier of the application to which the interface belongs before and after the interface transition, allowing the scheduling module to adjust priorities based on instruction B. Instruction B refers to the first instruction in this application.

[0124] In some examples, after the camera activity component detects that the user has triggered an action on thumbnail 102 in the shooting preview interface, the camera main thread can generate instruction B. Instruction B carries the application identifier K1 of the camera application to which the shooting preview interface 101 belongs before the interface jump, and the application identifier K2 of the gallery application to which the photo display interface 103 belongs after the interface jump. Then, the camera main thread sends instruction B to the scheduling module.

[0125] Optionally, when switching from the camera activity component to the gallery activity component, which involves switching between activity components of different applications, the phone can ensure that the camera main thread has a higher priority than the gallery main thread by following these steps.

[0126] In some embodiments, after receiving instruction B, the scheduling module may execute the following S703:

[0127] S703, The scheduling module determines that the scenario corresponding to instruction B is the scenario of switching between activity components of different applications.

[0128] Instruction B carries the application identifiers of the applications to which the interfaces displayed before and after the interface transition belong. In other words, the instruction has an application identifier K1 for the camera application and an application identifier K2 for the gallery application. Since application identifiers K1 and K2 are different, the scheduling module can determine the corresponding scenario as a switching scenario between application activity components based on instruction B.

[0129] In some embodiments, if the scheduling module determines, based on the received instruction sent by the camera main thread, that the current switching is between activity components within the same application, it indicates that there is still a possibility of switching between activity components within the application in the short term. Therefore, the scheduling module may not adjust the thread priority to avoid performance waste caused by frequent priority adjustments.

[0130] For example, a gallery application includes activity components H1, H2, and H3. Activity component H1 displays the album list interface. Activity component H2 displays a large image of the first photo in the album list. Activity component H3 displays a large image of the second photo in the album list. The large image display includes both the first and second photos. The gallery's main thread can run activity components H1, H2, and H3.

[0131] First, in response to the user's action of selecting the first photo in the album list interface, the phone displays a large-scale image of the first photo, which includes a back control A. At this time, the gallery's main thread sends instruction C to the scheduling module. Instruction C carries the application identifier K2 of the gallery application to which the interface belongs before the interface transition, and the application identifier K2 of the gallery application to which the interface belongs after the transition. Since the two application identifiers are the same, the scheduling module can determine that this is a scenario of switching between activity components within the same application, and the scheduling module does not need to update the priority of the gallery's main thread.

[0132] Next, in response to the user's trigger action on the return control A, the phone displays the album list interface. Then, in response to the user's trigger action on the second photo in the album list interface, the phone displays a larger version of the second photo. Throughout this process, the scheduling module does not update the priority of the gallery's main thread. This avoids performance waste caused by frequent priority adjustments.

[0133] When a user performs multiple actions within an application within a short period, each action triggers a switch between activity components within the application. If the scheduling module updates the thread priority every time an activity switches, it leads to a waste of phone resources and reduces phone performance. Furthermore, in the above embodiment, the phone can adjust thread priorities during activity component switching between different applications. This effectively avoids the stuttering issue caused by frequent priority adjustments in animation effects.

[0134] In this application, the album list interface refers to the third interface, the photos in the album list interface refer to the second control in this application, the large image display interface refers to the fourth interface in this application, and the gallery main thread refers to the third and fourth threads in this application.

[0135] The S703 mentioned above can reduce the waste of mobile phone operating resources, thereby improving mobile phone performance and reducing lag.

[0136] After the camera main thread sends instruction B to the scheduling module, or after the scheduling module determines that instruction B corresponds to a scenario of switching between activity components between different applications, the phone can continue to execute S704-S705 to set the camera main thread's priority to the real-time level and pause the camera main thread's priority update function. This ensures that the camera main thread can use runtime resources preferentially and prevents its priority from being lowered in subsequent priority adjustment operations.

[0137] S704, the scheduling module, based on instruction B and the list of important threads, sets the priority of the camera's main thread to the real-time level and sets a global flag.

[0138] In some embodiments, the scheduling module can determine whether the current scene meets preset conditions based on instructions and a list of important threads. These preset conditions include one or more of the following: the thread executing the display task before the transition is a preset thread; the thread executing the display task after the transition is a preset thread. If the current scene meets the preset conditions, the scheduling module can adjust the priority of the thread executing the transition animation playback task and pause the priority update function for the thread executing the transition animation playback task.

[0139] This list of important threads stores the application identifiers corresponding to those threads. Important threads can be those with high resource requirements, such as the camera main thread, gallery main thread, notification center main thread, control center main thread, and game main thread. Thus, if any thread in either the application before or after the interface transition has high resource requirements, the electronic device will determine that the current scene meets the preset conditions and will increase the priority of the thread executing the transition effect.

[0140] For example, instruction B carries the application identifier K1 of the camera application to which the shooting preview interface 101 displayed before the interface jumps, and the application identifier K2 of the gallery application to which the photo display interface 103 displayed after the interface jumps. The important thread list stores application identifiers K1 and K2. Thus, the important thread list contains the application identifiers of the applications to which the interfaces displayed before and after the interface jumps belong. Therefore, the scheduling module can determine that the camera main thread corresponding to the camera application and the gallery main thread corresponding to the gallery application are preset threads. Therefore, the scheduling module can determine that the current scene meets preset conditions based on instruction B and the important thread list. Thus, the scheduling module can set the priority of the camera main thread to a higher level, thereby ensuring that the camera main thread can use runtime resources preferentially during the execution of the zoom-in animation playback task.

[0141] In addition, the scheduling module sets a global flag to ensure that the scheduling module will not perform priority setting operations on the camera main thread in the future, so as to avoid the camera main thread's priority being reduced, which would cause stuttering and frame dropping issues in the zoom animation.

[0142] In other embodiments, when the camera main thread has a real-time priority, the scheduling module may not need to adjust the priority of the camera main thread. The scheduling module only needs to set a global flag to prevent the priority of the camera main thread from being reduced from the real-time level to the normal level.

[0143] In other embodiments, the mobile phone is configured with a configuration file (uniperf configuration file) that works with the scheduling module. The uniperf configuration file may include application identifiers from a pre-configured list of important threads. The configuration file may also include a configuration strategy for global flags. For example, the configuration strategy in the configuration file might be that when the global flag (command ID value) is set to 1, the scheduling module can pause priority updates for threads performing transition effects playback tasks. Alternatively, the configuration strategy might be that when the global flag (command ID value) is set to 0, the scheduling module can enable priority updates for threads performing transition effects playback tasks. The configuration file may also include specific strategies for how the scheduling module adjusts thread priorities. For instance, if the configuration file contains configuration information for the CPU or GPU frequency points and frequency scheduling duration during the execution of real-time threads, then the scheduling module can configure the corresponding CPU or GPU frequency points and frequency scheduling duration for the thread when it is necessary to set the thread to a real-time priority.

[0144] In this application, setting a global flag can be one way to suspend the function of updating the priority of the first thread. Electronic devices can also suspend the function of updating the priority of the first thread in other ways to avoid lowering the priority of the first thread executing transition effects.

[0145] An application corresponds to one main thread and multiple other threads. Generally, the tasks executed by the main thread are related to the tasks displayed in real time. Therefore, in the above embodiment, if the scheduling module determines that there is an application identifier carried in the instruction in the list of important threads, it can determine that the main thread of the application corresponding to the application identifier is the preset thread.

[0146] Since the playback of transition effects is typically executed by the thread corresponding to the application whose interface was displayed before the transition, the scheduling module needs to increase the priority of the camera's main thread that executes the transition effect playback task. If, in other related technologies, the transition effect playback task is executed by the thread corresponding to the application whose interface was displayed after the transition, then the scheduling module also needs to increase the priority of that thread.

[0147] S705, the scheduling module sends a priority change instruction to the kernel.

[0148] After the scheduling module adjusts the thread priority, it can send a priority change instruction to the kernel so that the kernel can allocate runtime resources to the thread according to the current thread priority.

[0149] In some embodiments, after the phone completes S705 and reaches time T3, since the scheduling module has already set the priority of the camera main thread to the real-time level and set the global flag, at time T3, if it is determined that the activity component has been switched, the scheduling module can set the priority of the gallery main thread corresponding to the switched gallery activity component to the real-time level, without adjusting the priority of the camera main thread.

[0150] To ensure the phone can respond promptly to user actions and play magnification effects, after executing S702, the phone can execute the following S706:

[0151] S706, the camera's main thread executes the zoom-in animation playback task.

[0152] In the above embodiment, after the phone executes S701, it continues to execute S702. Both S701 and S702 involve the camera's main thread executing command sending tasks, and the time consumed by the camera's main thread in executing command sending tasks is very short. Specifically, the camera's main thread sends command A through an asynchronous binder service. After the camera's main thread passes command A to the interface provided by the asynchronous binder service, it can continue to execute other tasks. The time consumed by the camera's main thread in passing command A to the interface provided by the asynchronous binder service is short, so the execution time of S701 can also be considered short.

[0153] Based on the above analysis, it can be considered that S701 and S702 are completed at relatively close times. In this embodiment, the time difference between the completion times of S701 and S702 is negligible. Therefore, ignoring the short time interval between the completion times of S701 and S702, it can be considered that S701 and S702 are essentially completed simultaneously. Figure 7 As shown, S701 begins execution at time T2. Since S701 completes in a short time, and the phone can execute S702 immediately after completing S701, S702 can also be considered to begin execution at time T2. Furthermore, S702 also completes in a short time, and the phone can execute S703 immediately after completing S702. Therefore, the time when the phone begins executing S703 can also be considered to be time T2, which is the same time as the phone starting to execute S701 and S702.

[0154] At time T2, in response to the user's triggering operation on the thumbnail 102 in the shooting preview interface, the electronic device executes S706, which enables the camera activity component to be responsible for displaying the magnification animation.

[0155] Furthermore, for instruction A to successfully reach the gallery's main thread, it needs to go through a complete cross-process asynchronous binder communication link, while for instruction B to successfully reach the scheduling module, the camera's main thread only needs to pass instruction B to the interface provided by the scheduling module. Therefore, when instruction B is successfully received by the scheduling module, instruction A has not yet been successfully received by the gallery's main thread. Thus, before the gallery activity component is launched, the scheduling module can set the camera's main thread's priority to the real-time level based on instruction B and set a global flag to pause the scheduling module's function of updating the camera thread's priority. In this way, it can be ensured that the camera's main thread maintains a high priority during the execution of the zoom-in animation playback task and will not be lowered, allowing the camera's main thread to use runtime resources preferentially, thereby ensuring that the zoom-in animation playback process does not experience stuttering or frame drops.

[0156] In some embodiments, the phone may execute S702 before S701. Based on the above description, S701 and S702 can be considered to be completed simultaneously. Therefore, if the phone executes S702 before S701, it can also be considered that S701 and S702 are completed simultaneously. Furthermore, if the phone executes S702 before S701, when the scheduling module successfully receives instruction B, instruction A has not yet been successfully received by the gallery main thread. Therefore, executing S702 before S701 also ensures that the camera main thread maintains a high priority during the execution of the zoom-in animation playback task.

[0157] Optionally, after the camera's main thread finishes executing the zoom-in animation playback task, it can continue to execute the following S707-S708:

[0158] S707, The camera's main thread sends instruction D to the scheduling module.

[0159] S708, the scheduling module clears the global flag.

[0160] Instruction D is used to instruct the scheduling module to clear the global flags so that the scheduling module can continue to manage thread priorities.

[0161] The global flag can be cleared by deleting it or by assigning it a null value. As in the example above, when the phone executes S705, it sets the command ID value to 1, causing the scheduling module to pause updating the camera main thread priority. In some examples, after executing S708, the command ID value may no longer exist on the phone, allowing the scheduling module to continue managing thread priorities. In still other examples, after executing S708, the command ID value on the phone can be 0 or null, allowing the scheduling module to continue managing the camera main thread priority.

[0162] In some embodiments, after the camera main thread completes the zoom-in animation, it no longer needs a high priority. Therefore, the camera main thread can send instruction D to the scheduling module to ensure that the scheduling module can promptly reduce the priority of the camera main thread. This effectively improves phone performance by managing thread priorities.

[0163] In the above embodiments, such as Figure 8 As shown, from time T1 to T2, the camera main thread is responsible for displaying the preview interface; therefore, its priority is real-time. The gallery main thread runs in the background of the phone; therefore, its priority is normal.

[0164] At time T2, in response to the user's trigger action on thumbnail 102 in the shooting preview interface, the camera main thread sends instruction A to the gallery main thread to enable the gallery activity component. Simultaneously, the camera main thread sends instruction B to the scheduling module, and the camera main thread executes the zoom-in animation playback task. Due to the delay in asynchronous binder communication, the gallery activity component does not start immediately after the camera main thread sends instruction A to the gallery main thread. Therefore, the priorities of the camera main thread and the gallery main thread are not adjusted. Figure 8 As shown, after time T2, the camera main thread still has a real-time priority, while the gallery main thread still has a normal priority.

[0165] Before the gallery activity component starts, the camera main thread sends instruction B to the scheduling module. Based on instruction B and a list of important threads, the scheduling module can set the camera main thread's priority to real-time and set a global flag to prevent the scheduling module from adjusting the camera main thread's priority. Therefore, as... Figure 8As shown, when the gallery activity component starts at time T3, the camera main thread's priority remains at the real-time level. The gallery main thread's priority is also set to real-time due to the gallery activity component's startup, until the zoom-in animation playback task is completed at time Tb. At time Tb, the camera main thread's priority is set to the normal level, while the gallery main thread's priority remains at the real-time level to ensure that the gallery main thread can handle the display tasks of the gallery interface.

[0166] Therefore, by using the method provided in the above embodiments, the camera main thread can prioritize the use of runtime resources to execute the zoom-in motion effect playback task, thus avoiding stuttering and frame dropping issues during the execution of the zoom-in motion effect playback task by the camera main thread.

[0167] It is understood that the thread priority management method provided in this application embodiment can also be used in scenarios where other applications are switched.

[0168] For example, after a user unlocks their phone, the desktop activity component is launched and runs on the main desktop thread. This desktop activity component is responsible for displaying, for example,... Figure 9 The desktop 901 is shown. Desktop 901 includes a notification center operation area 902. In response to a user's trigger action in the notification center operation area 902, such as a pull-down action, the desktop main thread begins executing the playback task of the notification center transition animation. Furthermore, after the notification center transition animation playback task is completed, the phone can display the notification center interface 903. The notification center interface 903 is displayed by the notification center activity component, which runs in the notification center main thread.

[0169] In the scenario described above, a transition from the desktop activity component to the notification center activity component also occurs. During this process, the desktop main thread is responsible for executing the playback task of the notification center transition animation. To prevent the scheduling module from lowering the priority of the desktop main thread during the transition from the desktop to the notification center, the list of important threads stored in the phone can include the application identifier K4 of the notification center, so that the scheduling module can determine whether the priority of the desktop main thread needs to be greater than or equal to the priority of the notification center main thread in the current scenario.

[0170] Thus, in response to the user's trigger operation in the notification center operation area 902, the desktop main thread can send an instruction to the scheduling module carrying the application identifier K3 of the desktop application and the application identifier K4 of the notification center. The scheduling module can then find the application identifier K4 of the notification center in the list of important threads. The scheduling module can determine that the thread executing the display task in the notification center is a preset thread. Therefore, the scheduling module can set the priority of the desktop main thread executing the transition animation to the real-time level and set a global flag, so that during the desktop main thread's execution of the notification center transition animation playback task, the scheduling module will no longer perform priority adjustments on the desktop main thread.

[0171] For example, similar to the above example, the desktop includes a control center operation area. In response to a user's trigger action in the control center operation area, such as a pull-down gesture, the desktop main thread begins executing the playback task for the control center transition effects. To prevent the scheduling module from changing the priority of the control center main thread to a real-time level, the list of important threads stored in the phone can include the control center's application identifier K5.

[0172] Thus, in response to a user's trigger operation in the control center's operating area, the desktop main thread can send an instruction to the scheduling module carrying the application identifier K3 of the desktop application and the application identifier K5 of the control center. The scheduling module can then locate the control center's application identifier K5 in the list of important threads. This allows the scheduling module to determine that the thread executing the display task in the control center is a preset thread. Therefore, the scheduling module can set the priority of the desktop main thread executing the transition animation to real-time level and set a global flag, ensuring that the scheduling module does not adjust the priority of the desktop main thread while it is executing the control center's transition animation playback task.

[0173] In some embodiments, the application identifiers stored in the list of important threads can be modified, added, or deleted by developers to ensure that the phone can manage thread priorities based on the user's actual needs. For example, developers may conduct research based on user scenarios and find that applications such as camera apps, gallery apps, game apps, notification centers, and control centers are high-load applications. These applications have high requirements for the timely allocation of CPU / GPU / memory and other runtime resources, and the corresponding threads need to have higher priorities. Therefore, in high-load scenarios involving these applications during interface switching, it is necessary to ensure that the thread corresponding to the previous activity component maintains a high priority for a period of time after the switch, thereby avoiding stuttering issues in transition animations.

[0174] This application also provides a readable storage medium that includes computer instructions that, when executed on the electronic device, cause the electronic device to perform the various functions or steps described in the method embodiments.

[0175] This application also provides a computer program product, including a computer program that, when run on an electronic device, causes the electronic device to perform the various functions or steps described in the above method embodiments.

[0176] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0177] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0178] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0179] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0180] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0181] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A thread priority management method, characterized in that, Applied to electronic devices, the method includes: Display a first interface, the first interface including a first control, the first control being used to trigger a jump from the first interface to a second interface; In response to the user's operation on the first control, the priority of the first thread is configured to the first level, and the priority update function of the first thread is paused; Display the transition animation from the first interface to the second interface; The first interface and the second interface are interfaces of different applications; the display task of the transition animation is executed by the first thread, and the priority of the first thread is greater than or equal to the priority of the second thread during the execution of the display task. The second thread is the thread used to execute the display task of the second interface; when the priority update function of the first thread is suspended, the electronic device does not update the priority of the first thread when updating the priority of the second thread.

2. The method according to claim 1, characterized in that, The electronic device includes a scheduling module. Before configuring the priority of the first thread to the first level and suspending the priority update function of the first thread, the method further includes: In response to the user's operation on the first control, the first thread sends a first instruction to the scheduling module. The first instruction carries the application identifier of the application to which the interface belongs before and after the interface jump. The application identifier of the application to which the interface belongs before and after the interface jump carried in the first instruction is different. The scheduling module determines, based on the received first instruction, that the first interface and the second interface are interfaces of different applications.

3. The method according to claim 1 or 2, characterized in that, Before configuring the priority of the first thread to the first level and pausing the priority update function of the first thread, the method further includes: Determine that the current scenario meets the preset conditions; The preset conditions include one or more of the following: the first thread executing the display task before the jump is a preset thread, and the second thread executing the display task after the jump is a preset thread.

4. The method according to claim 1, characterized in that, After displaying the transition animation from the first interface to the second interface, the method further includes: Enable the priority update function for the first thread; when the priority update function for the first thread is enabled, the electronic device responds to the task of updating the priority of the first thread.

5. The method according to claim 1, characterized in that, The method further includes: Display a third interface, the third interface including a second control, the second control being used to trigger a jump from the third interface to a fourth interface; In response to the user's operation on the second control, a transition animation is displayed to jump from the third interface to the fourth interface; The third interface and the fourth interface are interfaces of the same application; the display task of the transition animation from the third interface to the fourth interface is executed by the third thread. During the process of jumping from the third interface to the fourth interface, the priority of the third thread and the fourth thread does not change. The fourth thread is the thread used to execute the display task of the fourth interface.

6. The method according to claim 5, characterized in that, In response to a user's operation on the second control, the method further includes: The scheduling module in the electronic device keeps the priorities of the third thread and the fourth thread unchanged.

7. The method according to claim 6, characterized in that, Before the scheduling module in the electronic device controls the priorities of the third thread and the fourth thread to remain unchanged, the method further includes: In response to the user's operation on the second control, the third thread sends a fourth instruction to the scheduling module. The fourth instruction carries the application identifier of the application to which the interface belongs before and after the interface jump, and the application identifier of the application to which the interface belongs before and after the interface jump is the same. The scheduling module determines, based on the received fourth instruction, that the third interface and the fourth interface are interfaces of the same application.

8. The method according to claim 1, characterized in that, The first interface is the camera application interface, and the second interface is the gallery application interface. Alternatively, the first interface may be the desktop or application interface, and the second interface may be the notification center interface. Alternatively, the first interface may be the desktop or application interface, and the second interface may be the control center interface.

9. An electronic device, characterized in that, The electronic device includes a display screen, a memory, and one or more processors; the display screen, the memory, and the processors are coupled; the display screen is used to display an image generated by the processor, the memory is used to store computer program code, the computer program code including computer instructions; when the processor executes the computer instructions, the electronic device performs the method as described in any one of claims 1-8.

10. A readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-8.

11. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Video opening method and device and computer readable storage medium

    CN116980719A