Thread priority management method, electronic equipment and readable storage medium

By increasing the priority of threads for performing transition animation playback tasks, the problem of transition animation easily stuttering or frame drops when electronic devices jump on pages is solved, achieving a smoother user experience.

CN120066737AActive Publication Date: 2025-05-30HONOR DEVICE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When an electronic device jumps from one page to another, the transition motion effect is prone to stuttering or losing frames, resulting in poor user operation experience.

Method used

By increasing the priority of threads for performing transition animation playback tasks, it ensures that threads can prioritize the use of running resources, thereby ensuring the smoothness of transition animation.

Benefits of technology

It effectively avoids the problem of lag or frame drop in transition animation effects, and improves the user's operating experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066737A_ABST
    Figure CN120066737A_ABST
Patent Text Reader

Abstract

The invention provides a thread priority management method, electronic equipment and a readable storage medium, and relates to the technical field of terminals, and the method is applied to the electronic equipment. The electronic equipment can display the first interface, the first interface displayed in the electronic equipment comprises a first control, and the first control is used for triggering jumping from the first interface to the second interface. And after the user operates the first control, the electronic equipment jumps from the first interface to the second interface. In the process, the electronic equipment displays the transition dynamic effect of jumping from the first interface to the second interface, so that the visual continuity is improved. Wherein the first interface and the second interface are interfaces of different applications; the display task of the transition dynamic effect is executed by the first thread, the priority of the first thread is greater than or equal to the priority of the thread used for executing the display task of the second interface in the process of executing the display task, and the first thread can preferentially use the running resources, so that the playing fluency of the transition dynamic effect is ensured, and the operation experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the popularization of electronic devices, users of electronic devices have higher requirements for the operation experience of electronic devices. Currently, in the scenario of page switching in response to a user's trigger operation, an electronic device can use a transition animation to connect two different pages, thereby reducing the user's perception of interface jumps through visual continuity. Moreover, the transition animation can also strengthen the relationship between the two pages for the user and give the user an operation feedback.

[0003] However, currently when an electronic device jumps from one page to another, the transition animation may experience stuttering or frame dropping, resulting in a discontinuous visual experience for the user during the interface jump, thereby causing the user to think that the electronic device has 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, which improve the priority of the thread executing the transition animation playing task, avoid stuttering or frame dropping of the transition animation, and improve the user's operation experience.

[0005] In a first aspect, this application provides a thread priority management method, which is applied to an electronic device. The electronic device can display a first interface, and the first interface displayed on the electronic device includes a first control, and the first control is used to trigger a jump from the first interface to the second interface. After the user operates on 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 from the first interface to the second interface to achieve the connection between the two interfaces through the transition animation during the jump, thereby improving visual continuity. Among them, the first interface and the second interface are interfaces of different applications; the display task of the transition animation 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 a second thread, and the second thread is a thread used to execute the display task of the second interface.

[0006] Since the first interface and the second interface are interfaces of different applications, after jumping from the first interface to the second interface, the application in the foreground of the electronic device becomes the application to which the second interface belongs, so that the user can interact with the application to which the second interface belongs.

[0007] In some embodiments, after the application to which the second interface belongs becomes the foreground application, the application to which the first interface belongs becomes the background application. Herein, an application in the foreground of the electronic device refers to an application program that directly interacts with the user currently, such as an application in a visible state, accepting user input, or performing key rendering tasks. An application in the foreground of the electronic device can also be referred to as a foreground application. An application in the background of the electronic device refers to an inactive application program, which may be in a paused, dormant, or only performing lightweight tasks state. An application in the background of the electronic device can also be referred to as 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 process to achieve the connection between the two interfaces. Among them, the display task of the transition animation is executed by the first thread, and during the execution of the display task, the priority of the first thread is higher than that of the second thread. In this way, the first thread can preferentially use the running resources, thereby ensuring the real-time performance of the first thread to execute the transition animation playback task, and then ensuring the smoothness of the transition animation playback, improving the user's operation experience.

[0009] In a possible implementation of the first aspect, in response to the user's operation on the first control, the electronic device can also 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 that of the second thread. Specifically, the electronic device can configure the priority of the first thread to the first level and pause the priority update function of the first thread; where the first level is greater than or equal to the level of the priority of the second thread; in the case of pausing the priority update function of the first thread, the electronic device does not respond to the priority update task of the first thread.

[0010] Among them, the electronic device includes a scheduling module, and the scheduling module can configure the priority of the first thread to the first level and pause 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 bit. Similarly, when the electronic device does not need to ensure that the priority of the first thread is greater than or equal to that of the second thread, the electronic device can clear the set global flag bit to restore 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 the first level is greater than or equal to the level of the priority of the second thread. In this way, the first thread can preferentially use the running resources compared to the second thread, or both the first thread and the second thread can preferentially use the running resources. Moreover, in the above implementation, the electronic device also suspends the priority update function of the first thread, which can prevent the priority of the first thread from being updated from the first level to a lower other level, and can also avoid the problem of reduced real-time performance of the first thread when executing the transition animation playing task.

[0013] In a 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 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 identifiers of the applications to which the interfaces displayed before and after the interface jump belong, and the application identifiers of the applications to which the interfaces displayed before and after the interface jump carried in the first instruction are different; the scheduling module determines, according to the received first instruction, 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 during the process of jumping from the first interface to the second interface, the priority of the first thread is the first level, and it is avoided that the electronic device updates the priority of the first thread during this process, thereby causing the priority of the first thread to decrease. In this way, by fixing the priority of the first thread, it can be ensured that the first thread is not interfered by priority scheduling during the execution of the transition animation playing task, and it is avoided that the transition animation becomes stuck due to the decrease in the priority of the first thread. In this way, the user perception fluency can be effectively improved.

[0015] In a possible implementation of the first aspect, before configuring the priority of the first thread to the first level and suspending the priority update function of the first thread, the electronic device also needs to determine that the current scenario meets a preset condition; where the preset condition includes 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 identifiers of the applications to which the interfaces displayed before and after the interface jump belong. The electronic device can determine the identifiers of the threads corresponding to the applications to which the interfaces displayed before and after the jump belong according to the application identifiers. Moreover, an important thread list is stored in the electronic device, and the application identifiers corresponding to the important threads are stored in the important thread list. In this way, when there is an identifier in the important thread list that is the same as the identifier of the thread corresponding to the application to which the interface displayed before the jump belongs, the electronic device can determine the thread for executing the transition effect playing task corresponding to the application to which the interface displayed before the jump belongs as the preset thread.

[0017] For example, the first instruction carries the application identifier V1 of the application to which the first interface belongs and the application identifier V2 of the application to which the second interface belongs. Moreover, the important thread list stored in the electronic device includes the application identifier V1, so the electronic device can determine that the first thread is the preset thread. Another example is that the first instruction carries the application identifier V1 of the application to which the first interface belongs and the application identifier V2 of the application to which the second interface belongs. Moreover, the important thread list stored in the electronic device includes the application identifier V2, so the electronic device can determine that the first thread is the preset thread. In this way, 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 manner, the electronic device configures the priority of the first thread to the first level and suspends the priority update function of the first thread only when the preset conditions are met. In this way, it is possible to prevent the first thread from occupying high-priority resources for a long time.

[0019] In a possible implementation manner of the first aspect, after displaying the transition effect of jumping 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 update task of 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 a possible implementation manner 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, and the second control is used to trigger a jump from the third interface to the fourth interface. In response to the user's operation on the second control, the transition effect of jumping from the third interface to the fourth interface is displayed. Among them, the third interface and the fourth interface are interfaces of the same application; the display task of the transition effect of jumping from the third interface to the fourth interface is executed by a third thread. During the process of jumping from the third interface to the fourth interface, the priorities of the third thread and the fourth thread do not change, and the fourth thread is the thread for executing the display task of the fourth interface.

