Information sending method, electronic equipment and storage medium
Patent Information
- Application Number
- CN202480003852.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-05-29
- Filing Date
- 2024-01-05
- Publication Date
- 2025-04-18
AI Technical Summary
In electronic devices, when the window information between processes is transmitted, if a function in one process falls into an abnormal state, it will affect the operation of other functions, resulting in performance problems, and the amount of data is large when the window information is synchronized, resulting in stability problems.
By creating a special child thread in the main thread to perform window information sending tasks, avoiding the abnormal state affecting the operation of other functions, and filtering and delaying the sending of window information to reduce the amount of data and sending frequency, using asynchronous binder communication and frame-interval transmission Strategy.
It effectively avoids performance problems caused by function exception state, optimizes the load situation, reduces the amount of window information and sends frequency, and avoids the occurrence of stability problems.
Smart Images

Figure CN119856160A_ABST
Abstract
Description
Information sending method, electronic device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on May 29, 2023, with application number 202310617998.9 and invention name “Information sending method, electronic device and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to an information sending method, electronic device, and storage medium. Background Art
[0003] With the development of computer technology, electronic devices such as mobile phones and tablet computers have become an indispensable part of people's daily lives. Various application windows can be displayed on the screens of electronic devices, providing users with a good visual and operating experience.
[0004] Currently, different processes in electronic devices can transmit window information through inter-process communication. However, when a function in one process that sends window information to another process falls into an abnormal state, it affects the operation of other functions in the same process, causing performance issues.
[0005] Summary of the Invention
[0006] This application provides an information transmission method, electronic device, and storage medium that can avoid performance issues caused by abnormal state of the first function. The technical solution is as follows:
[0007] In a first aspect, a method for sending information is provided. In this method, a main thread of a first process creates a first child thread and a second child thread. The main thread runs a first function to pass first target information to the first child thread. After receiving the first target information passed by the main thread, the first child thread sends the first target information to the second process.
[0008] The first process is a process that can obtain window information. For example, the first process can be a SurfaceFlinger process. Of course, the first process can also be other processes that can obtain window information.
[0009] The first child thread can be called by the main thread through the first function, but cannot be called by the main thread through any other function except the first function. In this case, the first child thread is used to independently execute the sending task of the first function. The main thread can call the first child thread to execute the sending task only when running the first function, and cannot call the first child thread when running other functions.
[0010] The second sub-thread can be called by the main thread through a second function other than the first function. In this case, the second sub-thread is used to execute the sending task of the second function. When the main thread runs the second function, it can call the second sub-thread to execute the sending task. Optionally, the second sub-thread cannot be called by the main thread through other functions other than the second function. In this case, the second sub-thread is used to execute the sending task of the second function alone; or the second sub-thread can be called by the main thread through other functions other than the first and second functions. In this case, the second sub-thread executes the sending task of each of the multiple functions serially.
[0011] The main thread can at least run a first function and a second function, one of the first function and the second function is used to send window information to the second process, and the other is used to instruct the second process to release buffer space. The second process is a process other than the first process. The second processes corresponding to the first function and the second function can be the same or different. For example, the first function can be the updateInputFlinger function, and the second function can be the ReleaseBuffer function. In this case, the second process corresponding to the first function is the process that needs window information, and the second process corresponding to the second function is the process that needs to release buffer space; or, the first function can be the ReleaseBuffer function, and the second function can be the updateInputFlinger function. In this case, the second process corresponding to the first function is the process that needs to release buffer space, and the second process corresponding to the second function is the process that needs window information. For example, the process that needs window information can be a SystemServer process, and the SystemServer process includes an InputDispatcher thread. The InputDispatcher thread can distribute touch events based on window information.
[0012] The first target information is information that the first function needs to send to the second process. For example, if the first function is used to send window information to the second process, the first target information is target window information. Alternatively, if the first function is used to instruct the second process to release buffer space, the first target information is buffer space release information. The target window information can be window information for some or all windows displayed by the electronic device.
[0013] In this application, the main thread can call the first sub-thread to execute the sending task by running the first function, and the main thread can call the second sub-thread to execute the sending task by running the second function. The operation of the first sub-thread and the second sub-thread do not affect each other, so the abnormal state of one of the first function and the second function will not affect the operation of the other function, thereby avoiding performance issues caused by the abnormal state of the first function or the second function.
[0014] Optionally, the first function is used to send window information to the second process, and the first target information is target window information. The main thread runs the first function to perform the following operations: obtaining current window information; determining target window information based on the current window information, where the target window information is other window information in the current window information except for window information containing a preset window type; if it is determined that the window has changed based on the current window information, calling the first child thread based on the target window information to pass the target window information to the first child thread.
[0015] For example, the preset window type may be a window type that cannot be directly operated by the user on the screen. For example, the preset window type may include one or more window types such as an invisible window type and a non-input channel window type.
[0016] In this application, the target window information sent by the first function to the second process is obtained by filtering the current window information. After filtering, the amount of window information that needs to be sent to the second process is greatly reduced, thereby optimizing the load situation and avoiding stability problems to a certain extent.
[0017] Optionally, the first function is used to send window information to the second process, and the first target information is the target window information. After the first child thread receives the first target information passed by the main thread, the operation of sending the first target information to the second process can be: after the first child thread receives the target window information passed by the main thread, determine the time interval between the moment of receiving the target window information and the moment of last sending window information to the second process; and send the target window information to the second process according to the time interval.
[0018] In the present application, the first sub-thread can send the target window information to the second process according to the time interval between the moment when the target window information is received and the moment when the window information was last sent to the second process, so as to reduce the frequency of sending window information.
[0019] Among them, the operation of the first sub-thread sending the target window information to the second process according to the time interval can be: the first sub-thread sends the target window information to the second process when the time interval is greater than or equal to the first time length; when the time interval is less than the first time length, if the next window information is not received within the first time length after receiving the target window information, the target window information is sent to the second process.
[0020] The first duration is greater than the frame interval of the display screen. Optionally, the first duration may be less than or equal to m times the frame interval, where m is greater than 1, such as 2, 3, etc.
[0021] In the present application, after the first sub-thread receives the target window information, it sends the target window information to the second process only when the time interval between the moment of receiving the target window information and the moment of sending the window information last time is greater than the frame interval time of the display screen. In this way, the window information can be sent every other frame, thereby reducing the frequency of sending the window information, optimizing the load situation, and avoiding stability problems.
[0022] It should be noted that, when the first duration is greater than m-1 times the frame interval and less than or equal to m times the frame interval, the first sub-thread sends window information to the second process at least once every m-1 image frames. For example, when the first duration is greater than the frame interval and less than or equal to 2 times the frame interval, the first sub-thread sends window information to the second process at least once every one image frame.
[0023] Furthermore, if the first child thread does not receive the next window information within the first time period after receiving the target window information, the first child thread sends the target window information to the second process when the time interval is less than the first time period. In this case, since the first time period is greater than the frame interval, the first child thread sends the window information to the second process at least once every frame interval, thereby reducing the frequency of window information transmission, optimizing load conditions, and avoiding stability issues.
[0024] Optionally, after receiving the target window information, the first sub-thread may store the target window information in a task queue and wait for the first time period if the time interval between the time when the target window information is received and the time when the window information was last sent to the second process is less than a first time period. Thereafter, if the first sub-thread does not receive the next window information within the first time period after receiving the target window information, the first sub-thread sends the target window information in the task queue to the second process; if the first sub-thread receives the next window information within the first time period after receiving the target window information, the first sub-thread discards the target window information in the task queue and sends the next window information to the second process.
[0025] It is understandable that the window information in the task queue is the window information that the first child thread has received and has not yet sent to the second process. In this case, after the first child thread receives the target window information transmitted by the main thread, it can first determine whether the window information exists in the task queue. If the window information exists in the task queue, it indicates that the target window information is at least separated from the window information last sent to the second process by the window information existing in the task queue, that is, the time interval between the moment when the first child thread receives the target window information and the moment when the window information was last sent to the second process is at least greater than the frame time interval. Therefore, the first child thread can discard the window information in the task queue and send the target window information to the second process. If the window information does not exist in the task queue, the time interval between the moment when the target window information is received and the moment when the window information was last sent to the second process can be determined, and the target window information can be sent to the second process based on this time interval. In this way, the task queue can be used to quickly determine whether the target window information can be sent.
[0026] Optionally, if the main thread receives a first message, the target variable is set to the first variable value, and the first message is used to indicate the start of the startup and exit animations of the application; if the main thread receives a second message, the target variable is set to the second variable value, and the second message is used to indicate the end of the startup and exit animations.
[0027] In this case, after the first child thread receives the target window information passed by the main thread, if it is determined that the target variable is the second variable value, the target window information is sent to the second process; if it is determined that the target variable is the first variable value, the time interval between the time when the target window information is received and the time when the window information was last sent to the second process can be determined, and the target window information is sent to the second process according to the time interval.
[0028] In this application, a load reduction solution can be implemented by sending window information every other frame during the application startup and exit animation process. The startup and exit animation refers to the animation when the application starts or exits. Since it is highly unlikely that any window operation will occur when the application is in the startup and exit animation, sending window information every other frame in this scenario will not affect user operations.
[0029] Optionally, if the main thread receives the first message, the operation of setting the target variable to the first variable value may be: if the main thread receives the first message and determines that the refresh rate of the display screen is greater than or equal to the preset refresh rate, the target variable is set to the first variable value.
[0030] In this application, a load reduction solution of sending window information every other frame can be implemented when the application is in the startup and exit animation and the refresh rate of the display screen is greater than or equal to the preset refresh rate. The preset refresh rate can be set in advance, and the preset refresh rate can be set larger, for example, the preset refresh rate can be 90Hz, 120Hz, etc. Since the refresh rate of the display screen is greater than or equal to the preset refresh rate, that is, the refresh rate of the display screen is high, sending window information every other frame in this scenario will not cause lag.
[0031] Optionally, if the main thread does not receive the second message within a second time period after setting the target variable to the first variable value, the main thread sets the target variable to the second variable value.
[0032] If the main thread does not receive the second message within the second time period after setting the target variable to the first variable value, it means that the effective time of the load reduction plan has reached the second time period, that is, the effective time of the load reduction plan has been too long. In this case, the main thread has not received the second message, which means that some errors may have occurred. Therefore, in this case, the main thread can actively close the load reduction plan, that is, the main thread can set the target variable to the second variable value. Optionally, in this case, the main thread can also print logs so that technical personnel can confirm abnormal situations in time according to the logs.
[0033] Optionally, the operation of the first sub-thread sending the first target information to the second process may be: the first sub-thread sends the first target information to the second process through a binder driver.
[0034] Specifically, the first child thread can carry the first target information in a binder message and send it to the binder driver. After receiving the binder message, the binder driver can send the binder message to the binder thread in the binder thread pool of the second process for processing. Optionally, the binder thread can pass the first target information in the binder message to other threads in the second process for processing. For example, the first target information is the target window information, and the second process can be the SystemServer process. The SystemServer process includes the InputDispatcher thread. After the binder thread in the SystemServer process receives the binder message sent by the binder driver, it can pass the target window information in the binder message to the InputDispatcher thread. The InputDispatcher thread can distribute touch events according to the target window information.
[0035] In the second aspect, a method for sending information is provided. In this method, the main thread of the SurfaceFlinger process creates a third child thread, which can be called by the main thread through the updateInputFlinger function. The main thread runs the updateInputFlinger function to perform the following operations: obtaining the current window information, determining the target window information based on the current window information, and passing the target window information to the third child thread. The target window information is other window information in the current window information except for the window information containing the preset window type. After receiving the target window information passed by the main thread, the third child thread sends the target window information to the second process.
[0036] For example, the third sub-thread can be the first sub-thread or the second sub-thread described above. Alternatively, the third sub-thread can be called by the main thread through the ReleaseBuffer function, that is, the third sub-thread can serially execute the sending tasks of the updateInputFlinger function and the ReleaseBuffer function.
[0037] The preset window type can be pre-set, for example, by a technician based on relevant requirements. For example, the preset window type can be a window type that the user cannot directly operate on the screen, such as an invisible window type, a non-input channel window type, or one or more window types.
[0038] In this application, the target window information sent by the updateInputFlinger function to the second process is obtained by filtering the current window information. After filtering, the amount of window information that needs to be sent to the second process is greatly reduced, thereby optimizing the load situation and avoiding stability problems to a certain extent.
[0039] Optionally, when the main thread runs the updateInputFlinger function, after obtaining the target window information, it can directly call the third child thread based on the target window information to pass the target window information to the third child thread. Alternatively, when the main thread runs the updateInputFlinger function, after obtaining the target window information, it can call the third child thread based on the target window information when it determines that the window has changed based on the current window information, to pass the target window information to the third child thread. In other words, when the window changes, the third child thread can be called to send the target window information to the second process. In this way, the frequency of sending window information can be reduced, the load can be optimized, and stability issues can be avoided.
[0040] In a third aspect, an electronic device is provided, wherein the structure of the electronic device includes a processor and a memory, wherein the memory is used to store a program that supports the electronic device in executing the information transmission method provided in the first or second aspect, and to store data involved in implementing the information transmission method described in the first or second aspect. The processor is configured to execute the program stored in the memory. The electronic device may also include a communication bus, which is used to establish a connection between the processor and the memory.
[0041] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, which, when executed on a computer, enables the computer to execute the information sending method described in the first or second aspect above.
[0042] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the information sending method described in the first or second aspect above.
[0043] The technical effects obtained by the third, fourth and fifth aspects are similar to those obtained by the corresponding technical means in the first or second aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] FIG1 is a schematic diagram of a first thread state provided in an embodiment of the present application;
[0045] FIG2 is a schematic diagram of a second thread state provided in an embodiment of the present application;
[0046] FIG3 is a schematic diagram of a third thread state and a schematic diagram of log records provided in an embodiment of the present application;
[0047] FIG4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
[0048] FIG5 is a block diagram of a software system of an electronic device provided in an embodiment of the present application;
[0049] FIG6 is a flowchart of a first information sending method provided in an embodiment of the present application;
[0050] FIG7 is a flowchart of a second information sending method provided in an embodiment of the present application;
[0051] FIG8 is a schematic diagram of a fourth thread state provided in an embodiment of the present application;
[0052] FIG9 is a schematic diagram of sending window information provided by an embodiment of the present application;
[0053] FIG10 is a schematic diagram of a fifth thread state provided in an embodiment of the present application;
[0054] FIG11 is a flowchart of a third information sending method provided in an embodiment of the present application;
[0055] Figure 12 is a flowchart of the fourth information sending method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0057] It should be understood that the “multiple” mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; “and / or” in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, words such as “first” and “second” are used to distinguish between identical or similar items with basically the same functions and effects. Those skilled in the art can understand that words such as “first” and “second” do not limit the quantity and execution order, and words such as “first” and “second” do not necessarily limit them to be different.
[0058] The phrases "one embodiment" or "some embodiments" described in this application mean that the specific features, structures, or characteristics described in that embodiment are included in one or more embodiments of the application. Thus, the phrases "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" that appear in different places in this application do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. In addition, the terms "including," "comprising," "having," and their variations all mean "including but not limited to," unless otherwise specifically emphasized.
[0059] Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are first explained.
[0060] With the increasing popularity of various applications, windows of multiple applications can be displayed on screens of electronic devices such as mobile phones and tablet computers, bringing users a good visual and operating experience.
[0061] At present, some threads running in electronic devices need to obtain the current window information of the electronic device in order to implement relevant processing accordingly. For example, the processing of touch events (i.e., touch events) of electronic devices mainly involves the InputReander thread and the InputDispatcher thread running in the electronic device, wherein the touch events include but are not limited to click events, sliding events, etc. After the user touches the screen of the electronic device, the InputReander thread can read the touch event, and then notify the InputDispatcher thread to distribute the touch event. When distributing the touch event, the InputDispatcher thread can first determine the window corresponding to the touch event based on the window information and the position of the touch event, and then distribute the touch event to the corresponding window. It can be seen that in the process of handling touch events, it is very important for the InputDispatcher thread to obtain window information.
[0062] In the related technology, a SurfaceFlinger process runs in the electronic device, and an updateInputFlinger function runs in the SurfaceFlinger process. The updateInputFlinger function is used to obtain the current window information of the electronic device and synchronize the window information to the InputDispatcher thread. The InputDispatcher thread runs in the SystemServer (system service) process. Among them, the SurfaceFlinger process can complete the synchronization of window information through asynchronous binder communication. Specifically, by running the updateInputFlinger function, the SurfaceFlinger process can send the binder message carrying window information to the binder thread in the binder thread pool of the SystemServer process through the binder driver. The binder thread will pass the window information to the InputDispatcher thread.
[0063] For example, in the thread state diagram shown in Figure 1, the updateInputFlinger function is running in the surfaceflinger thread in the SurfaceFlinger process. By running the updateInputFlinger function, the surfaceflinger thread can send the binder message carrying window information to the binder thread in the SystemServer process through the binder driver. The binder thread will pass the window information to the InputDispatcher thread.
[0064] However, this approach has the following two problems:
[0065] On the one hand, in addition to the updateInputFlinger function, other functions are also running in the SurfaceFlinger process, including but not limited to the ReleaseBuffer function. The main function of the ReleaseBuffer function is to release the used buffer space (i.e., buffer) for next use. All functions running in the SurfaceFlinger process will call the same child thread to perform the sending task. For example, the SurfaceFlinger process can call the child thread to send the window information to the InputDispatcher thread after getting the window information by running the updateInputFlinger function, and the SurfaceFlinger process can also call the child thread to send information by running the ReleaseBuffer function. In this case, if the updateInputFlinger function falls into an abnormal state, it will affect the operation of the ReleaseBuffer function, causing performance problems.
[0066] For example, in the thread state diagram shown in Figure 2, the SurfaceFlinger process calls the child thread "surfaceflinger2773" to perform the send task when running the updateInputFlinger function and the ReleaseBuffer function. The child thread "surfaceflinger2773" executes the send task of the updateInputFlinger function and the send task of the ReleaseBuffer function serially. In this case, if the child thread "surfaceflinger2773" encounters an abnormal state during the execution of the send task of the updateInputFlinger function, such as the Uninterruptible sleep (D) state, the execution time of the send task of the updateInputFlinger function will be longer, which will cause the send task of the ReleaseBuffer function to be delayed and unable to execute for a long time. This will affect the release of the buffer, resulting in buffer accumulation. Other threads will be unable to obtain the buffer for a long time, which will cause performance problems.
[0067] On the other hand, when synchronizing window information, the updateInputFlinger function synchronizes all current window information of the electronic device, including the window information of visible windows and invisible windows. This will result in a large amount of data for the window information synchronized at a time, which in turn results in a large amount of data for a single binder message, leading to stability issues. For example, when the updateInputFlinger function needs to synchronize window information to the InputDispatcher thread, once a certain updateInputFlinger function runs for a long time, it will cause a pile-up of binder messages. Since the size of the binder thread pool of the SystemServer process is limited, and the SystemServer process itself also requires a lot of communication, if the data volume of a single binder message is large, when a large number of accumulated binder messages flow into the binder thread pool of the SystemServer process in a short period of time, the binder thread pool of the SystemServer process will be filled up or even directly stuck, causing stability issues.
[0068] For example, in the thread state diagram shown in Figure 3 (a), the binder thread pool of the SystemServer process includes binder thread "binder2798" and binder thread "binder3802." The SurfaceFlinger process calls the child thread "surfaceflinger2773" to perform the sending task by running the updateInputFlinger function. The child thread "surfaceflinger2773" can send the binder message carrying window information to the binder thread in the SystemServer process through the binder driver for processing. In this case, if the processing time of a particular binder message is long, the binder driver will receive a backlog of binder messages. For example, as shown in Figure 3 (a), the child thread "surfaceflinger2773" sends binder message A to the binder driver. The binder driver then sends binder message A to the binder thread "binder3802" for processing. During the processing of binder message A, the child thread "surfaceflinger2773" sends binder message B to the binder driver. After processing binder message A, the binder driver can continue to send binder message B to the binder thread "binder3802" for processing. However, the processing time of binder message B is long, and during the processing of binder message B, the child thread "surfaceflinger2773" sends a large number of binder messages to the binder driver, causing binder message backlog. After processing binder message B, the binder driver sends the accumulated binder messages to the binder thread "binder2798" for processing. Because a single binder message carries a large amount of data, a large number of accumulated binder messages quickly flooding the binder thread "binder2798" can fill up the SystemServer process's binder thread pool or even cause a crash, leading to stability issues. As shown in the log record in Figure 3 (b), when a large number of accumulated binder messages quickly flood the SystemServer process's binder thread pool, binder communication between the child thread "surfaceflinger2773" in the SurfaceFlinger process "surfaceflinger2849" and the SystemServer process "systemserver2793" fails, causing stability issues.
[0069] To this end, an embodiment of the present application provides a method for sending information. On the one hand, the sending task of the updateInputFlinger function or the sending task of the ReleaseBuffer function is split into separate sub-threads to prevent the abnormal state of the updateInputFlinger function from affecting the operation of the ReleaseBuffer function and causing performance problems. On the other hand, the method adopts the method of reducing the data volume of the window information sent in a single time and / or reducing the sending frequency of the window information to optimize the load and avoid stability problems.
[0070] The information transmission method provided in the embodiments of the present application can be executed by an electronic device. Various applications can be installed in the electronic device, and the electronic device can display windows of various applications. For example, the electronic device can be a mobile phone, a palmtop computer, a tablet computer, a laptop computer, an in-vehicle device, an ultra-mobile personal computer (UMPC), a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, etc., and the embodiments of the present application are not limited to this.
[0071] FIG4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Referring to FIG4 , 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, an earphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, an air 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.
[0072] It should be understood that the structures illustrated in the embodiments of the present application do 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 shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0073] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0074] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0075] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0076] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0077] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0078] The USB interface 130 is an interface that complies with USB standards and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100 and to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. The USB interface 130 can also be used to connect other devices, such as augmented reality devices.
[0079] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device 100 via the power management module 141.
[0080] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0081] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0082] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0083] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0084] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0085] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0086] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is an integer greater than one.
[0087] The touch sensor 180K is also called a "touch panel." The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen." The touch sensor 180K is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor 180K can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operations can be provided via the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, at a location different from that of the display screen 194.
[0088] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
[0089] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and transformed into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.
[0090] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is an integer greater than 1.
[0091] The electronic device 100 can implement audio functions, such as music playback and recording, through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D and the application processor.
[0092] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.
[0093] The keys 190 include a power button, a volume button, etc. The keys 190 may be mechanical keys or touch keys. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0094] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. Touch operations on different areas of the display screen 194 can also correspond to different vibration feedback effects. Different application scenarios (such as: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0095] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power level changes, messages, missed calls, notifications, etc.
[0096] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is an integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0097] Next, the software system of the electronic device 100 will be described.
[0098] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the present application, the software system of the electronic device 100 is exemplarily described by taking the Android system of the layered architecture as an example.
[0099] Figure 5 is a block diagram of a software system for an electronic device 100 provided in an embodiment of the present application. Referring to Figure 5 , the layered architecture divides the software into several layers, each with distinct roles and divisions of labor. Layers communicate with each other via software interfaces. In some embodiments, the Android system is divided into an application layer, an application framework layer, an Android runtime (Android Runtime), a system layer, and a kernel layer.
[0100] The application layer can include a series of application packages. As shown in Figure 5, the application package can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0101] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0102] As shown in Figure 5, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like. The window manager is used to manage window programs. It can obtain the display size, determine whether a status bar is present, lock the screen, and take screenshots. The content provider is used to store and retrieve data and make it accessible to applications. This data may include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and the phone book. The view system includes visual controls, such as those for displaying text and images. The view system is used to construct the application's display interface, which may consist of one or more views, such as a view that displays a text message notification icon, a view that displays text, and a view that displays images. The telephony manager is used to provide communication functions for electronic device 100, such as managing call status (including connected and disconnected calls). The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, and video files. The notification manager enables applications to display notifications in the status bar. These notifications can be used to convey informational messages and can be displayed for a short period of time, disappearing automatically without user interaction. For example, a notification manager is used to notify users of completed downloads, message alerts, and more. A notification manager can also appear as an icon or scrolling text bar in the system's top status bar, such as notifications from background applications. A notification manager can also appear as a dialog window on the screen, such as a text message in the status bar, a beep, a vibration on an electronic device, or a flashing indicator light.
[0103] As shown in FIG5 , the application framework layer may further run a first process and a second process, and the first process and the second process may perform asynchronous binder communication.
[0104] In some embodiments, the first process may obtain window information and send the window information to the second process through asynchronous binder communication, so that the second process can perform relevant processing accordingly.
[0105] For example, the first process may be the SurfaceFlinger process. The second process may be the SystemServer process. The SurfaceFlinger process may receive graphics data from multiple sources and synthesize these graphics data and send them to the display screen for rendering. The SystemServer process may create and run the core services of the system. The SurfaceFlinger process and the SystemServer process may perform asynchronous binder communication. Specifically, the updateInputFlinger function runs in the SurfaceFlinger process, and the InputDispatcher thread exists in the SystemServer process. By running the updateInputFlinger function, the SurfaceFlinger process may obtain window information and send the window information to the InputDispatcher thread in the SystemServer process through asynchronous binder communication, so that the InputDispatcher thread can distribute touch events based on the window information.
[0106] In other embodiments, the first process may send buffer space release information to the second process through asynchronous binder communication to instruct the second process to release the buffer space.
[0107] For example, the first process may be the SurfaceFlinger process. The second process may be the process to which the RenderThread thread belongs. The RenderThread thread is used to draw image frames. The SurfaceFlinger process and the process to which the RenderThread thread belongs can perform asynchronous binder communication. Specifically, the SurfaceFlinger process runs a ReleaseBuffer function. By running the ReleaseBuffer function, the SurfaceFlinger process can send buffer space release information to the RenderThread thread via asynchronous binder communication, instructing the RenderThread thread to release the buffer space.
[0108] The Android Runtime consists of core libraries and a virtual machine (VM). The Android Runtime is responsible for scheduling and management of the Android system. The core libraries consist of two parts: one containing the Java language's callable functions and the other the Android core library. The application layer and the application framework layer run in the VM. The VM executes the Java files in the application layer and application framework layer as binary files. The VM is responsible for performing functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0109] The system layer can include multiple functional modules, such as: surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.
[0110] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, binder drivers, etc.
[0111] The first process and the second process in the application framework layer can implement asynchronous binder communication through a binder driver. Specifically, the second process can have a binder thread pool. The first process can carry the above-mentioned window information or buffer space release information in a binder message and send it to the binder driver. The binder driver can send the binder message to a binder thread in the binder thread pool of the second process for processing.
[0112] For example, the first process can be the SurfaceFlinger process. The second process can be the SystemServer process. The updateInputFlinger function runs in the SurfaceFlinger process, and the InputDispatcher thread exists in the SystemServer process. By running the updateInputFlinger function, the SurfaceFlinger process can obtain window information and send it in a binder message to the binder driver. The binder driver can send the binder message to a binder thread in the binder thread pool of the SystemServer process. The binder thread can pass the window information to the InputDispatcher thread, which then distributes touch events based on the window information.
[0113] For another example, the first process may be the SurfaceFlinger process. The second process may be the process to which the RenderThread thread belongs. The SurfaceFlinger process runs a ReleaseBuffer function. By running the ReleaseBuffer function, the SurfaceFlinger process can send buffer space release information in a binder message to the binder driver. The binder driver can then send the binder message to a binder thread in the binder thread pool of the process to which the RenderThread thread belongs. The binder thread can then pass the buffer space release information to the RenderThread thread. After receiving the buffer space release information, the RenderThread thread can release the buffer space.
[0114] The information sending method provided in the embodiment of the present application is described below.
[0115] FIG6 is a flow chart of a method for sending information provided by an embodiment of the present application, which is applied to an electronic device. Referring to FIG6 , the method includes the following steps:
[0116] Step 601: The main thread of the first process creates a first sub-thread and a second sub-thread.
[0117] The first process is a process capable of obtaining window information. The window information may include window information of some or all windows displayed by the electronic device, such as window information of visible windows and window information of invisible windows. The window information may include information such as window position, window size, and window type, which is not limited in the embodiments of the present application.
[0118] For example, the first process may be a SurfaceFlinger process. Of course, the first process may also be other processes that can obtain window information. This embodiment of the present application does not make a sole limitation to this.
[0119] After the electronic device creates the first process, the main thread of the first process starts running. The main thread can create a first sub-thread and a second sub-thread during the running process.
[0120] The first child thread can be called by the main thread through the first function, but cannot be called by the main thread through any other function except the first function. In this case, the first child thread is used to independently execute the sending task of the first function. The main thread can call the first child thread to execute the sending task only when running the first function, and cannot call the first child thread when running other functions.
[0121] The second sub-thread can be called by the main thread through a second function other than the first function. In this case, the second sub-thread is used to execute the sending task of the second function. When the main thread runs the second function, it can call the second sub-thread to execute the sending task. Optionally, the second sub-thread cannot be called by the main thread through other functions other than the second function. In this case, the second sub-thread is used to execute the sending task of the second function alone; or the second sub-thread can be called by the main thread through other functions other than the first and second functions. In this case, the second sub-thread executes the sending task of each of the multiple functions serially.
[0122] In an embodiment of the present application, the main thread is capable of running at least a first function and a second function, one of the first function and the second function is used to send window information to the second process, and the other is used to instruct the second process to release buffer space. The second process is a process other than the first process. The second processes corresponding to the first function and the second function may be the same or different. For example, the first function may be an updateInputFlinger function, and the second function may be a ReleaseBuffer function. In this case, the second process corresponding to the first function is a process that requires window information, and the second process corresponding to the second function is a process that requires buffer space to be released; or, the first function may be a ReleaseBuffer function, and the second function may be an updateInputFlinger function. In this case, the second process corresponding to the first function is a process that requires buffer space to be released, and the second process corresponding to the second function is a process that requires window information.
[0123] In an embodiment of the present application, the main thread can call the first sub-thread to execute the sending task by running the first function, and the main thread can call the second sub-thread to execute the sending task by running the second function. The operation of the first sub-thread and the second sub-thread do not affect each other, so an abnormal state of one of the first function and the second function will not affect the operation of the other function, thereby avoiding performance issues caused by the abnormal state of the first function or the second function.
[0124] Step 602: The main thread runs a first function to pass first target information to the first child thread.
[0125] When the main thread runs the first function, it can call the first child thread based on the first target information to pass the first target information to the first child thread. The first target information is the information that the first function needs to send to the second process. For example, if the first function is used to send window information to the second process, the first target information is the target window information. Alternatively, if the first function is used to instruct the second process to release buffer space, the first target information is the buffer space release information.
[0126] Step 603: After receiving the first target information transmitted by the main thread, the first sub-thread sends the first target information to the second process.
[0127] After receiving the first target information transmitted by the main thread, the first sub-thread may execute the sending task of the first function to send the first target information to the second process.
[0128] In some embodiments, the first child thread may send the first target information to the second process via a binder driver. Specifically, the first child thread may carry the first target information in a binder message and send it to the binder driver. After receiving the binder message, the binder driver may send the binder message to a binder thread in the binder thread pool of the second process for processing. In some embodiments, the binder thread may pass the first target information in the binder message to other threads in the second process for processing.
[0129] Optionally, the main thread runs a second function to pass the second target information to the second child thread. When the main thread runs the second function, it can call the second child thread based on the second target information to pass the second target information to the second child thread. The second target information is information that the second function needs to send to the second process. For example, if the second function is used to send window information to the second process, the second target information is target window information. Alternatively, if the second function is used to instruct the second process to release buffer space, the second target information is buffer space release information.
[0130] After receiving the second target information transmitted by the main thread, the second sub-thread sends the second target information to the second process. That is, after receiving the second target information transmitted by the main thread, the second sub-thread can execute the sending task of the second function to send the second target information to the second process.
[0131] In some embodiments, the second child thread may send the second target information to the second process via a binder driver. Specifically, the second child thread may carry the second target information in a binder message and send it to the binder driver. After receiving the binder message, the binder driver may send the binder message to a binder thread in the binder thread pool of the second process for processing. In some embodiments, the binder thread may pass the second target information in the binder message to other threads in the second process for processing.
[0132] In an embodiment of the present application, the main thread of the first process can run the first function and the second function, one of the first function and the second function is used to send window information to the second process, and the other is used to instruct the second process to release buffer space. The main thread can create a first sub-thread and a second sub-thread, the first sub-thread is used to independently execute the sending task of the first function, and the second sub-thread is used to execute the sending task of the second function. The operation of the first sub-thread and the second sub-thread does not affect each other, so the abnormal state of one function of the first function and the second function will not affect the operation of the other function, thereby avoiding performance problems caused by the abnormal state of the first function or the second function.
[0133] The following takes the first function as a function for sending window information to the second process and the first target information as target window information as an example to exemplarily illustrate the above information sending method.
[0134] This information sending method is applied to a scenario in which a first process in an electronic device sends window information to a second process. It should be noted that the display screen of the electronic device continuously refreshes the screen image during display. The refresh rate of the display screen refers to the number of times the screen image is refreshed per second. The screen image displayed by the display screen each time can be called an image frame. Each time the first process obtains the graphic data of an image frame, the graphic data can be sent to the display screen for rendering, thereby completing the display of the image frame. In addition, each time the first process obtains the graphic data of an image frame, it can also obtain corresponding window information based on the graphic data and send the window information to the second process. Optionally, the first process can use asynchronous binder communication when sending the window information to the second process. Specifically, the first process can send a binder message carrying the window information to the binder driver, and the binder driver can send the binder message to the binder thread in the binder thread pool of the second process.
[0135] FIG7 is a flow chart of a method for sending information provided by an embodiment of the present application, which is applied to an electronic device. Referring to FIG7 , the method includes the following steps:
[0136] Step 701: The main thread of the first process creates a first child thread. The first child thread can be called by the main thread through a first function, but cannot be called by the main thread through any function other than the first function.
[0137] The first process is a process capable of obtaining window information. The window information may include window information of some or all windows displayed by the electronic device, such as window information of visible windows and window information of invisible windows. The window information may include information such as window position, window size, and window type, which is not limited in the embodiments of the present application.
[0138] For example, the first process may be a SurfaceFlinger process. Of course, the first process may also be other processes that can obtain window information. This embodiment of the present application does not make a sole limitation to this.
[0139] After the electronic device creates a first process, the main thread of the first process begins running. During this process, the main thread may create a first child thread. The first child thread is used to independently execute the sending task of the first function. That is, the main thread can only execute the sending task by calling the first child thread through the first function and cannot call the first child thread through other functions.
[0140] The first function is used to send window information to the second process. That is, when the main thread runs the first function, it can obtain window information and call the first child thread to send the window information to the second process. For example, the first function can be the updateInputFlinger function. Of course, the first function can also be other functions that can send window information. This embodiment of the present application is not limited to this.
[0141] In this embodiment of the present application, the main thread of the first process creates a first child thread that is solely used to execute the send task of the first function. This splits the send task of the first function from the main thread into a separate child thread. In this case, an abnormal state of the first function will not affect the execution of other functions in the main thread, thereby avoiding performance issues caused by the abnormal state of the first function.
[0142] Furthermore, the main thread can also create a second child thread. The second child thread can be called by the main thread through a second function. That is, the second child thread can execute the sending task of the second function. The second function is different from the first function. For example, the second function can be a ReleaseBuffer function. Of course, the second function can also be other functions in the main thread besides the first function. This embodiment of the application does not limit this to a single function.
[0143] Optionally, the main thread can only call the second sub-thread through the second function. In this case, the second sub-thread independently executes the sending task of the second function. Alternatively, the main thread can not only call the second sub-thread through the second function, but also call the second sub-thread through at least one other function other than the first function and the second function. In this case, the second sub-thread serially executes the sending task of each of the multiple functions.
[0144] For example, the first process is the SurfaceFlinger process, the first function is the updateInputFlinger function, and the second function is the ReleaseBuffer function. In the thread state diagram shown in Figure 8, the SurfaceFlinger process has a main thread "surfaceflinger1653". The main thread "surfaceflinger1653" creates a first sub-thread "surfaceflinger2688" and a second sub-thread "surfaceflinger2689" during operation. Among them, the first sub-thread is used to execute the sending task of the updateInputFlinger function alone, and the second sub-thread is used to execute the sending task of the ReleaseBuffer function. The operation of the first sub-thread and the second sub-thread does not affect each other. In this case, even if the first sub-thread "surfaceflinger2688" encounters an abnormal state when executing the sending task of the updateInputFlinger function, it will not affect the execution of the sending task of the ReleaseBuffer function by the second sub-thread "surfaceflinger2689", thereby avoiding performance problems.
[0145] Step 702: The main thread runs a first function to pass target window information to the first child thread.
[0146] When the main thread runs the first function, it can obtain target window information and call the first sub-thread according to the target window information to pass the target window information to the first sub-thread.
[0147] The target window information may be window information of part or all of the windows displayed by the electronic device. The target window information is window information that the first function needs to send to the second process.
[0148] In some embodiments, the main thread can obtain current window information when running the first function. For example, when the main thread obtains the graphic data of the current image frame to be rendered, it can obtain the window information of all windows contained in the current image frame as the current window information based on the graphic data by running the first function. Optionally, when the main thread runs the first function, it can also determine whether the window displayed by the electronic device has changed based on the current window information. Specifically, when the current window information is different from the historical window information (i.e., the window information of all windows contained in the previous image frame), it can be determined that the window displayed by the electronic device has changed. When the current window information is the same as the historical window information, it can be determined that the window displayed by the electronic device has not changed.
[0149] Optionally, when the main thread runs the first function, the current window information can be directly determined as the target window information; or, the target window information can be determined based on the current window information, and the target window information is other window information in the current window information except for the window information containing the preset window type, that is, the current window information can be filtered, and the other window information in the current window information except for the window information containing the preset window type can be determined as the target window information.
[0150] The preset window type can be pre-set, for example, by a technician according to relevant requirements. For example, the preset window type can be a window type that a user cannot directly operate on the screen, such as a preset window type that includes one or more window types such as a not visible window type (NOT_VISIBLE) and a non-input channel window type (NO_INPUT_CHANNEL).
[0151] In the embodiment of the present application, the target window information sent by the first function to the second process is obtained by filtering the current window information. After filtering, the amount of window information that needs to be sent to the second process is greatly reduced, and the amount of binder messages carrying window information that need to be sent to the second process subsequently is also reduced, thereby optimizing the load situation and avoiding stability problems to a certain extent.
[0152] For example, as shown in Table 1 below, the amount of data required to send the current window information in the related art is greater than or equal to the amount of data required to send the target window information in the embodiments of the present application. Furthermore, as the number of open applications increases, compared to the related art, the embodiment of the present application can significantly reduce the amount of data required to send the target window information by filtering the current window information, thereby avoiding stability issues to a certain extent.
[0153] Table 1
[0154] It should be noted that the embodiment of the present application only uses Table 1 above as an example to illustrate the data volume of the window information, and Table 1 above does not constitute a limitation on the embodiment of the present application.
[0155] For example, the first process is the SurfaceFlinger process, the first function is the updateInputFlinger function, and the second process is the SystemServer process. Even if the updateInputFlinger function takes a long time to run, resulting in the accumulation of binder messages, since the data volume of the binder messages in the embodiment of the present application is small, the total data volume of the accumulated binder messages is also small. In this case, when the accumulated binder messages flow into the binder thread pool of the SystemServer process in a short period of time, the binder thread pool of the SystemServer process will not be filled up, and no stability problems will be caused.
[0156] When the main thread runs the first function, it can call the first child thread according to the target window information after obtaining the target window information to pass the target window information to the first child thread, so that the first child thread can send the target window information to the second process.
[0157] In some embodiments, when the main thread executes the first function, it may directly call the first child thread based on the target window information after obtaining the target window information. Alternatively, when the main thread executes the first function, it may, after obtaining the target window information, call the first child thread based on the target window information when determining that the window has changed based on the current window information. In other words, the first child thread may be called to send the target window information to the second process when the window changes. This reduces the frequency of window information transmission, optimizes load conditions, and avoids stability issues.
[0158] Step 703: After receiving the target window information transmitted by the main thread, the first sub-thread sends the target window information to the second process.
[0159] After receiving the target window information transmitted by the main thread, the first sub-thread can execute the sending task of the first function to send the target window information to the second process.
[0160] The second process is a process that needs to perform relevant processing based on the window information. For example, the second process can be a SystemServer process, which includes an InputDispatcher thread that can distribute touch events based on the window information. Of course, the second process can also be other processes that need to perform relevant processing based on the window information, and this embodiment of the application is not limited to this.
[0161] In some embodiments, the first child thread can send target window information to the second process through the binder driver. Specifically, the first child thread can carry the target window information in a binder message and send it to the binder driver. After the binder driver receives the binder message, it can send the binder message to the binder thread in the binder thread pool of the second process for processing. In some embodiments, the binder thread can pass the target window information in the binder message to other threads in the second process for processing. For example, the second process can be a SystemServer process. The SystemServer process includes an InputDispatcher thread. After the binder thread in the SystemServer process receives the binder message sent by the binder driver, it can pass the target window information in the binder message to the InputDispatcher thread. The InputDispatcher thread can distribute touch events based on the target window information.
[0162] Optionally, the operation of step 703 may include the following steps (1) to (3):
[0163] (1) After receiving the target window information transmitted by the main thread, the first sub-thread determines the time interval between the time when the target window information is received and the time when the window information was last sent to the second process.
[0164] Each time the first child thread sends window information to the second process, the sending time can be recorded. In this way, after receiving the target window information, the first child thread can determine the time interval between the time when the target window information is received and the recorded sending time (i.e., the time when the window information was last sent to the second process).
[0165] Afterwards, the first child thread may send the target window information to the second process according to the time interval. Specifically, the first child thread may execute the following step (2) if the time interval is greater than or equal to the first duration; and may execute the following step (3) if the time interval is less than the first duration.
[0166] (2) The first child thread sends the target window information to the second process when the time interval is greater than or equal to the first duration.
[0167] The first duration can be pre-set, for example, based on the frame interval of the electronic device's display screen. For example, the first duration can be greater than the frame interval of the display screen. Furthermore, the first duration can be less than or equal to m times the frame interval, where m is greater than 1, such as 2, 3, or the like. For example, the first duration can be greater than the frame interval of the display screen and less than or equal to 2 times the frame interval. In this case, if the refresh rate of the electronic device's display screen is 90 Hz, the frame interval of the display screen is 1000 ÷ 90 ≈ 11.1 ms. The first duration can be greater than 11.1 ms and less than or equal to 22.2 ms, such as 16 ms. Alternatively, if the refresh rate of the electronic device's display screen is 120 Hz, the frame interval of the display screen is 1000 ÷ 120 ≈ 8.3 ms. The first duration can be greater than 8.3 ms and less than or equal to 16.6 ms, such as 16 ms.
[0168] In an embodiment of the present application, after the first sub-thread receives the target window information, it sends the target window information to the second process only if the time interval between the moment of receiving the target window information and the moment of last sending the window information is greater than the frame interval time of the display screen. In this way, the window information can be sent every other frame, thereby reducing the frequency of sending the window information, optimizing the load situation, and avoiding stability problems.
[0169] It should be noted that, when the first duration is greater than m-1 times the frame time interval and less than or equal to m times the frame time interval, the first sub-thread sends window information to the second process at least once every m-1 image frames. For example, when the first duration is greater than the frame interval and less than or equal to 2 times the frame interval, the first sub-thread sends window information to the second process at least once every one image frame. Assume that there are three consecutive image frames: image frame 1, image frame 2, and image frame 3. After the first sub-thread sends the target window information of image frame 1 to the second process, if the first sub-thread receives the target window information of image frame 2, it will not send the target window information of image frame 2 to the second process, but will send the target window information of image frame 3 to the second process when it receives the target window information of image frame 3. In this way, the intermittent sending of window information to the second process is achieved.
[0170] (3) When the time interval is less than the first duration, the first sub-thread waits for the target window information for the first duration.
[0171] If the first child thread does not receive the next window message while waiting for the first time period for the target window message, that is, if the first child thread does not receive the next window message within the first time period after receiving the target window message, the first child thread can send the target window message to the second process. In this case, because the first time period is greater than the frame interval, the first child thread sends the window message to the second process at least once every frame interval, thereby reducing the frequency of window message sending, optimizing load conditions, and avoiding stability issues.
[0172] If the first sub-thread receives the next window information while waiting for the target window information for the first time duration, then since the time interval between two adjacent image frames is the frame time interval, the time interval between the time when the first sub-thread receives the next window information and the time when the last window information was sent to the second process will be greater than the frame time interval, that is, greater than the first time duration, and thus the first sub-thread can send the next window information to the second process. In other words, if the first sub-thread receives the next window information while waiting for the target window information for the first time duration, the first sub-thread can directly send the next window information to the second process.
[0173] For example, as shown in Figure 9, assume that the first duration is 16ms. After the first child thread receives the target window information, if it determines that the time interval between the moment the target window information is received and the moment the window information was last sent to the second process is less than 16ms, the first child thread will wait for the target window information for 16ms. Thereafter, as shown in Figure (a) of Figure 9, if the first child thread receives the next window information during the waiting process for the target window information, the waiting for the target window information will be interrupted. In this case, the first child thread discards the target window information and sends the next window information to the second process. Alternatively, as shown in Figure (b) of Figure 9, if the first child thread has not received the next window information during the waiting process for the target window information, the first child thread can automatically send the target window information to the second process after the waiting timeout.
[0174] Optionally, after receiving the target window information transmitted by the main thread, the first sub-thread may store the target window information in a task queue and wait for the first time period if the time interval between the time of receiving the target window information and the time of last sending window information to the second process is less than a first time period. Thereafter, if the first sub-thread does not receive the next window information within the first time period after receiving the target window information, the first sub-thread sends the target window information in the task queue to the second process; if the first sub-thread receives the next window information within the first time period after receiving the target window information, the first sub-thread discards the target window information in the task queue and sends the next window information to the second process.
[0175] It is understandable that the window information in the task queue is the window information that the first child thread has received and has not yet sent to the second process. In this case, after the first child thread receives the target window information transmitted by the main thread in the above step (1), it can first determine whether there is window information in the task queue. If there is window information in the task queue, it indicates that the target window information is at least separated from the window information last sent to the second process by the window information existing in the task queue, that is, it indicates that the time interval between the moment when the first child thread receives the target window information and the moment when the window information was last sent to the second process is at least greater than the frame time interval. Therefore, the first child thread can discard the window information in the task queue and directly send the target window information to the second process. If there is no window information in the task queue, the first child thread can perform the operation of determining the time interval between the moment when the target window information is received and the moment when the window information was last sent to the second process in step (1) and the subsequent steps (2) and (3). In this way, the task queue can be used to quickly determine whether the target window information can be sent.
[0176] It should be noted that the embodiment of the present application can achieve the sending of window information to the second process every other frame through the above steps (1) to (3). In this case, even if the running time of the first function is relatively long, it will not lead to excessive accumulation of binder messages. Therefore, when a small amount of accumulated binder messages flows into the binder thread pool of the second process in a short period of time, the binder thread pool of the second process will not be filled up, and no stability problem will be caused.
[0177] The embodiment of the present application implements a load reduction scheme for the first child thread when sending window information through the above steps (1) to (3). In some embodiments, the load reduction scheme can be implemented in all scenarios, that is, the first child thread can execute the above steps (1) to (3) every time it receives a window information transmitted by the main thread. In other embodiments, the load reduction scheme can be implemented only in some scenarios, and in other scenarios, the received window information is directly sent to the second process.
[0178] Optionally, this load reduction solution can be implemented while the application is experiencing startup and exit animations, which are the animations that occur when the application starts or exits. Since window operations are unlikely to occur during the startup and exit animations, sending window information every other frame in this scenario will not affect user operations.
[0179] Alternatively, the load reduction solution can be implemented when the application is in the startup and exit animation and the refresh rate of the display screen is greater than or equal to the preset refresh rate. The preset refresh rate can be set in advance, and the preset refresh rate can be set larger. For example, the preset refresh rate can be 90Hz, 120Hz, etc., which is not limited in the embodiment of the present application. Since the refresh rate of the display screen is greater than or equal to the preset refresh rate, that is, the refresh rate of the display screen is high, sending window information every other frame in this scenario will not cause lag.
[0180] Next, the process of implementing the load reduction solution in the above two scenarios is described in detail, which may specifically include the following steps A to B:
[0181] Step A: If the main thread receives the first message, it sets the target variable to the first variable value.
[0182] The first message is used to indicate the start of the application's startup and exit animations. For example, the first message can be a binder message. Optionally, the electronic device can include a target module that can detect whether the application is in the startup animation or exit animation. If the target module detects that the application is in the start phase of the startup animation or exit animation, it can send the first message to the main thread to indicate the start of the application's startup and exit animations.
[0183] After receiving the first message, the main thread can set the target variable to the first variable value. The target variable is used to indicate whether to use the load reduction solution. When the target variable is the first variable value, it indicates that the load reduction solution is used. When the target variable is the second variable value, it indicates that the load reduction solution is not used. The first variable value and the second variable value are different. For example, the first variable value can be true, and the second variable value can be false.
[0184] In some embodiments, after receiving the first message, the main thread may directly set the target variable to the first variable value. In other embodiments, after receiving the first message, the main thread may first determine whether the refresh rate of the display screen is greater than or equal to a preset refresh rate. If the refresh rate of the display screen is greater than or equal to the preset refresh rate, the target variable is set to the first variable value. If the refresh rate of the display screen is less than the preset refresh rate, the target variable value is not changed, that is, the target variable is maintained at the second variable value.
[0185] Optionally, if the target module detects that the application has ended its startup or exit animation, it can send a second message to the main thread, indicating that the application's startup or exit animation has ended. For example, the second message can be a binder message. After receiving the second message, the main thread can directly set the target variable to the second variable value.
[0186] In some embodiments, if the main thread does not receive the second message within a second period of time after setting the target variable to the first variable value, the main thread may set the target variable to the second variable value.
[0187] The second duration can be set in advance, and the second duration can be set to be larger, such as 2 seconds, 3 seconds, etc. Optionally, the second duration can be greater than the maximum duration of the start-up exit animation.
[0188] The main thread sets the target variable to the first variable value, indicating that the load reduction scheme has been started. In this case, the main thread can record the effective time of the load reduction scheme, that is, record how long it has been since the target variable was set to the first variable value. If the main thread does not receive the second message within the second time period after setting the target variable to the first variable value, it means that the effective time of the load reduction scheme has reached the second time period, that is, the effective time of the load reduction scheme has exceeded the maximum duration of the start-up exit animation. In this case, the main thread has not received the second message, which means that some errors may have occurred. Therefore, in this case, the main thread can actively close the load reduction scheme, that is, the main thread can set the target variable to the second variable value. Optionally, in this case, the main thread can also print a log so that technical personnel can confirm the abnormal situation in time according to the log.
[0189] Step B: After the first sub-thread receives the target window information transmitted by the main thread, if it is determined that the target variable is the first variable value, the load reduction solution provided by the above steps (1) to (3) is executed.
[0190] If it is determined that the target variable is the second variable value, it means that the load reduction solution cannot be used currently, and the first child thread can directly send the target window information to the second process.
[0191] For example, the first process is the SurfaceFlinger process, the first function is the updateInputFlinger function, and the second function is the ReleaseBuffer function. In the thread state diagram shown in Figure 10, the SurfaceFlinger process has a first child thread "surfaceflinger2688", which is used to execute the sending task of the updateInputFlinger function alone. As shown in Figure 10 (a), when the application is not in the process of starting the exit animation, the first child thread can send the window information of each image frame to the second process. As shown in Figure 10 (b), when the application is in the process of starting the exit animation, the first child thread can use this load reduction solution to send window information to the second process every other frame.
[0192] It should be noted that in the embodiment of the present application, the window information that needs to be sent to the second process can be obtained by filtering the current window information, and / or, a load reduction scheme can be used to send window information to the second process every other frame. In this way, the amount of window information that needs to be sent at a single time is reduced and / or the frequency of sending window information is reduced, which also reduces the amount of data of a single binder message and / or reduces the frequency of sending binder messages, thereby optimizing the load situation and avoiding stability problems.
[0193] In an embodiment of the present application, the main thread of a first process creates a first child thread. The main thread then runs a first function to obtain target window information and calls the first child thread based on the target window information. After receiving the target window information from the main thread, the first child thread sends the target window information to the second process. Because the first child thread can only be called by the main thread through the first function and not through other functions, an abnormal state of the first function will not affect the execution of other functions in the main thread, thereby avoiding performance issues caused by the abnormal state of the first function.
[0194] The following takes the example where the first function is a function for instructing the second process to release the buffer space and the first target information is the buffer space release information to exemplarily illustrate the above information sending method.
[0195] FIG11 is a flow chart of a method for sending information provided by an embodiment of the present application, which is applied to an electronic device. Referring to FIG11 , the method includes the following steps:
[0196] Step 1101: The main thread of the first process creates a first child thread. The first child thread can be called by the main thread through a first function, but cannot be called by the main thread through any function other than the first function.
[0197] The first process is a process capable of obtaining window information. The window information may include window information of some or all windows displayed by the electronic device, such as window information of visible windows and window information of invisible windows. The window information may include information such as window position, window size, and window type, which is not limited in the embodiments of the present application.
[0198] For example, the first process may be a SurfaceFlinger process. Of course, the first process may also be other processes that can obtain window information. This embodiment of the present application does not make a sole limitation to this.
[0199] After the electronic device creates a first process, the main thread of the first process begins running. During this process, the main thread may create a first child thread. The first child thread is used to independently execute the sending task of the first function. That is, the main thread can only execute the sending task by calling the first child thread through the first function and cannot call the first child thread through other functions.
[0200] The first function is used to instruct the second process to release buffer space. That is, when the main thread runs the first function, it can call the first child thread to send buffer space release information to the second process. For example, the first function can be a ReleaseBuffer function. Of course, the first function can also be other functions that can instruct a process to release buffer space. This embodiment of the present application is not limited to this.
[0201] In this embodiment of the present application, the main thread of the first process creates a first child thread that is solely used to execute the send task of the first function. This splits the send task of the first function from the main thread into a separate child thread. In this case, abnormal states of other functions in the main thread will not affect the operation of the first function, thereby avoiding performance issues caused by abnormal states of other functions.
[0202] Furthermore, the main thread can also create a second child thread. The second child thread can be called by the main thread through a second function. That is, the second child thread can execute the sending task of the second function. The second function is different from the first function. For example, the second function can be the updateInputFlinger function. Of course, the second function can also be other functions in the main thread besides the first function. This embodiment of the present application does not limit this to a single function.
[0203] Optionally, the main thread can only call the second sub-thread through the second function. In this case, the second sub-thread independently executes the sending task of the second function. Alternatively, the main thread can not only call the second sub-thread through the second function, but also call the second sub-thread through at least one other function other than the first function and the second function. In this case, the second sub-thread serially executes the sending task of each of the multiple functions.
[0204] Step 1102: The main thread runs a first function to pass buffer space release information to the first child thread.
[0205] When the main thread runs the first function, it can call the first sub-thread according to the buffer space release information to pass the buffer space release information to the first sub-thread. The buffer space release information is used to indicate the release of the buffer space.
[0206] Step 1103: After receiving the buffer space release information transmitted by the main thread, the first sub-thread sends the buffer space release information to the second process.
[0207] After receiving the buffer space release information transmitted by the main thread, the first sub-thread can execute the sending task of the first function to send the buffer space release information to the second process.
[0208] The second process is the process that needs to release the buffer space. For example, the second process can be the process to which the RenderThread thread belongs. Of course, the second process can also be other processes that need to release the buffer space, and this embodiment of the application does not limit this to a single process.
[0209] In some embodiments, the first child thread may send buffer space release information to the second process through the binder driver. Specifically, the first child thread may carry the buffer space release information in a binder message and send it to the binder driver. After the binder driver receives the binder message, it may send the binder message to the binder thread in the binder thread pool of the second process for processing. In some embodiments, the binder thread may pass the buffer space release information in the binder message to other threads in the second process for processing. For example, the second process may be the process to which the RenderThread thread belongs. After the binder thread in the process to which the RenderThread thread belongs receives the binder message sent by the binder driver, it may pass the buffer space release information in the binder message to the RenderThread thread. The RenderThread thread may release the buffer space according to the buffer space release information.
[0210] In an embodiment of the present application, the main thread of a first process creates a first child thread. The main thread then runs a first function to call the first child thread based on buffer space release information. After receiving the buffer space release information from the main thread, the first child thread sends the buffer space release information to the second process. Because the first child thread can only be called by the main thread through the first function and not through other functions, abnormal conditions in other functions within the main thread will not affect the execution of the first function, thereby avoiding performance issues caused by abnormal conditions in other functions.
[0211] The following describes an information sending method provided in an embodiment of the present application.
[0212] FIG12 is a flow chart of a method for sending information provided by an embodiment of the present application, which is applied to an electronic device. Referring to FIG12 , the method includes the following steps:
[0213] Step 1201: The main thread of the SurfaceFlinger process creates a third child thread, and the third child thread can be called by the main thread through the updateInputFlinger function.
[0214] After the electronic device creates the SurfaceFlinger process, the main thread of the SurfaceFlinger process begins running. The main thread can create a third child thread during operation. The third child thread is used to execute the sending task of the updateInputFlinger function. In some embodiments, the third child thread can be the first child thread or the second child thread described above. In other embodiments, the third child thread can be called by the main thread through the ReleaseBuffer function, that is, the third child thread can execute the sending tasks of the updateInputFlinger function and the ReleaseBuffer function serially.
[0215] Step 1202: The main thread runs the updateInputFlinger function to perform the following operations: obtaining the current window information, determining the target window information based on the current window information, and passing the target window information to the third child thread. The target window information is other window information in the current window information except for the window information containing the preset window type.
[0216] When the main thread runs the updateInputFlinger function, it can obtain the current window information. For example, when the main thread obtains the graphic data of the current image frame to be rendered, it can obtain the window information of all windows contained in the current image frame as the current window information based on the graphic data by running the updateInputFlinger function. Optionally, when the main thread runs the updateInputFlinger function, it can also determine whether the window displayed by the electronic device has changed based on the current window information. Specifically, when the current window information is different from the historical window information (i.e., the window information of all windows contained in the previous image frame), it can be determined that the window displayed by the electronic device has changed. When the current window information is the same as the historical window information, it can be determined that the window displayed by the electronic device has not changed.
[0217] When the main thread runs the updateInputFlinger function, it can filter the current window information and determine other window information in the current window information except the window information containing the preset window type as the target window information.
[0218] The preset window type can be pre-set, for example, by a technician based on relevant requirements. For example, the preset window type can be a window type that the user cannot directly operate on the screen, such as an invisible window type, a non-input channel window type, or one or more window types.
[0219] In the embodiment of the present application, the target window information sent by the updateInputFlinger function to the second process is obtained by filtering the current window information. After filtering, the amount of window information that needs to be sent to the second process is greatly reduced, and the amount of binder messages carrying window information that need to be sent to the second process subsequently is also reduced, thereby optimizing the load situation and avoiding stability problems to a certain extent.
[0220] In this case, even if the updateInputFlinger function takes a long time to run, resulting in the accumulation of binder messages, since the data volume of the binder messages in the embodiment of the present application is small, the total data volume of the accumulated binder messages is also small. In this case, when the accumulated binder messages flow into the binder thread pool of the second process in a short period of time, the binder thread pool of the second process will not be filled up, and no stability problem will be caused.
[0221] When the main thread runs the updateInputFlinger function, it can call the third child thread according to the target window information after obtaining the target window information to pass the target window information to the third child thread, so that the third child thread can send the target window information to the second process.
[0222] In some embodiments, when the main thread executes the updateInputFlinger function, it can directly call the third child thread based on the target window information after obtaining the target window information. Alternatively, when the main thread executes the updateInputFlinger function, it can, after obtaining the target window information, call the third child thread based on the target window information when it determines that the window has changed based on the current window information. In other words, when the window changes, the third child thread can be called to send the target window information to the second process. This can reduce the frequency of window information transmission, optimize load conditions, and avoid stability issues.
[0223] Step 1203: After receiving the target window information transmitted by the main thread, the third sub-thread sends the target window information to the second process.
[0224] After receiving the target window information transmitted by the main thread, the third sub-thread can execute the sending task of the updateInputFlinger function to send the target window information to the second process.
[0225] The second process is a process that needs to perform relevant processing based on the window information. For example, the second process can be a SystemServer process, which includes an InputDispatcher thread that can distribute touch events based on the window information. Of course, the second process can also be other processes that need to perform relevant processing based on the window information, and this embodiment of the application is not limited to this.
[0226] In some embodiments, the third sub-thread can send target window information to the second process through the binder driver. Specifically, the third sub-thread can carry the target window information in a binder message and send it to the binder driver. After the binder driver receives the binder message, it can send the binder message to the binder thread in the binder thread pool of the second process for processing. In some embodiments, the binder thread can pass the target window information in the binder message to other threads in the second process for processing. For example, the second process can be a SystemServer process. The SystemServer process includes an InputDispatcher thread. After the binder thread in the SystemServer process receives the binder message sent by the binder driver, it can pass the target window information in the binder message to the InputDispatcher thread. The InputDispatcher thread can distribute touch events based on the target window information.
[0227] In an embodiment of the present application, the main thread of the SurfaceFlinger process creates a third child thread, and the third child thread can be called by the main thread through the updateInputFlinger function. The main thread runs the updateInputFlinger function to perform operations: obtain the current window information, determine the target window information based on the current window information, and pass the target window information to the third child thread. The target window information is other window information in the current window information except for the window information containing the preset window type. After receiving the target window information passed by the main thread, the third child thread sends the target window information to the second process. In an embodiment of the present application, the target window information sent by the updateInputFlinger function to the second process is obtained by filtering the current window information. After filtering, the amount of window information data that needs to be sent to the second process is greatly reduced, thereby optimizing the load situation and avoiding stability problems to a certain extent.
[0228] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (such as a coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0229] The above are optional embodiments provided for this application and are not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the technical scope disclosed in this application should be included in the scope of protection of this application.
Claims
1. An image display method, the method being applied to an electronic device, characterized in that: include: The RenderThread thread draws the image frame; The SurfaceFlinger process obtains the graphics data of the image frame; After acquiring the graphic data of the image frame, the SurfaceFlinger process performs synthesis processing on the graphic data of the image frame to obtain a synthesized image frame; The SurfaceFlinger process performs display processing on the synthesized image frame; After acquiring the graphics data of the image frame, the SurfaceFlinger process is run to obtain window information; After obtaining the window information, the SurfaceFlinger process is run to obtain buffer space release information; The first thread of the SurfaceFlinger process sends the window information to the first process; A second thread of the SurfaceFlinger process sends the buffer space release information to a second process, wherein the second thread is different from the first thread.
2. The method according to claim 1, characterized in that The first process is the SystemServer process.
3. The method according to claim 2, characterized in that The first thread of the SurfaceFlinger process sends the window information to the first process, including: The first thread of the SurfaceFlinger process sends the window information to the InputDispatcher thread of the SystemServer process.
4. The method according to any one of claims 1 to 3, characterized in that The first thread and the second thread are subthreads of the SurfaceFlinger process, The SurfaceFlinger process obtains the graphics data of the image frame, including: The main thread of the SurfaceFlinger process obtains the graphics data of the image frame; The SurfaceFlinger process performs synthesis processing on the graphic data of the image frame, including: The main thread of the SurfaceFlinger process performs synthesis processing on the graphic data of the image frame; The SurfaceFlinger process performs display processing on the synthesized image frame, including: The main thread of the SurfaceFlinger process sends the synthesized image frame for display processing; The SurfaceFlinger process is run to obtain window information, including: The main thread of the SurfaceFlinger process is run to obtain the window information; The SurfaceFlinger process is run to obtain buffer space release information, including: The main thread of the SurfaceFlinger process is executed to obtain the buffer space release information.
5. The method according to claim 4, characterized in that The method further comprises: The main thread of the SurfaceFlinger process creates the first thread and the second thread.
6. The method according to any one of claims 1 to 5, characterized in that The second process is the process to which the RenderThread thread belongs.
7. The method according to any one of claims 1 to 6, characterized in that The SurfaceFlinger process is run to obtain window information, including: The SurfaceFlinger process runs updateInputFlinger to obtain the window information.
8. The method according to claim 6, characterized in that The buffer space release information is used to instruct the RenderThread thread to release the buffer space.
9. The method according to claim 8, characterized in that The method further comprises: The RenderThread releases buffer space.
10. An information transmission method, the method being applied to an electronic device, characterized in that: include: A touch event is detected; After detecting the touch event, the main thread of the SurfaceFlinger process is run to obtain window information; After obtaining the window information, the main thread of the SurfaceFlinger process is run to obtain buffer space release information; The first child thread of the SurfaceFlinger process sends the window information to the first process; A second sub-thread of the SurfaceFlinger process sends the buffer space release information to a second process, wherein the second sub-thread is different from the first sub-thread.
11. The method according to claim 10, characterized in that The first process is the SystemServer process.
12. The method according to claim 11, characterized in that The first child thread of the SurfaceFlinger process sends the window information to the first process, including: The first child thread sends the window information to the InputDispatcher thread of the SystemServer process.
13. The method according to any one of claims 10 to 12, characterized in that The method further comprises: The main thread of the SurfaceFlinger process creates the first sub-thread and the second sub-thread.
14. The method according to any one of claims 10 to 13, characterized in that The second process is the process to which the RenderThread thread belongs.
15. The method according to any one of claims 10 to 14, characterized in that The main thread of the SurfaceFlinger process is run to get window information, including: The main thread of the SurfaceFlinger process runs updateInputFlinger to obtain the window information.
16. The method according to claim 14, characterized in that The method further comprises: The RenderThread releases buffer space.
17. The method according to claim 12, characterized in that After the first child thread sends the window information to the InputDispatcher thread of the SystemServer process, the method further includes: The InputDispatcher thread sends the touch event to a window corresponding to the touch event based on the window information.
18. A method for sending information, characterized in that: The method comprises: A main thread of a first process creates a first child thread and a second child thread, wherein the first child thread can be called by the main thread through a first function and cannot be called by the main thread through other functions except the first function, and the second child thread can be called by the main thread through a second function except the first function, wherein one of the first function and the second function is used to send window information to a second process, and the other is used to instruct the second process to release buffer space; The main thread runs the first function to pass the first target information to the first child thread; After receiving the first target information transmitted by the main thread, the first sub-thread sends a The first target information is sent.
19. The method according to claim 18, characterized in that The first function is used to send window information to the second process, the first target information is target window information, and the main thread runs the first function to perform the following operations: Get the current window information; Determine the target window information according to the current window information, where the target window information is other window information in the current window information except the window information including the preset window type; If it is determined according to the current window information that the window has changed, the first sub-thread is called according to the target window information to pass the target window information to the first sub-thread.
20. The method of claim 19, wherein: The preset window type includes one or more of an invisible window type and a non-input channel window type.
21. The method according to any one of claims 18 to 20, characterized in that: The first function is used to send window information to the second process, the first target information is target window information, and after the first sub-thread receives the first target information transmitted by the main thread, sending the first target information to the second process includes: After receiving the target window information transmitted by the main thread, the first sub-thread determines the time interval between the time when the target window information is received and the time when the window information was last sent to the second process, and sends the target window information to the second process according to the time interval.
22. The method according to claim 21, characterized in that The first sub-thread sends the target window information to the second process according to the time interval, including: The first sub-thread sends the target window information to the second process when the time interval is greater than or equal to a first duration, and the first duration is greater than a frame interval of a display screen; When the time interval is less than the first duration, if the first sub-thread does not receive the next window information within the first duration after receiving the target window information, the target window information is sent to the second process.
23. The method according to any one of claims 18 to 20, characterized in that: The first function is used to send window information to the second process, the first target information is target window information, and after the first sub-thread receives the first target information transmitted by the main thread, sending the first target information to the second process includes: After the first sub-thread receives the target window information transmitted by the main thread, if there is window information in the task queue, the first sub-thread discards the window information in the task queue and sends the target window information to the second process; if there is no window information in the task queue, the first sub-thread determines the time interval between the time when the target window information is received and the time when the window information was last sent to the second process, and sends the target window information to the second process according to the time interval; wherein the window information in the task queue is the window information that has been received by the first sub-thread and has not yet been sent to the second process.
24. The method of claim 23, wherein: The first sub-thread sends the target window information to the second process according to the time interval, including: The first sub-thread sends the target window information to the second process when the time interval is greater than or equal to a first duration, and the first duration is greater than a frame interval of a display screen; When the time interval is less than the first duration, the first sub-thread sends the target window information The target window information is stored in the task queue, and if the next window information is not received within the first time period after the target window information is received, the target window information in the task queue is sent to the second process.
25. The method according to claim 22 or 24, characterized in that The first duration is less than or equal to twice the frame interval.
26. The method according to any one of claims 18 to 20, characterized in that The method further comprises: If the main thread receives the first message, the target variable is set to the first variable value, and the first message is used to indicate the start and exit animation of the application program; If the main thread receives a second message, the target variable is set to a second variable value, and the second message is used to indicate the end of the start-up and exit animation effect; The first function is used to send window information to the second process, the first target information is target window information, and after the first sub-thread receives the first target information transmitted by the main thread, sending the first target information to the second process includes: After the first sub-thread receives the target window information transmitted by the main thread, if it is determined that the target variable is the second variable value, the target window information is sent to the second process; if it is determined that the target variable is the first variable value, the time interval between the time when the target window information is received and the time when the window information was last sent to the second process is determined, and the target window information is sent to the second process according to the time interval.
27. The method of claim 26, wherein: If the main thread receives the first message, the target variable is set to the first variable value, including: If the main thread receives the first message and determines that the refresh rate of the display screen is greater than or equal to the preset refresh rate, the target variable is set to the first variable value.
28. The method according to claim 26 or 27, characterized in that The method further comprises: If the main thread does not receive the second message within a second period of time after setting the target variable to the first variable value, the main thread sets the target variable to the second variable value.
29. The method according to any one of claims 18 to 28, characterized in that The first sub-thread sends the first target information to the second process, including: The first sub-thread sends the first target information to the second process through a binder driver.
30. The method according to any one of claims 18 to 29, characterized in that: The first process is a SurfaceFlinger process, one of the first function and the second function is an updateInputFlinger function, and the other is a ReleaseBuffer function, and the updateInputFlinger function is used to send window information to an InputDispatcher thread in a SystemServer process.
31. A method for sending information, characterized in that: The method comprises: The main thread of the SurfaceFlinger process creates a third child thread, and the third child thread can be called by the main thread through the updateInputFlinger function; The main thread runs the updateInputFlinger function to perform the following operations: obtaining current window information, determining the target window information according to the current window information, and passing the target window information to the third sub-thread, wherein the target window information is other window information in the current window information except the window information including the preset window type; After receiving the target window information transmitted by the main thread, the third sub-thread sends a The target window information.
32. The method of claim 31, wherein: The transmitting the target window information to the third sub-thread comprises: If it is determined according to the current window information that the window has changed, the target window information is passed to the third sub-thread.
33. The method according to claim 31 or 32, characterized in that The preset window type includes one or more of an invisible window type and a non-input channel window type.
34. An electronic device, characterized in that: The electronic device includes a display screen, a memory and one or more processors; the display screen and the memory are coupled to the processor; the memory stores computer program code, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-33.
35. A computer-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 33.
36. A chip system, characterized in that: The chip system includes a processor, which is used to call a computer program in a memory to execute the method as described in any one of claims 1-33.