[0021] In the above implementation, in response to the user's operation on the second control, the electronic device can jump from the third interface to the fourth interface, and play a transition effect during the jump to achieve the connection between the two interfaces. Among them, the display task of the transition effect is executed by the third thread, and the priorities of the third thread and the fourth thread do not change during the execution of the display task. Since the third interface and the fourth interface are interfaces of the same application, it indicates that there is still a possibility that the user interacts with the application and jumps to another interface within the application in a short period of time. Therefore, the priorities of the third thread and the fourth thread can be kept unchanged to avoid the system overhead caused by priority switching and ensure the stability of the overall performance.

[0022] In a 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 thread and the fourth thread to remain unchanged through the scheduling module.

[0023] In a possible implementation of the first aspect, before the scheduling module in the electronic device controls the priorities of the third thread and the fourth thread to remain unchanged, 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. The fourth instruction carries the application identifier of the application to which the interfaces displayed before and after the interface jump belong. The application identifiers of the applications to which the interfaces displayed before and after the interface jump belong carried in the fourth instruction are the same. The scheduling module determines that the third interface and the fourth interface are interfaces of the same application according to the received fourth instruction. In this way, the electronic device can control the priorities of the third thread and the fourth thread to remain unchanged when the interfaces displayed before and after the interface jump belong to the same application, avoiding the system overhead caused by priority switching.

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

[0025] Since the camera application and the gallery application have high performance requirements for the electronic device, during the process of switching from the camera application to the gallery application, the priorities of the threads can be managed through the thread priority management method provided in the first aspect above, so as to ensure that the priority of the thread for playing the transition effect task is higher during the process of switching from the camera application to the gallery application, and avoid the transition effect from getting stuck or dropping frames. Similarly, the notification center and the control center have high performance requirements for the electronic device. Therefore, in the case of switching from the desktop or other applications to the notification center or the control center, the electronic device can also manage the priorities of the threads through the thread priority management method provided in the first aspect above.

[0026] In a second aspect, the present 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 on the electronic device includes a second control, where the second control is used to trigger a jump from the third interface to a fourth interface. In response to a user's operation on the second control, a transition effect of jumping from the third interface to the fourth interface is displayed. Among them, the third interface and the fourth interface are interfaces of the same application; the display task of the transition effect of jumping from the third interface to the fourth interface is executed by a third thread, and during the process of jumping from the third interface to the fourth interface, the priorities of the third thread and the fourth thread do not change, and the fourth thread is a thread used to execute the display task of the fourth interface.

[0027] In the above implementation, in response to a user's operation on the second control, the electronic device can jump from the third interface to the fourth interface, and a transition effect is played during the jump to achieve the connection between the two interfaces. Among them, the display task of the transition effect is executed by the third thread, and during the execution of the display task, the priorities of the third thread and the fourth thread do not change. Since the third interface and the fourth interface are interfaces of the same application, it indicates that within a short period of time, there is still a possibility that the user interacts with the application and jumps to another interface within the application again. Therefore, the priorities of the third thread and the fourth thread can be kept unchanged to avoid the system overhead caused by priority switching and ensure the stability of the overall performance.

[0028] In a third aspect, the present 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 images generated by the processor, the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device is caused to execute the methods in the first aspect and any one of its possible design manners, and the methods in the second aspect and any one of its possible design manners.

[0029] In a fourth aspect, the present application provides a readable storage medium, including computer instructions, which when running on an electronic device, cause the electronic device to execute the methods in the first aspect and any one of its possible design manners, and the methods in the second aspect and any one of its possible design manners.

[0030] In a fifth aspect, the present application provides a computer program product, including computer programs / instructions, which when executed by a processor, cause the electronic device to execute the methods in the first aspect and any one of its possible design manners, and the methods in the second aspect and any one of its possible design manners.

[0031] In a sixth aspect, the present application provides a device, which is included in an electronic device and has a function of implementing the behavior of the electronic device in any of the methods in the above aspects and possible implementation manners. 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 sending module or unit, a control module or unit, a storage module or unit, etc.

[0032] In a seventh aspect, an embodiment of the present application provides a chip system, which includes a processor and may further include a memory for implementing any of the methods provided in the first aspect above, as well as the methods in the second aspect and any of its possible design manners. The chip system may be composed of chips or may include chips and other discrete devices.

[0033] It can be understood that the electronic devices provided in the above third aspect and any of its possible design manners, the readable storage medium in the fourth aspect, and the computer program product in the fifth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a schematic diagram of a camera application scenario switching provided by an embodiment of the present application; Figure 2 It is a flowchart of a thread priority management provided by an embodiment of the present application Figure 1 ; Figure 3 It is a schematic diagram of a thread priority management provided by an embodiment of the present application Figure 1 ; Figure 4 It is a schematic diagram of a magnified animation playback provided by an embodiment of the present application; Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application; Figure 6 It is a software structure block diagram of an electronic device provided by an embodiment of the present application; Figure 7 It is a flowchart of a thread priority management provided by an embodiment of the present application Figure 2 ; Figure 8 It is a schematic diagram of a thread priority management provided by an embodiment of the present application Figure 2 ; Figure 9 It is a schematic diagram of a pull-down notification center scenario switching provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0035] Hereinafter, the terms "first" and "second" are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of this embodiment, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after 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 items or plural items. For example, at least one of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or multiple.

[0036] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to give examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.

[0037] Before introducing the embodiments of this application, the technologies related to the embodiments of this application will be introduced in detail first.

[0038] An activity component is an application component in an application that is responsible for presenting the user interface and handling user interactions. An activity component can be responsible for implementing one or more functions. Therefore, an application may include at least one activity component.

[0039] In the case of an application including one activity component, this activity component can implement multiple functions. For example, a shopping application includes one activity component, which can be responsible for product display, shopping cart management, order management, and management of the user login status, etc.

[0040] In the case of multiple activity components included in an application, these activity components can cooperate with each other. For example, a news media application includes a home page activity component and a news detail page activity component. Among them, the home page activity component is responsible for displaying news lists, hot topics, category navigation, etc. on the home page, and providing user interaction entrances, such as search, refresh, category filtering, etc. The news detail page activity component can be responsible for the display of news details, and the news detail page activity component can also be responsible for providing user interaction entrances for operations such as like, comment, share, return, etc.

[0041] Among them, the home page activity component and the news detail page activity component can be switched between each other. For example, the home page activity component can display the home page including a news list, and the news list includes entertainment news. In response to a user's trigger operation on the entertainment news in the home page news list, the news detail page activity component can be launched, so that the news detail page activity component can display a news display interface including the specific content of the entertainment news. The news display interface can include a return control. In response to a user's trigger operation on the return control, the home page activity component can be launched, so that the home page activity component can display the home page again. The specific switching process between the home page activity component and the news detail page activity component can refer to related technologies and will not be elaborated here.

[0042] In the above example, the mutual switching between the two activity components in the news media application can realize the switching of different functions in the same application. Different activity components included in different applications can also be switched to achieve cross-application functional interaction, enabling seamless cooperation between different applications.

[0043] In some embodiments, the camera activity component in the camera application and the gallery activity component in the gallery application can be switched between each other. When the camera application is running, the camera activity component can be responsible for the display of the interface related to taking pictures. As Figure 1 shown, the camera activity component can be responsible for displaying the shooting preview interface 101 on the mobile phone, and the displayed shooting preview interface 101 includes a thumbnail 102 corresponding to the taken photo. In response to a user's trigger operation on the thumbnail 102, the camera activity component can be switched to the gallery activity component, so that the gallery activity component can be responsible for displaying the photo display interface 103 as Figure 1 shown on the mobile phone.

[0044] To enhance the fluency of the user experience, during the process of switching from the camera activity component to the gallery activity component, a switching animation effect can be added to reduce the abruptness of the interface jump and improve visual coherence. As Figure 1 shown, in response to the user's triggering operation on the thumbnail 102, the mobile phone can display a zoom-in animation effect in which the thumbnail 102 gradually enlarges and transforms into the photo display interface 103.

[0045] However, it is found during use that when the mobile phone displays this zoom-in animation effect, there will be problems of stuttering and frame dropping in the playback of the zoom-in animation effect.

[0046] Analyzing this problem, it is found that the above-mentioned zoom-in animation effect is executed by the camera main thread, and during the process of the camera main thread executing the zoom-in animation effect playback task, the priority of the camera main thread decreases. In this way, the camera main thread with reduced priority needs to compete for running resources with other threads in the mobile phone, resulting in the camera main thread waiting during the process of running the zoom-in animation effect playback task, and thus there is stuttering and frame dropping in the zoom-in animation effect.

[0047] For the specific reasons for the stuttering and frame dropping in the zoom-in animation effect, please refer to Figures 2 - 4 and the following analysis.

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

[0049] Among them, the scheduling module can monitor that the camera activity component starts running in the camera main thread. Then, the scheduling module can set the priority of the camera main thread to the real-time level to ensure that the camera main thread can preferentially use running resources, so that the camera application can run smoothly in the foreground. And the scheduling module can also reduce the priority of other threads except the camera main thread to avoid these threads competing with the camera main thread for running resources.

[0050] It should be noted that the priorities involved in the embodiments of the present application include a real-time level and a normal level, and the real-time level is higher than the normal level. However, in fact, the embodiments of the present application do not limit the specific types of priorities and the rules for the levels of priorities, and the priority rules can be set according to the actual application scenarios. For example, in a priority rule, the priorities of threads can be divided into 256 levels, and any integer value from 0 to 256 can represent a priority. The smaller the value, the higher the priority, 0 being the highest priority and 256 being the lowest priority. In the case of adopting such a 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 that of the gallery main thread.

[0051] Among them, the camera activity component can be used to display a shooting preview interface on the mobile phone, and the displayed shooting preview interface may include a taking photo control. The camera activity component can also be used to sense the triggering operations of the user. For example, when the camera main thread senses through the camera activity component that the user triggers the taking photo control in the shooting preview interface, the camera main thread can notify the background thread of the camera application to capture the original image from the camera hardware and process the original image to obtain a photo. When the background thread of the camera application obtains the photo, it can also generate a thumbnail corresponding to the photo and send the thumbnail to the camera main thread, so that the camera main thread can display the thumbnail in the shooting preview interface through the camera activity component, such as Figure 1 the thumbnail 102 shown in the shooting preview interface 101 as shown. In this way, the user can be prompted that the photo has been taken through the thumbnail 102. In addition, the user can also enter the photo viewing interface through the thumbnail, which is convenient for the user to operate.

[0052] It should be noted that after the camera application is started, the camera main thread and the background thread corresponding to the camera application are both created to support the operation of the camera application. The camera main thread is responsible for tasks related to interface display and interaction. For example, the display task of the shooting preview interface and the task of playing the zoom-in animation based on the user's operation. The background thread of the camera application runs in the background of the mobile phone and is responsible for tasks related to image acquisition and processing.

[0053] Among them, since the camera application runs in the foreground and the camera main thread needs to be responsible for the rendering and display of the shooting preview interface, the priority of the camera main thread is the real-time level. The tasks processed by the background thread of the camera application take more time compared to the tasks processed by the camera main thread, and the tasks processed by the background thread of the camera application have less relevance to the real-time display content. Therefore, the priority of the background thread of the camera application is the normal level.

[0054] The embodiments of the present application mainly relate to the tasks executed by the camera main thread and the priorities when executing tasks. The tasks executed by the background thread corresponding to the camera application and the priorities when executing tasks have less relevance to the embodiments of the present application. Therefore, for the content related to the background thread corresponding to the camera application, reference can be made to the related art, and no further elaboration will be provided here.

[0055] In addition, since the camera application needs to run in coordination with the gallery application when executing the photographing task, after the camera application is started, the gallery application, as an associated application of the camera application, is also started. At this time, the camera application runs in the foreground of the mobile phone, and the gallery application runs in the background of the mobile phone. The gallery main thread corresponding to the gallery application also runs in the background of the mobile phone. Therefore, the priority of the gallery main thread is lower than that of the camera main thread and is at the normal level.

[0056] As Figure 3 shown, from time T1 to time T2, the camera main thread is responsible for the display task of the shooting preview interface. Therefore, the priority of the camera main thread is at the real-time level. The gallery main thread runs in the background of the mobile phone waiting, so the priority of the gallery main thread is at the normal level.

[0057] Combined with Figure 2 and Figure 3 shown, at time T2, the user performs a triggering operation on the thumbnail 102 shown in Figure 1 .

[0058] The camera activity component can sense the triggering operation of the user on the thumbnail 102 in Figure 1 . In response to the triggering operation of the user on the thumbnail 102 in Figure 1 , the camera main thread can send instruction A to the gallery main thread to cause the gallery main thread to start the gallery activity component.

[0059] Among them, since the communication between the camera application and the gallery application is cross-process communication, the instruction A sent from the camera main thread to the gallery main thread is implemented through the cross-process communication asynchronous binder service. Specifically, the camera activity component triggers the camera main thread to execute the asynchronous binder communication task by calling startActivity(intent) to pass the instruction A carrying the intent to the activity manager service (AMS). Among them, the intent is the intent used to start the gallery activity component. After that, based on the intent, AMS can notify the gallery main thread to start the gallery activity component through the asynchronous binder service, and AMS can also notify the camera main thread through the asynchronous binder service to make the camera activity component enter the paused state (onPause()).

[0060] Since the communication process implemented by the asynchronous binder service takes a relatively long time, there is a time difference between the moment when the instruction A is sent from the camera main thread and the moment when the gallery main thread starts the gallery activity component. For example, at the T2 moment when the user triggers the thumbnail 102, the camera main thread immediately sends the instruction A to the gallery main thread. Therefore, it can be considered that the camera main thread sends the instruction A at the T2 moment. But as Figure 2 shown, the gallery main thread may receive the instruction A and start the gallery activity component at a moment after the T2 moment, such as at the T3 moment.

[0061] In some embodiments, the scheduling module can adjust the priority of the thread corresponding to the activity component when the activity component switches. Specifically, AMS can determine whether the activity component switches, and update the process state when the activity component switches, so that the scheduling module adjusts the priority of the thread when it detects that the process state changes.

[0062] In some examples, the AMS notifies the main thread of the gallery to start the gallery activity component through the asynchronous binder service, and notifies the camera activity component to enter the paused state (onPause()) through the asynchronous binder service. After that, the AMS can determine through the activity component stack that the main thread of the gallery has started the gallery activity component, and the camera activity component in the main thread of the camera has entered the paused state. After that, the AMS can adjust the process of the gallery application associated with the gallery activity component to the foreground process, and adjust the process of the camera application associated with the camera activity component to the background process. In this way, the scheduling module can monitor that the process of the gallery application has become the foreground process, while the process of the camera application has become the background process. At this time, the scheduling module can set the priority of the main thread of the gallery corresponding to the gallery application to the real-time level, and set the priority of the main thread of the camera corresponding to the camera application to the normal level.

[0063] In the above way, the scheduling module can adjust the priorities of the main threads of the camera and the gallery when the camera activity component enters the paused state and the gallery activity component is started. As Figure 2 shown, at time T3, the scheduling module can lower the priority of the main thread of the camera corresponding to the camera activity component and increase the priority of the main thread of the gallery corresponding to the gallery activity component to ensure that the main thread of the gallery can preferentially use the running resources to support the gallery activity component to respond promptly to the user's operations.

[0064] Among them, at time T3, the main thread of the gallery receives instruction A and starts the gallery activity component. At this time, the AMS can determine that the activity component has switched and update the process corresponding to the gallery application to the foreground process. In this way, the scheduling module can monitor that the process of the gallery application has become the foreground process, while the process of the camera application has become the background process. The process for the AMS to determine that the activity component has switched and update the process state is very short, and the time for the scheduling module to monitor through the AMS that the process of the gallery application has become the foreground process is also very short. Therefore, it can be considered that the scheduling module changes the priority of the thread at time T3.

[0065] After the scheduling module adjusts the priority of a thread, the scheduling module may send a priority change instruction to the kernel so that the kernel allocates running resources to the thread based on the priority change instruction. Specifically, after receiving the priority change instruction, the kernel may pass the priority change instruction to a system on chip (SOC) through a relevant interface, enabling the SOC to implement resource scheduling and supply. Among them, the communication time between the scheduling module and the kernel is also very short. Therefore, it can be considered that the kernel starts to allocate running resources to the main gallery thread with a higher priority at time T3.

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

[0067] In response to a user's Figure 1 trigger operation on the thumbnail 102, the camera main thread may also start to execute the task of playing the zoom-in animation. Among them, the time difference between the moment when the camera main thread sends instruction A to the main gallery thread and the moment when the camera main thread starts to execute the task of playing the zoom-in animation is relatively small, and in the embodiments of the present application, it can be regarded as the same moment.

[0068] As Figure 2 shown, at time T2, in response to a user's trigger operation on the thumbnail 102, the camera main thread may start to execute the task of playing the zoom-in animation so that the camera activity component can display the zoom-in animation. In this way, the user can see the zoom-in process on the display screen of the mobile phone from Figure 1 the thumbnail 102 in which it gradually zooms in and transforms into the photo display interface 103.

[0069] Based on the above analysis, it can be known that the camera main thread starts to execute the task of playing the zoom-in animation at time T2, and at time T2, the priority of the camera main thread is still at the real-time level. However, since the camera main thread needs to send instruction A through an asynchronous binder service and there is a time delay in the sending of instruction A, the main gallery thread will not start the gallery activity component immediately after the camera main thread sends out instruction A. It may not be until time T3 that the main gallery thread receives instruction A and starts the gallery activity component. At this time, the foreground camera activity component for display is switched to the gallery activity component. As described above, the scheduling module sets the priority of the camera main thread to the normal level.

[0070] As Figure 3As shown, in response to the user's triggering operation on the thumbnail 102, during the process of the camera main thread executing the play task of the zoom-in animation effect from time T2 to time T3, the priority of the camera main thread is the real-time level. Therefore, the mobile phone kernel preferentially allocates running resources to the camera main thread. Thus, during this process, there will be no lag in the process of the camera main thread playing the zoom-in animation effect.

[0071] If the camera main thread completes the play task of the zoom-in animation effect at time Tm, the gallery main thread can be responsible for the display task of the photo viewing interface at time Tm. Then, as Figure 3 shown, from time T3 to time Tm, the camera main thread is still executing the play task of the zoom-in animation effect, and during this process, the priority of the camera main thread is the normal level. From time T3 to time Tm, the gallery main thread does not execute tasks related to interface display. However, since the scheduling module sets the priority of the gallery main thread to the real-time level at time T3, the mobile phone kernel will preferentially allocate running resources to the gallery main thread with a higher priority. Then, the camera main thread with a normal priority needs to compete for running resources with other threads with a normal priority. Thus, during the process of the camera main thread competing for running resources from time T3 to time Tm, it needs to queue up to wait for the mobile phone kernel to allocate running resources. During the process of the camera main thread waiting for running resources, it cannot execute the play task of the zoom-in animation effect. Therefore, there will be problems of lag and frame dropping in the play of the zoom-in animation effect.

[0072] As Figure 4 shown in (a) below, if the zoom-in animation effect is played at a normal speed, it can be played from time T2 to time Tn, and during the entire play process, a total of 8 frames of animation pictures are played. Due to the decrease in the priority of the camera main thread at time T3, as Figure 4 shown in (b) below, the zoom-in animation effect is played from time T2 to time T3, and a total of 3 frames of animation pictures are played, and there is no frame dropping and lag during this process. From time T3 to time Tm, during the entire play process, a total of 3 frames of animation pictures are played. Among them, 3 frames of animation pictures have frame dropping due to the camera main thread waiting for running resources for a long time. When the time interval between the third frame of the animation picture and the fifth frame of the animation picture is greater than the effective lag interval visible to the human eye (such as 50 ms), the user can see obvious lag in the play of the zoom-in animation effect as Figure 4 shown in (b) below.

[0073] Moreover, since the camera main thread needs to queue up to wait for the allocation of running resources, the actual end time Tm of the zoom-in animation effect may be later than the time Tn when the zoom-in animation effect should end. Thus, it will also lead to a situation where the play time of the zoom-in animation effect is relatively long, thereby bringing an experience of untimely response to the user.

[0074] Based on this, the present application provides a thread priority management method. The first interface displayed on the electronic device includes a first control. 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 effect when jumping from the first interface to the second interface to improve visual continuity. Among them, the first interface and the second interface are interfaces of different applications; the display task of the transition effect 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 thread used to execute the display task of the second interface. In this way, the first thread can preferentially use the running resources to ensure the smooth playback of the transition effect and improve the user's operation experience.

[0075] Furthermore, the third interface displayed on the electronic device includes a second control. In response to the user's operation on the second control, the electronic device displays a transition effect when jumping from the third interface to the fourth interface. Among them, the third interface and the fourth interface are interfaces of the same application; the display task of the transition effect when jumping 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 priorities of the third thread and the fourth thread do not change, and the fourth thread is the thread used to execute the display task of the fourth interface. In this way, in the case where there may be frequent switching within the application, the priorities of the threads are not frequently adjusted, which can avoid waste of resources and resulting in performance lag.

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

[0077] Figure 5 The structural schematic diagram of the electronic device 100 is shown.

[0078] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a 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 acceleration sensor 180E, a distance sensor 180F, a proximity light 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.

[0079] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0080] The processor 110 may include one or more graphics processing units (GPUs), which execute program instructions to generate or change display information. The processor 110 may also include an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The electronic device 100 realizes the display function through the GPU, the display screen 194, and the application processor, etc.

[0081] The electronic device 100 may realize the shooting function through an image signal processor (ISP), the camera 193, a video codec, the GPU, the display screen 194, and the application processor, etc.

[0082] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the Android® system with a layered architecture as an example, the software structure of the electronic device 100 is exemplarily described.

[0083] Figure 6 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0084] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android® system is divided into four layers, from top to bottom, namely the application layer, the framework layer, the native layer, and the kernel layer.

[0085] It should be noted that the embodiments of the present application take the Android® system as an example for illustration. In other operating systems (such as the Harmony® system, the IOS® system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solution of the present application can also be implemented.

[0086] The application layer may include a series of application program packages. For example, the application layer may include system applications and third-party applications. Among them, the system applications may include a camera application, a gallery application, a desktop application, a notification center, a control center, etc. The third-party applications may include third-party developed camera applications, media applications, social applications, game applications, etc.

[0087] Applications can be switched between each other. Moreover, when switching from one application to another application, the electronic device can display a transition animation effect to connect the different interfaces displayed by the two different applications. For example, as Figure 1 shown, it is possible to switch from the camera application to the gallery application. During the switching process, the mobile phone can display a zoom-in animation effect in which the thumbnail 102 gradually enlarges and transforms into the photo display interface 103. Another example is that the electronic device can switch from the desktop application to the game application. During the switching process, the mobile phone can display a transition animation effect. Another example is that the electronic device switches from the desktop application to the control center. During the switching process, the mobile phone can display a transition animation effect. The following embodiments take the switching from the camera application to the gallery application as an example for illustration, but the use of the solution of the present application is not limited thereto.

[0088] In some embodiments, during the process of switching from one application L1 to another application L2, the main thread corresponding to application L1 can send an instruction to the main thread of application L2 through the interface provided by the asynchronous binder service. As Figure 6 shown, in response to the user's trigger 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.

[0089] When an application is started, a thread corresponding to the application is created.

[0090] For example, when the camera application is launched, the camera main thread and other related threads are created, enabling the camera application to respond to user operations and perform various tasks such as enabling the photo-taking mode, enabling the video-recording mode, sliding the shooting perspective task, zooming the shooting perspective, taking a photo, starting video recording, and pausing video recording. Specifically, the camera main thread in the camera application can execute the above tasks, and during this process, the camera main thread can call relevant processes or threads for collaborative processing. For example, the camera main thread can call the background thread corresponding to the camera application to be responsible for tasks related to image acquisition and image processing. Among them, the tasks related to image processing can include performing post-processing of camera algorithms on the image, adding an address watermark to the image, generating a thumbnail based on the image, obtaining a Joint Photographic Experts Group (JPEG) format photo based on the image after post-processing of the camera algorithm, and storing the JPEG format photo in the photo gallery, etc.

[0091] For another example, when the camera application is launched, the photo gallery application, as an associated application of the camera application, will also be launched. At this time, the photo gallery main thread can be created. Or, when the photo gallery application is launched, the photo gallery main thread is created. The photo gallery main thread can store photos and information corresponding to the photos. The photo gallery main thread can also execute tasks related to the display of the large image corresponding to the thumbnail after the zoom-in animation is played, or execute tasks related to the animation playback within the photo gallery, etc.

[0092] The framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The framework layer is implemented based on the Java language and includes some predefined functions. In some embodiments, the framework layer includes the framework layer asynchronous binder service, the framework layer scheduling module, and AMS.

[0093] The framework layer asynchronous binder service can provide an interface for the applications in the application layer. The interface provided by the asynchronous binder service is an interface defined by the Android Interface Definition Language (AIDL) and is used for inter-process communication (IPC).

[0094] The native layer is located between the framework layer and the kernel layer and is mainly composed of core libraries and runtime environments written in C / C++ language, responsible for high-performance computing, hardware interaction, and support for underlying system services. In some embodiments, the native layer includes the native layer asynchronous binder service and the native layer scheduling module.

[0095] In the above-mentioned framework layer and native layer, the framework layer asynchronous binder service provides interfaces for the application layer through a series of Java classes to encapsulate the details of the asynchronous binder service implementation at a lower level, enabling developers to conveniently use the Java language to implement communication using the asynchronous binder service. The native layer asynchronous binder service is implemented in C++ to implement the underlying asynchronous binder service mechanism, and the native layer asynchronous binder service can directly interact with the asynchronous binder driver in the kernel layer. The framework layer asynchronous binder service and the native layer asynchronous binder service jointly implement asynchronous binder communication between the application layer and the kernel layer. Therefore, to simplify the drawings for easy understanding, as Figure 6 shown, the framework layer and the native layer are merged, and the framework layer asynchronous binder service and the native layer asynchronous binder service are collectively referred to as the asynchronous binder service.

[0096] Similarly, the framework layer scheduling module also provides interfaces for the application layer through a series of Java classes to encapsulate the priority scheduling details at a lower level. The native layer scheduling module can directly interact with the kernel scheduler in the kernel layer so that the kernel scheduler adjusts the running resources of the thread according to the updated priority, thereby implementing the priority scheduling of the thread. To simplify the drawings for easy understanding, as Figure 6 shown, after the framework layer and the native layer are merged, the framework layer scheduling module and the native layer scheduling module can be collectively referred to as the scheduling module.

[0097] Among them, the scheduling module can be responsible for scenario recognition and adjust the thread priority based on the performance scheduling policy and resource supply of the electronic device. For example, as described above, the scheduling module can adjust the thread priority when the activity component switches. Among them, when the camera main thread sends the application identifier of the application to which the interface before and after the interface jump belongs to the scheduling module, the scheduling module can recognize the scenario corresponding to the instruction. And 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 mobile phone and set the global flag bit to pause the priority update function of the camera main thread. The specific implementation of this part can be seen in the detailed description later and will not be elaborated here.

[0098] In some embodiments, as Figure 2 shown, the process of the scheduling module sending the changed priority to the kernel is the Figure 6 process of the scheduling module sending the changed priority to the kernel scheduler in the kernel layer as shown. In some embodiments, after receiving the changed priority, the kernel scheduler can pass the changed priority to the SOC through relevant interfaces to implement the scheduling of running resources.

[0099] The following exemplarily describes the working process of an electronic device in combination with the scenario of communication between a camera application and a gallery application.

[0100] When the touch sensor receives a touch operation, the camera activity component in the camera application can sense the touch operation. When it is determined by the camera main thread based on the touch operation that the user triggers an operation on the thumbnail, the camera main thread can send instruction A to the gallery main thread. For example, as Figure 6 shown, the camera main thread can send instruction A to the AMS through the interface provided by the asynchronous binder service, and the AMS forwards instruction A to the gallery main thread through the asynchronous binder service and the asynchronous binder driver. For a more detailed process of the camera main thread sending an instruction to the gallery main thread, reference can be made to the related technology, Figure 6 and only this process is simply shown.

[0101] Hereinafter, taking the electronic device as a mobile phone as an example, in combination with the Figure 1 shown photo-taking scenario, the thread priority management method provided by the embodiments of the present application will be introduced.

[0102] After the user opens the camera application, the camera activity component is started, and the camera activity component runs in the camera main thread. As described above in relation to Figure 1 and Figure 2 the relevant description, the camera activity component can be responsible for displaying the shooting preview interface 101 on the mobile phone. And after the user performs the operation of taking a photo, the camera activity component can also be responsible for displaying the thumbnail 102 on the shooting preview interface 101, and the thumbnail 102 corresponds to the taken photo. Among them, for the relevant introduction of how the camera activity component in the mobile phone is responsible for the operation of displaying the interface during the process from the start of the camera application to the user triggering an operation on the thumbnail 102, reference can be made to the above Figure 2 relevant description, which will not be elaborated here.

[0103] At time T2, the camera activity component can sense the trigger operation of the user on the thumbnail 102. At this time, the mobile phone can display the enlarged animation effect of the transition from the camera application to the gallery application. During this process, the mobile phone can raise the priority of the camera main thread executing the enlarged animation effect playback task to the real-time level to avoid stuttering or frame dropping of the enlarged animation effect, After the enlarged animation effect is played, the priority of the camera main thread is set to the normal level, and the priority of the gallery main thread is set to the real-time level, so that the mobile phone can display the gallery display interface for displaying photos in the gallery application.

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

[0105] In the above implementation manner, in response to a user's operation on the first control, the electronic device may jump from the first interface to the second interface, and play a transition animation effect during the jump to achieve the connection between the two interfaces. Among them, the display task of the transition animation effect 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 preferentially use the running resources, thereby ensuring the real-time performance of the first thread to execute the transition animation effect playback task, and then ensuring the smoothness of the transition animation effect playback, and improving the user's operation experience.

[0106] The real-time level may be the first level in the present application. It should be noted that in other cases, the first level may be a priority level with a high priority. For example, in the above example regarding the priority-related description, the priority of the camera main thread is 98, the priority of the gallery main thread is 110, and the priority represented by 98 is greater than the priority represented by 110. Here, 98 refers to the first level in the present application. Of course, the present application does not make specific limitations on the specific level division and specific values of the priority.

[0107] Specifically, at time T2, in response to a user's trigger operation on the thumbnail 102 in the shooting preview interface, as Figure 7 shown, the mobile phone may execute the following S701 - S706: S701. The camera main thread sends an instruction A to enable the gallery activity component to the gallery main thread.

[0108] When the user performs a trigger operation on the thumbnail 102 in the shooting preview interface, the camera activity component running in the camera main thread can sense the user's trigger operation on the thumbnail 102. After that, the camera activity component can trigger the camera main thread to send an instruction A for enabling the gallery activity component to the gallery main thread. For the related description of instruction A, reference can be made to the above Figure 2 related description, which will not be elaborated here.

[0109] Among them, as described above, the instruction A sent by the camera main thread to the gallery main thread is cross-process communication, and cross-process communication has a certain time delay. Exemplarily, the camera main thread sends instruction A to the gallery main thread through an asynchronous binder service, asFigure 6 As shown, instruction A needs to go through the framework layer + native layer, and then the kernel layer in sequence, and then start from the kernel layer and go through the framework layer + native layer in sequence to be sent to the gallery main thread. This process takes a certain amount of 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 time, it is already a certain moment after T2, such as T3. As Figure 7 shown, there is a long time interval between T2 and T3.

[0110] Since the communication mechanism of the asynchronous binder involves processes such as the encapsulation of the framework layer and asynchronous callbacks, the asynchronous binder communication mechanism can achieve an asynchronous effect in terms of business logic. That is to say, after the camera main thread sends instruction A to the gallery main thread through the asynchronous binder service, the camera main thread does not need to wait for the feedback from the gallery main thread and can execute other tasks.

[0111] Therefore, after the camera main thread sends instruction A to the gallery main thread, the mobile 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 started.

[0112] S702: The camera main thread sends instruction B to the scheduling module.

[0113] After the camera activity component senses the user's trigger operation on the thumbnail 102, the camera main thread can send instruction B to the scheduling module. Among them, instruction B carries the application identifiers of the applications to which the interfaces displayed before and after the interface jump belong, so that the scheduling module can adjust the priority based on instruction B. Among them, instruction B refers to the first instruction in this application.

[0114] In some examples, after the camera activity component senses that the user performs a trigger operation on the thumbnail 102 in the shooting preview interface, the camera main thread can generate instruction B, which carries the application identifier K1 of the camera application to which the shooting preview interface 101 displayed before the interface jump belongs, and the application identifier K2 of the photo display interface 103 displayed after the interface jump belongs to the gallery application. Then, the camera main thread sends instruction B to the scheduling module.

[0115] Optionally, when switching from the camera activity component to the gallery activity component, which is a case of switching between activity components of different applications, in this way, the mobile phone can ensure that the priority of the camera main thread is higher than that of the gallery main thread through the following steps.

[0116] In some embodiments, after the scheduling module receives instruction B, the following S703 may be executed: S703. The scheduling module determines that the scenario corresponding to instruction B is a scenario of activity component switching between different applications.

[0117] Instruction B carries the application identifiers of the applications to which the interfaces displayed before and after the interface jump belong. That is to say, the instruction has the application identifier K1 of the camera application and the application identifier K2 of the gallery application. Since the application identifier K1 and the application identifier K2 are different, the scheduling module can determine that the corresponding scenario based on instruction B is a scenario of activity component switching between applications.

[0118] In some embodiments, if the scheduling module determines based on the instruction received from the camera main thread that it is a case of activity component switching within the same application currently, it indicates that there is still a possibility of activity component switching between these applications in a short period of time. Then, the scheduling module may not adjust the priority of the thread to avoid performance waste caused by frequent priority adjustments.

[0119] For example, the gallery application includes activity component H1, activity component H2, and activity component H3. Activity component H1 is responsible for displaying the album list interface. Activity component H2 is responsible for displaying the large - image display interface of the first photo in the album list. Activity component H3 is responsible for displaying the large - image display interface of the second photo in the album list. The large - image display interface includes the first photo and the second photo. Among them, the gallery main thread can run activity component H1, activity component H2, and activity component H3.

[0120] First, in response to the user's trigger operation on the first photo in the album list interface, the mobile phone displays the large - image display interface of the first photo, and the large - image display interface of the first photo includes the return control A. At this time, the gallery main thread sends instruction C to the scheduling module. Instruction C carries the application identifier K2 of the gallery application to which the interface displayed before the interface jump belongs, and the application identifier K2 of the gallery application to which the interface displayed after the interface jump belongs. Since the two application identifiers are the same, the scheduling module can determine that it is a scenario of activity component switching within the same application, and the scheduling module may not update the priority of the gallery main thread.

[0121] After that, in response to the user's triggering operation on the return control A, the mobile phone displays the photo album list interface. After that, in response to the user's triggering operation on the second photo in the photo album list interface, the mobile phone displays the large - image display interface of the second photo. During the above process, the scheduling module does not update the priority of the gallery main thread. In this way, performance waste caused by frequent priority adjustments can be avoided.

[0122] When the user performs multiple operations within an application in a short period of time, each operation of the user will trigger the switching of the activity components within the application. If the scheduling module updates the priority of the thread every time an activity switches, it will cause waste of the mobile phone's running resources and reduce the performance of the mobile phone. In addition, in the above - mentioned embodiment, the mobile phone can adjust the thread priority in the scenario of activity component switching between different applications. In this way, the problem of stuttering caused by frequent priority adjustments of the magnifying animation effect can be effectively avoided.

[0123] Among them, the photo album list interface refers to the third interface in this application, the photos in the photo album list interface refer to the second control in this application, and the large - image display interface refers to the fourth interface in this application; the gallery main thread refers to the third thread and the fourth thread in this application.

[0124] Through the above S703, the problem of waste of the mobile phone's running resources can be reduced, so as to improve the performance of the mobile phone and reduce the occurrence of stuttering on the mobile phone.

[0125] After the camera main thread sends instruction B to the scheduling module, or after the scheduling module determines that the scenario corresponding to instruction B is the scenario of activity component switching between different applications, the mobile phone can continue to execute the following S704 - S705 to set the priority of the camera main thread to the real - time level and pause the priority update function of the camera main thread. In this way, it can be ensured that the camera main thread can preferentially use the running resources and avoid the priority of the camera main thread being reduced in subsequent priority adjustment operations.

[0126] S704: Based on instruction B and the important thread list, the scheduling module sets the priority of the camera main thread to the real - time level and sets a global flag bit.

[0127] In some embodiments, the scheduling module can determine whether the current scenario meets a preset condition based on the instruction and the important thread list. Among them, the preset condition includes one or more of the following conditions: the thread that executes the display task before the jump is a preset thread, and the thread that executes the display task after the jump is a preset thread. When it is determined that the current scenario meets the preset condition, the scheduling module can adjust the priority of the thread that executes the transition animation playback task and pause the priority update function of the thread that executes the transition animation playback task.

[0128] Among them, application identifiers corresponding to important threads are stored in the important thread list. An important thread can be a thread with high requirements for running resources. For example, the camera main thread, the gallery main thread, the notification center main thread, the control center main thread, the game main thread, etc. In this way, as long as the threads in any one of the applications before and after the interface jump have high requirements for running resources, the electronic device will determine that the current scenario meets the preset conditions. And at this time, the priority of the thread executing the transition animation is increased.

[0129] For example, the instruction B carries the application identifier K1 of the camera application to which the shooting preview interface 101 displayed before the interface jump belongs, and the application identifier K2 of the gallery application to which the photo display interface 103 displayed after the interface jump belongs. The application identifier K1 and the application identifier K2 are stored in the important thread list. In this way, the application identifier of the application to which the interface displayed before the interface jump belongs, and the application identifier of the application to which the interface displayed after the interface jump belongs exist in the important thread list. 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 scenario meets the preset conditions based on the instruction B and the important thread list. In this way, the scheduling module can set the priority of the camera main thread to a higher level, so as to ensure that the camera main thread can preferentially use running resources during the process of executing the zoom animation playback task.

[0130] Moreover, the scheduling module sets a global flag bit to ensure that the scheduling module will no longer perform priority setting operations on the camera main thread later, and avoid the problem of zoom animation jamming and frame dropping caused by the reduction of the priority of the camera main thread.

[0131] In some other embodiments, when the priority of the camera main thread is at the real-time level, the scheduling module may not adjust the priority of the camera main thread, and the scheduling module only needs to set a global flag bit to prevent the priority of the camera main thread from being reduced from the real-time level to the normal level.

[0132] In some other embodiments, a configuration file (uniperf configuration file) that cooperates with the scheduling module is configured in the mobile phone. The uniperf configuration file may include application identifiers in a pre-configured important thread list. A configuration policy for a global flag may also be configured in the configuration file. For example, when the configuration policy in the configuration file is that the global flag (command ID value) is set to 1, the scheduling module may pause the priority update of the thread executing the transition animation playback task. Another example is that when the configuration policy in the configuration file is that the global flag (command ID value) is set to 0, the scheduling module may enable the priority update of the thread executing the transition animation playback task. The configuration file may also include specific policies on how the scheduling module adjusts the priorities of threads. For example, if the configuration file configures the frequency information of the CPU or GPU and the configuration information of the frequency scheduling duration during the operation of the real-time level thread, then the scheduling module may, when it is necessary to set a thread to the real-time level, configure the corresponding CPU or GPU frequency information and the configuration information of the frequency scheduling duration for this thread to implement setting the priority of this thread to the real-time level.

[0133] Among them, setting the global flag may be a way to pause the update function of the priority of the first thread in this application. The electronic device may also pause the priority update function of the first thread through other means to prevent the priority of the first thread executing the transition animation from being reduced.

[0134] An application corresponds to a main thread and multiple other threads. Generally, the tasks executed by the main thread are related to the tasks of real-time display. Therefore, in the above embodiments, when the scheduling module determines that there is an application identifier carried in the instruction in the important thread list, it may determine that the main thread of the application corresponding to this application identifier is the preset thread.

[0135] Among them, since the transition animation playback task is generally executed by the thread corresponding to the application to which the interface before the interface jump belongs, the scheduling module needs to increase the priority of the camera main thread executing the transition animation playback task. If in other related technologies, the thread corresponding to the application to which the interface after the interface jump belongs executes the transition animation playback task, then the scheduling module needs to increase the priority of the thread corresponding to the application to which the interface after the interface jump belongs.

[0136] S705. The scheduling module sends a priority change instruction to the kernel.

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

[0138] In some embodiments, at time T3 after the mobile phone finishes executing S705, since the scheduling module has set the priority of the camera main thread to the real-time level and set a global flag, at time T3, when it is determined that the activity component has 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.

[0139] To ensure that the mobile phone can promptly respond to the user's operation and play the zoom-in animation effect, after the mobile phone finishes executing S702, the following S706 can be executed: S706: The camera main thread executes the zoom-in animation effect playing task.

[0140] In the above embodiments, after the mobile phone executes S701, it then continues to execute S702. Both S701 and S702 are instruction sending tasks executed by the camera main thread, and the time consumed by the camera main thread to execute the instruction sending task is very short. Among them, the camera main thread sends instruction A through the asynchronous binder service. After the camera main thread passes instruction A into the interface provided by the asynchronous binder service, it can continue to execute other tasks. The time consumed by the camera main thread to pass instruction A into the interface provided by the asynchronous binder service is relatively short. Therefore, it can also be considered that the execution time of S701 is short.

[0141] Based on the above analysis, it can be considered that the completion times of S701 and S702 are relatively close. In the embodiments of the present application, the time difference between the completion times of S701 and S702 can be ignored. Therefore, when ignoring the short time interval between the completion times of S701 and S702, it can be considered that S701 and S702 are completed simultaneously. As Figure 7 shown, S701 starts to be executed at time T2. Since the completion time of S701 is short and the mobile phone can execute S702 after finishing executing S701, S702 can also be considered to start to be executed at time T2. Moreover, the completion time of S702 is also short, and the mobile phone can execute S703 after finishing executing S702. Therefore, the time when the mobile phone starts to execute S703 can also be considered to be the same as the time T2 when the mobile phone starts to execute S701 and S702.

[0142] At time T2, in response to the user's trigger operation on the thumbnail 102 in the shooting preview interface, the electronic device executes S706, which can enable the camera activity component to be responsible for the display of the zoom-in animation effect.

[0143] Furthermore, for Instruction A to successfully reach the main thread of the gallery, it needs to go through a complete cross-process asynchronous Binder communication link, while for Instruction B to successfully reach the scheduling module, it only requires the main thread of the camera to pass Instruction B into 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 main thread of the gallery. In this way, before the gallery activity component is launched, the scheduling module can set the priority of the main thread of the camera to the real-time level based on Instruction B and set a global flag to pause the function of the scheduling module for updating the priority of the camera thread. By doing so, it can be ensured that during the process of the main thread of the camera executing the zoom-in animation playback task, the priority of the main thread of the camera remains at a relatively high level and will not be reduced, enabling the main thread of the camera to preferentially use the running resources, thus ensuring that there will be no lag or dropped frames during the playback process of the zoom-in animation.

[0144] In some other embodiments, the mobile phone can also execute S702 first and then S701. Based on the above description, it can be considered that S701 and S702 are completed simultaneously. Then, if the mobile phone executes S702 first and then S701, similarly, it can be considered that S701 and S702 are completed simultaneously. Also, when the scheduling module successfully receives Instruction B, Instruction A has not yet been successfully received by the main thread of the gallery. Therefore, if the mobile phone executes S702 first and then S701, it can also ensure that during the process of the main thread of the camera executing the zoom-in animation playback task, the priority of the main thread of the camera remains at a relatively high level.

[0145] Optionally, after the main thread of the camera finishes executing the zoom-in animation playback task, it can continue to execute the following S707 - S708: S707: The main thread of the camera sends Instruction D to the scheduling module.

[0146] S708: The scheduling module clears the global flag.

[0147] Instruction D is used to instruct the scheduling module to clear the global flag so that the scheduling module can continue to manage the priority of the thread.

[0148] Among them, the global flag bit can be cleared by deleting the global flag bit or by assigning a null value to the global flag bit. As described in the above example, when the mobile phone executes S705, the command ID value is set to 1, causing the scheduling module to suspend the update function of the camera main thread priority. In some examples, after executing S708, there may no longer be a command ID value in the mobile phone. In this way, the scheduling module can continue to manage the priority of the thread. In some other examples, after executing S708, the command ID value in the mobile phone can also be a null value such as 0 or null. In this way, the scheduling module can also continue to manage the priority of the camera main thread.

[0149] In some embodiments, after the camera main thread completes the zoom animation effect, the camera main thread no longer requires a high-level priority. Therefore, the camera main thread can send an instruction D to the scheduling module to ensure that the scheduling module can promptly lower the priority of the camera main thread. In this way, the performance of the mobile phone can be effectively improved by managing the priority of the thread.

[0150] In the above embodiments, as Figure 8 shown, from time T1 to time T2, the camera main thread is responsible for the display task of the shooting preview interface. Therefore, the priority of the camera main thread is the real-time level. The gallery main thread runs in the background of the mobile phone waiting. Therefore, the priority of the gallery main thread is the normal level.

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

[0152] Before the gallery activity component is started, the camera main thread sends an instruction B to the scheduling module, and the scheduling module can set the priority of the camera main thread to the real-time level based on the instruction B and the important thread list, and set the global flag bit, so that the scheduling module no longer performs priority adjustment operations on the camera main thread. Therefore, as Figure 8As shown, when the gallery activity component starts at time T3, the priority of the camera main thread remains at the real-time level. Due to the start of the gallery activity component, the priority of the gallery main thread is set to the real-time level until the magnification animation playback task is completed at time Tb. At time Tb, the priority of the camera main thread is set to the normal level, while the priority of the gallery main thread remains at the real-time level to ensure that the gallery main thread can be responsible for the display task of the gallery display interface.

[0153] Therefore, by using the method provided in the above embodiment, the camera main thread can preferentially use the running resources to execute the magnification animation playback task. In this way, the problems of jamming and frame dropping during the execution of the magnification animation playback task by the camera main thread can be avoided.

[0154] It can be understood that the thread priority management method provided in the embodiments of the present application can also be used in scenarios where other applications are switched.

[0155] For example, after the user unlocks the mobile phone, the desktop activity component is started, and the desktop activity component runs in the desktop main thread. Among them, the desktop activity component is responsible for displaying the desktop 901 as shown. Figure 9 The desktop 901 includes a notification center operation area 902. In response to a trigger operation performed by the user in the notification center operation area 902, such as a pull-down operation, the desktop main thread starts to execute the playback task of the notification center transition animation. And after the playback task of the notification center transition animation is completed, the mobile phone can display the notification center interface 903. The notification center interface 903 is responsible for being displayed by the notification center activity component, and the notification center activity component runs in the notification center main thread.

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

[0157] Thus, in response to a trigger operation performed by the user in the operation area 902 of the notification center, the desktop main thread can send an instruction carrying the application identifier K3 of the desktop application and the application identifier K4 of the notification center to the scheduling module. Subsequently, the scheduling module can find the application identifier K4 of the notification center in the important thread list. The scheduling module can determine that the thread for the notification center to execute the display task is a preset thread. Therefore, the scheduling module can set the priority of the desktop main thread that executes the transition animation to the real-time level and set a global flag, so that during the process of the desktop main thread executing the notification center transition animation playback task, the scheduling module no longer performs priority adjustment operations on the desktop main thread.

[0158] For another example, similar to the above example, the desktop includes a control center operation area. In response to a trigger operation performed by the user in the control center operation area, such as a pull-down operation, the desktop main thread starts to execute the playback task of the control center transition animation. To prevent the scheduling module from changing the priority of the control center main thread to the real-time level, the important thread list stored in the mobile phone can include the application identifier K5 of the control center.

[0159] Thus, in response to a trigger operation performed by the user in the control center operation area, the desktop main thread can send an instruction carrying the application identifier K3 of the desktop application and the application identifier K5 of the control center to the scheduling module. Subsequently, the scheduling module can find the application identifier K5 of the control center in the important thread list. Thus, the scheduling module can determine that the thread for the control center to execute the display task is a preset thread. Therefore, the scheduling module can set the priority of the desktop main thread that executes the transition animation to the real-time level and set a global flag, so that during the process of the desktop main thread executing the control center transition animation playback task, the scheduling module no longer performs priority adjustment operations on the desktop main thread.

[0160] In some embodiments, the application identifiers stored in the important thread list can be changed, added, or deleted by developers to ensure that the mobile phone can manage the priorities of threads based on the actual needs of users. For example, developers conduct research based on the scenarios in which users use the mobile phone and find that applications such as the camera application, the gallery application, game applications, the notification center, and the control center are high-load applications. These applications have relatively high requirements for the timeliness of the scheduling supply of operating resources such as the CPU / GPU / memory, and the corresponding threads require relatively high priorities. Therefore, in high-load scenarios where the interface switch involves these applications, it is necessary to ensure that the thread corresponding to the activity component before the switch maintains a relatively high level of priority for a period of time after the switch, so as to avoid the problem of stuttering in the transition animation.

[0161] An embodiment of the present application also provides a readable storage medium, which includes computer instructions. When the computer instructions run on the above-mentioned electronic device, the electronic device is enabled to execute each function or step in the above-mentioned method embodiment.

[0162] An embodiment of the present application also provides a computer program product, including a computer program. When the computer program runs on an electronic device, the electronic device is enabled to execute each function or step in the above-mentioned method embodiment.

[0163] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

[0164] In several embodiments provided by the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.

[0165] The unit described as a separate component may or may not be physically separated. The component displayed as a unit may be a physical unit or multiple physical units, that is, it may be located in one place, or it may be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0166] In addition, each functional unit in the various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0167] When the integrated unit is implemented in the form of 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 solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0168] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A thread priority management method, characterized in that: Applied to electronic equipment, the method comprises: Display a first interface, where the first interface includes a first control, and the first control is used to trigger a jump from the first interface to a second interface; In response to the user's operation on the first control, displaying a transition effect from the first interface to the second interface; Among them, 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 in the process of executing the display task, the priority of the first thread is greater than or equal to the priority of the second thread, and the second thread is a thread used to execute the display task of the second interface.

2. The method according to claim 1, characterized in that In response to a user's operation on the first control, the method further includes: configuring the priority of the first thread to be a first level, and suspending a priority update function of the first thread; The first level is higher than 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.

3. The method according to claim 2, 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 an application identifier of an application to which the interface displayed before and after the interface jump belongs, and the application identifiers of the application to which the interface displayed before and after the interface jump carried in the first instruction are different; The scheduling module determines, according to the received first instruction, that the first interface and the second interface are interfaces of different applications.

4. The method according to claim 2 or 3, characterized in that: 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: Determine that the current scene meets the preset conditions; The preset condition includes one or more of the following conditions: 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.

5. The method according to claim 2, characterized in that: After displaying the transition animation from the first interface to the second interface, the method further includes: The priority update function of the first thread is enabled; 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.

6. The method according to claim 1, characterized in that The method further comprises: Displaying a third interface, wherein the third interface includes a second control, and the second control is used to trigger a jump from the third interface to a fourth interface; In response to the user's operation on the second control, displaying a transition animation from the third interface to the fourth interface; Among them, 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, and in the process of jumping from the third interface to the fourth interface, the priorities of the third thread and the fourth thread do not change, and the fourth thread is a thread used to execute the display task of the fourth interface.

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

8. The method according to claim 7, 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 an application identifier of the application to which the interface displayed before and after the interface jump belongs, and the application identifiers of the applications to which the interfaces displayed before and after the interface jump belong carried in the fourth instruction are the same; The scheduling module determines, according to the received fourth instruction, that the third interface and the fourth interface are interfaces of the same application.

9. The method according to claim 1, characterized in that: The first interface is an interface of a camera application, and the second interface is an interface of a gallery application; Or, the first interface is a desktop or application interface, and the second interface is a notification center interface; Alternatively, the first interface is a desktop or application interface, and the second interface is an interface of a control center.

10. 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 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, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device executes the method described in any one of claims 1-9.

11. A readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 9.

12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the electronic device is caused to perform a method as claimed in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Video opening method and device and computer readable storage medium

    CN116980719A

  • Interface display method, readable medium and electronic equipment

    CN117076088A

  • Thread scheduling method and related device

    CN117112154A

  • Display method and device

    CN118885239A

  • Method and device for starting application program and electronic equipment

    CN119440647A