Application management method and related device
By creating and maintaining canvas and buffers in the desktop application of electronic devices, the interface display lag problem during frequent front and back-end switching is solved, and the application's response speed and user experience is improved.
Patent Information
- Application Number
- CN202410027541.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-04
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-01-04
AI Technical Summary
In electronic devices, the interface display may be stuttered when switching from the background to the front desk. The existing technology cannot effectively reduce this stuttering phenomenon in applications that frequently switch between front and back desks.
Create a canvas and apply for associated buffers when the desktop application is started and run in the foreground, and does not destroy the canvas and buffers when switching to the background, until the application switches to the foreground again, and then image drawing in the unreleased buffer and render.
It reduces the time-consuming interface display when the desktop application is switched to the foreground, reduces the probability of interface lag, and improves the user experience.
Smart Images

Figure CN119271318A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to an application management method and related devices. Background Art
[0002] Some electronic devices are installed with multiple applications to provide users with multiple application services. The multiple applications include desktop applications and other applications. The interface of the desktop application includes at least one application icon. The application icon can be an icon of other applications.
[0003] When the desktop application is running in the foreground, the user can click the application icon on the interface of the desktop application to make other applications corresponding to the application icon run in the foreground and the desktop application enter the background. When other applications running in the foreground exit the foreground, the desktop application can run in the foreground.
[0004] However, when other applications running in the foreground exit the foreground, the interface display of the desktop application may become stuck. Summary of the invention
[0005] The embodiment of the present application provides an application management method and related devices, which are applied to the field of terminal technology. When a desktop application is started and runs in the foreground, a canvas of the desktop application is created and a buffer associated with the canvas of the desktop application is applied for. When the desktop application is switched to run in the background and other applications (such as file management applications) are running in the foreground, the canvas of the desktop application is not destroyed, and the buffer associated with the canvas of the desktop application is not released. When the desktop application is switched to run in the foreground again, the image of the desktop application can be drawn in the buffer associated with the canvas of the desktop application that has not been released. In this way, the time consuming from the start time of the desktop application switching to run in the foreground again to the electronic device displaying the interface of the desktop application can be reduced, and the probability of the interface display of the desktop application being stuck can be reduced. Among them, the start time of the desktop application switching to run in the foreground again can be the moment when the electronic device receives an operation that causes the desktop application to run in the foreground.
[0006] In a first aspect, an embodiment of the present application provides an application management method, which may include:
[0007] When the first application is running in the foreground, a first canvas of the first application is created and at least one first buffer associated with the first canvas is requested. The first buffer is used to store the image of the first application. When the first application is switched to the background and the second application is running in the foreground, a second canvas of the second application is created and at least one second buffer associated with the second canvas is requested. The second buffer is used to store the image of the second application. The first canvas is not destroyed and at least one first buffer is not released. When the first application is switched to the foreground again, the image of the first application is drawn in at least one first buffer that has not been released.
[0008] For example, the specific implementation principle of the embodiment of the present application can be found in Figure 4A and Figure 4B The specific implementation principle shown.
[0009] Optionally, for a scenario where the memory of the electronic device is large, when an operation to start the second application is received, when the first application switches to the background and the second application runs in the foreground, the electronic device can create a spare pointer for the second application when creating the second canvas of the second application, and point the spare pointer to the second canvas, so that when an operation to cause the second application to exit the foreground is received, the second canvas is not destroyed, and at least one second buffer associated with the second canvas is not released. In this way, when the second application switches from the background to the foreground, the electronic device can display the interface of the second application in a timely manner, thereby improving the user experience.
[0010] The application management method provided in the embodiment of the present application creates a first canvas and applies for at least one first buffer associated with the first canvas when the first application is running in the foreground. The electronic device can draw and render the image of the first application in the at least one first buffer so that the electronic device displays the interface of the first application. When the second application is running in the foreground and the first application is running in the background, the canvas of the first application is not destroyed, and at least one first buffer is not released, so that when the first application is switched to run in the foreground again, the electronic device does not need to create a canvas for the first application again, nor does it need to apply for an associated buffer for the canvas of the first application again. The electronic device can draw and render in at least one first buffer that has not been released, so that the electronic device can display the interface of the first application in a timely manner. In this way, the probability of the interface display of the first application being stuck when the first application enters the foreground from the background can be reduced.
[0011] In a possible implementation, when the first application is running in the foreground, the method further includes: obtaining a first canvas pointer of the first application, the first canvas pointer including a first canvas parameter, and creating a standby pointer based on the first canvas parameter, wherein the first canvas pointer and the standby pointer both point to the first canvas.
[0012] Exemplarily, in the case of obtaining the first canvas pointer of the first application, the electronic device can use the first canvas parameter to create a standby pointer for the first application, so that when the first application is running in the background, the canvas of the first application is not destroyed, and the buffer associated with the canvas of the first application is not released, so that when the first application is switched from the background to the foreground, the interface of the first application can be displayed in time, reducing the probability of the interface display of the first application being stuck. It can be understood that when the electronic device obtains the canvas pointer of any application, the electronic device can use the canvas parameter carried in the canvas pointer of any application to create a standby pointer, so that when the any application is running in the background, the canvas of the any application is not destroyed, and the buffer associated with the canvas of the any application is not released, so that when the any application is switched from the background to the foreground, the interface of the any application can be displayed in time, reducing the probability of the interface display of the any application being stuck.
[0013] In a possible implementation, the first canvas parameter includes a canvas identifier of the first application. Creating a standby pointer based on the first canvas parameter includes: creating a standby pointer based on the first canvas parameter when the canvas identifier of the first application is a preset identifier.
[0014] In this way, applications that frequently switch between the foreground and the background can be identified through a preset identifier. The canvas identifier of the first application is a preset identifier, which can indicate that the first application is an application that frequently switches between the foreground and the background, and a backup pointer can be created for the canvas of the first application, so that when the first application exits the foreground and runs in the background, the first canvas is not destroyed, and the buffer associated with the first canvas is not released. If it is identified based on the preset identifier that the application that exits the foreground is not an application that frequently switches between the foreground and the background, when the application that does not frequently switch between the foreground and the background exits the foreground, the canvas corresponding to the application that does not frequently switch between the foreground and the background can be destroyed and the buffer associated with the corresponding canvas can be released to reduce the memory usage of the electronic device.
[0015] In a possible implementation, when the first application is switched to the background and the second application is running in the foreground, the method further includes: canceling the first canvas pointer pointing to the first canvas, and adding the address of the first canvas to a destruction queue. If it is determined that the first canvas is pointed to by the standby pointer, the first canvas is not destroyed.
[0016] In this way, by determining that the first canvas is pointed to by the standby pointer, it indicates that the application corresponding to the first canvas is an application that switches frequently between the foreground and the background, and the first canvas need not be destroyed. When the application corresponding to the first canvas switches to the foreground, the image can be drawn and rendered in the buffer associated with the first canvas, so that the electronic device can display the interface of the application corresponding to the first canvas in a timely manner, reducing the probability of freezes in the interface display of the application corresponding to the first canvas.
[0017] In a possible implementation, before canceling the first canvas pointer pointing to the first canvas, the method further includes: if it is determined that the first canvas is pointed to by the standby pointer, not releasing at least one first buffer associated with the first canvas.
[0018] In this way, by determining that the first canvas is pointed to by the standby pointer, it indicates that the application corresponding to the first canvas is an application that switches frequently between the foreground and the background, and at least one first buffer associated with the first canvas may not be released, so that when the application corresponding to the first canvas is switched to the foreground, the image can be drawn and rendered in the at least one first buffer, so that the electronic device can display the interface of the application corresponding to the first canvas in a timely manner, reducing the probability of freeze in the interface display of the application corresponding to the first canvas.
[0019] In a possible implementation, when creating a first canvas of a first application, the method further includes: maintaining an identifier of a first flag as a first identifier, the first identifier indicating that the canvas of the first application is a new canvas. Applying for at least one first buffer associated with the first canvas includes: applying for at least one first buffer associated with the first canvas when the first identifier is read.
[0020] In this way, if the first identifier is read, it means that the buffer associated with the canvas of the first application has not been applied for, and at least one first buffer associated with the first canvas can be applied for, so that the electronic device can draw and render the image of the first application in the at least one first buffer, so that the electronic device can display the interface of the first application.
[0021] In a possible implementation, when the first application is switched back to the foreground, the method further includes: obtaining a third canvas pointer of the first application, the third canvas pointer including a third canvas parameter. When the parameter of the standby pointer is the same as the parameter of the third canvas, the parameter of the standby pointer is used to assign a value to the third canvas pointer, so that the third canvas pointer points to the first canvas.
[0022] In this way, if the parameters of the standby pointer are the same as the parameters of the third canvas, it can be said that the canvas pointed to by the standby pointer meets the requirements of the third canvas parameters. There is no need to create a canvas for the first application again. The parameters of the standby pointer are used to assign values to the third canvas pointer so that the third canvas pointer points to the first canvas, so that the electronic device can find the first canvas based on the assigned third canvas pointer and draw the image of the first application in the buffer associated with the first canvas, so that the electronic device can display the interface of the first application in a timely manner.
[0023] In a possible implementation, when the parameter of the standby pointer is used to assign a value to the third canvas pointer, the method further includes: maintaining the identifier of the first flag bit as a second identifier, the second identifier indicating that the canvas of the first application is an old canvas. After maintaining the identifier of the first flag bit as the second identifier, the method further includes: when the second identifier is read, not executing the process of applying for the buffer associated with the canvas of the first application.
[0024] In this way, if the second identifier is read, it can indicate that the buffer associated with the canvas of the first application has been applied for, and there is no need to apply for the buffer associated with the canvas of the first application again, and there is no need to execute the process of applying for the buffer associated with the canvas of the first application, which can reduce the power consumption of the electronic device and facilitate the electronic device to find the first canvas in time based on the assigned third canvas pointer, and draw the image of the first application in the buffer associated with the first canvas, so that the electronic device can display the interface of the first application in time.
[0025] In one possible implementation, the method further includes: when the first application is switched to run in the background and the third application is running in the foreground, creating a third canvas of the third application and applying for at least one third buffer associated with the third canvas. The third buffer is used to store the image of the third application. The first canvas is not destroyed and at least one first buffer is not released. An operation to download a fourth application is received, and the fourth application is downloaded. The download of the fourth application causes the interface of the first application to change. When the first application is switched to run in the foreground again, creating a fourth canvas of the first application and applying for at least one fourth buffer associated with the fourth canvas. The fourth buffer is used to store the image of the first application. The specific implementation principle of the embodiment of the present application can be found in Figure 5 The specific implementation principle of the embodiment.
[0026] In this way, when the interface of the first application changes and the first application is switched to the foreground again, a new canvas (such as the fourth canvas) is recreated for the first application and a buffer associated with the new canvas (such as at least one fourth buffer) is applied for, which can reduce the probability that the canvas of the first application does not meet the drawing and rendering requirements of the image of the first application.
[0027] In a possible implementation, when the first application is switched to run in the foreground again, the method further includes: obtaining a fourth canvas pointer of the first application, the fourth canvas pointer including fourth canvas parameters. When the parameters of the standby pointer are different from the fourth canvas parameters, the fourth canvas parameters are used to create the fourth canvas of the first application, and the standby pointer is set to zero to obtain a standby pointer after being set to zero. The standby pointer after being set to zero does not point to the canvas. The fourth canvas pointer and the standby pointer after being set to zero are assigned values, so that the fourth canvas pointer and the standby pointer both point to the fourth canvas.
[0028] In this way, when the first application runs in the background again, the fourth canvas will not be destroyed and the buffer associated with the fourth canvas will not be released, so that when the first application switches from the background to the foreground again, the electronic device does not need to create a new canvas for the first application again, nor does it need to apply for the buffer associated with the canvas of the first application again, so that the electronic device can display the interface of the first application in a timely manner and reduce the probability of freezes in the interface display of the first application.
[0029] In a possible implementation, the method further includes: when the standby pointer points to the fourth canvas, determining that the first canvas is not pointed to by the pointer, destroying the first canvas, and releasing at least one first buffer associated with the first canvas.
[0030] In this way, the occupation of the electronic device memory by the unnecessary first canvas and the buffer associated with the first canvas can be reduced.
[0031] In a possible implementation, when the first application switches to background operation and the second application runs in the foreground, the method further includes: obtaining a second canvas pointer of the second application, the second canvas pointer includes a second canvas parameter, and the second canvas parameter includes a canvas identifier of the second application. Creating a second canvas of the second application includes: when the canvas identifier of the second application is not a preset identifier, creating the second canvas based on the second canvas parameter. The second canvas pointer points to the second canvas.
[0032] In this way, the canvas identifier of the second application is not a preset identifier, which can indicate that the second application is not an application that frequently switches between the foreground and the background. No backup pointer is created for the second application, so that the canvas of the second application is destroyed and the buffer associated with the canvas of the second application is released when the second application exits the foreground, so as to reduce the memory usage of the electronic device.
[0033] In a possible implementation, when the first application is switched to run in the foreground again, the method further includes: canceling the second canvas pointer pointing to the second canvas, and adding the address of the second canvas to a destruction queue. If it is determined that the second canvas is not referenced by the pointer, destroying the second canvas.
[0034] In this way, the canvas of the second application can be destroyed when the second application exits the foreground, so as to reduce the memory occupation of the electronic device.
[0035] In a possible implementation, before canceling the second canvas pointer pointing to the second canvas, the method further includes: if it is determined that the second canvas is not referenced by the standby pointer, releasing at least one second buffer associated with the second canvas.
[0036] In this way, when the second application exits the foreground, the buffer associated with the canvas of the second application can be released, so as to reduce the memory occupation of the electronic device.
[0037] In one possible implementation, the first canvas parameter includes a canvas identifier of the first application. When the first application switches to the background and the second application runs in the foreground, the method further includes: if the canvas identifier of the first application is a preset identifier, the process of destroying the first canvas is not executed, and the process of releasing at least one first buffer associated with the first canvas is not executed. The specific implementation principle of the embodiment of the present application can be found in Figure 6 The specific implementation principle shown.
[0038] In this way, when the canvas identifier of the first application is the preset identifier, the process of destroying the first canvas is not executed, and the process of releasing at least one first buffer associated with the first canvas is not executed, so that when the first application is running in the background, the canvas of the first application is not destroyed, and the buffer associated with the canvas of the first application is not released, so that when the first application switches from the background to the foreground, the electronic device can display the interface of the first application in time, reducing the probability of the interface display of the first application being stuck. Not executing the process of destroying the first canvas and not executing the process of releasing at least one first buffer associated with the first canvas can also reduce the power consumption of the electronic device.
[0039] In a possible implementation, when the first application is switched back to the foreground, the method further includes: when the canvas identifier of the second application is not a preset identifier, executing a process of destroying the second canvas, and executing a process of releasing at least one second buffer associated with the second canvas. The canvas identifier of the second application is carried in the second canvas pointer of the second application. The specific implementation principle of the embodiment of the present application can be found in Figure 6 The specific implementation principle shown.
[0040] In this way, the canvas identifier of the second application is not a preset identifier, indicating that the second application is not an application that frequently switches between the foreground and the background. When the first application switches to the foreground again and the second application exits the foreground, the process of destroying the second canvas is executed, and the process of releasing at least one second buffer associated with the second canvas is executed. This can achieve the situation where the canvas of the second application is destroyed and the buffer associated with the canvas of the second application is released when the second application is running in the background, so as to reduce the memory usage of the electronic device.
[0041] In a possible implementation, the first application is a desktop application.
[0042] In a second aspect, an embodiment of the present application provides an application management device, which may be an electronic device, or a chip or chip system in an electronic device. The application management device may include a display unit and a processing unit. When the application management device is an electronic device, the display unit may be a display screen. The display unit is used to perform the display step so that the electronic device implements an application management method described in the first aspect or any possible implementation of the first aspect. When the application management device is an electronic device, the processing unit may be a processor. The application management device may also include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit so that the electronic device implements an application management method described in the first aspect or any possible implementation of the first aspect. When the application management device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements an application management method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit within the chip (eg, a register, a cache, etc.), or a storage unit within the electronic device that is located outside the chip (eg, a read-only memory, a random access memory, etc.).
[0043] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: one or more processors and a memory. The memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method described in the first aspect or any possible implementation of the first aspect.
[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0045] In a fifth aspect, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect or any possible implementation manner of the first aspect.
[0046] In a sixth aspect, the present application provides a chip or a chip system, the chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.
[0047] In a possible implementation, the chip or chip system described above in the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0048] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of a scenario provided for an embodiment of the present application;
[0050] Figure 2 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0051] Figure 3 A schematic diagram of the software architecture of an electronic device according to an embodiment of the present application;
[0052] Figure 4A A schematic diagram of a module interaction process provided in an embodiment of the present application;
[0053] Figure 4B Another schematic diagram of a module interaction process provided in an embodiment of the present application;
[0054] Figure 5 A schematic diagram of another module interaction process provided in an embodiment of the present application;
[0055] Figure 6 A schematic diagram of another module interaction process provided in an embodiment of the present application;
[0056] Figure 7A schematic diagram of another module interaction process provided in an embodiment of the present application;
[0057] Figure 8 A schematic diagram of a chip system structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:
[0059] 1. Other terms
[0060] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. 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.
[0061] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0062] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.
[0063] 2. Electronic equipment
[0064] The electronic device of the embodiment of the present application may include a handheld device, a vehicle-mounted device, etc. with a control function. For example, some electronic devices are: mobile phones, tablet computers, PDAs, laptop computers, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, terminal devices in 5G networks or future evolved public land mobile communication networks (public landmobile networks). The embodiments of the present application do not limit this.
[0065] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.
[0066] In addition, in the embodiments of the present application, the electronic device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.
[0067] The electronic devices in the embodiments of the present application may also be referred to as: terminal equipment, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.
[0068] In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0069] Figure 1 A schematic diagram of a scenario provided in an embodiment of the present application is shown.
[0070] like Figure 1 As shown, when the electronic device 100 is unlocked, the desktop application is started, and the electronic device 100 can display Figure 1 The desktop application interface shown in a. Figure 1 As shown in a in , the interface includes a status bar, an application icon for a settings application, an application icon for a calendar application, an application icon 101 for a file management application, an application icon for a WeChat application, an application icon for a note application, an application icon for a Toutiao application, an application icon for a phone application, an application icon for a camera application, and an application icon for a text message application.
[0071] exist Figure 1In the interface shown in a of FIG. 1 , the user can perform a touch operation on the application icon 101. The touch operation includes a click operation or a slide operation. When a touch operation on the application icon 101 is received, the electronic device 100 can display the following Figure 1 The interface of the file management application shown in b in FIG. 1 is shown, and the desktop application exits the foreground and runs in the background. Figure 1 The interface shown in b in the figure includes a status bar, a return control 102, the word "document", a control indicating search, a sorting mark and the word "sort by time", a drop-down selection control, a document indicating that the creation time is 2023 / 12 / 03 and the document name is "Save ABC", and a document indicating that the creation time is 2023 / 10 / 08 and the document name is "Drawing Process". The document with the document name "Save ABC" is surrounded by information indicating the document creation date "2023 / 12 / 03" and information indicating the document memory usage "159.78KB". The document with the document name "Drawing Process" is surrounded by information indicating the document creation date "2023 / 10 / 08" and information indicating the document memory usage "71.85KB".
[0072] exist Figure 1 In the interface shown in b in FIG. 1 , the user can touch the return control 102 to make the file management application exit the foreground. When the touch operation on the return control 102 is received, the desktop application can switch from running in the background to running in the foreground.
[0073] However, in some implementations, when the desktop application is started and runs in the foreground, the electronic device can create a desktop application canvas for the desktop application and apply for a buffer associated with the desktop application canvas. The electronic device can draw and render the image of the desktop application in the buffer associated with the desktop application canvas. The electronic device can synthesize and display the drawn and rendered image of the desktop application. In this way, the electronic device can display Figure 1 The interface shown in a.
[0074] When the desktop application exits the foreground and runs in the background, the electronic device can destroy the canvas of the desktop application and release the buffer associated with the canvas of the desktop application.
[0075] When the desktop application switches from running in the background to running in the foreground, the negative one-screen application and the desktop application of the electronic device will simultaneously apply to create their own canvases and buffers associated with their own canvases. The electronic device can first create a canvas for the negative one-screen application, and apply for a buffer associated with the canvas of the negative one-screen application. When the electronic device completes the creation of the canvas of the negative one-screen application and completes the application for the buffer associated with the canvas of the negative one-screen application, the electronic device creates a canvas for the desktop application for the desktop application, and applies for a buffer associated with the canvas of the desktop application. The electronic device can draw and render the image of the desktop application in the buffer associated with the canvas of the desktop application, and synthesize and display the image of the desktop application that has been drawn and rendered.
[0076] Because the canvas of the negative-one-screen application must be created and the buffer associated with the canvas of the negative-one-screen application must be requested before the electronic device creates the canvas of the desktop application, it takes a long time from the moment the electronic device receives the touch operation on the return control 102 to the moment the electronic device displays the image of the desktop application, which causes the user to have a visual experience of a stuck display of the desktop application interface, affecting the user experience.
[0077] In view of this, an embodiment of the present application proposes an application management method, when a desktop application is started and runs in the foreground, a canvas of the desktop application is created and a buffer associated with the desktop application's canvas is applied for. When the desktop application switches to run in the background and other applications (such as a file management application) run in the foreground, the canvas of the desktop application is not destroyed, and the buffer associated with the desktop application's canvas is not released. When the desktop application is switched to run in the foreground again, the image of the desktop application can be drawn in the buffer associated with the canvas of the desktop application that has not been released. In this way, the time from the start of the desktop application switching to run in the foreground to the electronic device displaying the interface of the desktop application can be reduced, thereby reducing the probability of freezes in the interface display of the desktop application. Among them, the start time of the desktop application switching to run in the foreground again can be the moment when the electronic device receives an operation to make the desktop application run in the foreground. The operation to make the desktop application run in the foreground is, for example: Figure 1 The touch operation of the return control 102 on the interface shown in b.
[0078] Figure 2 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown.
[0079] like Figure 2As shown, the electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc. The sensor module 280 may include a pressure sensor 280A, a gyroscope sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, etc.
[0080] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0081] Exemplarily, when the first application is started and runs in the foreground, the processor 210 creates a first canvas of the first application and applies for at least one first buffer associated with the first canvas. The first buffer is used to store images of the first application. The first application may be a desktop application.
[0082] When the first application switches to the background and the second application runs in the foreground, the processor 210 creates a second canvas of the second application and applies for at least one second buffer associated with the second canvas. The second buffer is used to store the image of the second application. The first canvas is not destroyed and at least one first buffer is not released. The second application may be another application. The other application is not a desktop application. The other application may be an application corresponding to any application icon on the interface of the desktop application.
[0083] When the first application is switched back to the foreground, the processor 210 draws the image of the first application in the at least one first buffer that has not been released, and the display screen 294 displays the image of the first application. Figure 1 An image of the interface shown in a in FIG.
[0084] In this way, when the first application exits the foreground, the first canvas of the first application and the buffer associated with the first canvas are not destroyed. When the first application switches from running in the background to running in the foreground, the processor 210 no longer needs to create a canvas and apply for a buffer for the first application, and can draw and render the image of the first application in the buffer associated with the first canvas created previously. When the second application exits the foreground, the display screen 294 can display the image of the first application in time, thereby reducing the probability of freezes in the interface display of the first application.
[0085] The software system of the electronic device 200 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 200.
[0086] Figure 3 A schematic diagram of the software architecture of an electronic device according to an embodiment of the present application is shown.
[0087] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0088] The application layer can include a series of application packages.
[0089] like Figure 3 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0090] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0091] like Figure 3 As shown, the application framework layer may include a window manager service (WMS), a rendering thread, a surface flinger, a destruction module, a view module, a content provider, a phone manager, a resource manager, a notification manager, and the like.
[0092] The window manager can be used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0093] The rendering module can be used to draw and render the application's images, and can also be used to apply for a buffer associated with a canvas (surface).
[0094] The synthesis module can be used to synthesize and display the images of the application that have been drawn and rendered.
[0095] The destruction module can be used to destroy canvases in the destruction queue that are not referenced by pointers.
[0096] Content providers are used to store and retrieve data and make it accessible to applications. The data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0097] The view module includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view module can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures. The view module can also be used to transmit application transmission information to the window manager.
[0098] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0099] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0100] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0101] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0102] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0103] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0104] The system library may 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.
[0105] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0106] Exemplarily, when the first application is started and runs in the foreground, the first application can transmit a first canvas pointer to the synthesis module through the view module and the window manager. The first canvas pointer includes the canvas name and first canvas parameters of the first application.
[0107] When the synthesis module determines that the canvas name of the first application is a preset name and there is no spare pointer, the synthesis module can create a spare pointer and use the first canvas parameter to create the first canvas of the first application. The synthesis module can point both the first canvas pointer and the spare pointer to the first canvas. The fact that both the first canvas pointer and the spare pointer point to the first canvas can be understood as the first canvas pointer and the spare pointer both refer to the first canvas. The synthesis module can also maintain the first flag as a first identifier. The first identifier indicates that the canvas of the first application is a new canvas. The first application can obtain the assignment information of the first canvas pointer. The assignment information of the first canvas pointer can be used to indicate that the first canvas pointer points to the first canvas.
[0108] The first application can transmit the assigned first canvas pointer and the first drawing instruction to the rendering module through the view module and the window manager. The first drawing instruction can include a first drawing parameter. The first drawing parameter can include the view position of the first application or the view content of the first application, etc. When the rendering module determines that the canvas name of the first application is a preset name, the rendering module can read the identifier of the first flag bit from the synthesis module and obtain the number of buffers associated with the first canvas based on the first canvas pointer. When the first identifier is read, the first buffer associated with the first canvas is applied according to the number of buffers associated with the first canvas. The first buffer is used to store the image of the first application.
[0109] When the first application is switched to the background and the second application is running in the foreground, the second application can transmit the second canvas pointer to the synthesis module through the view module and the window manager. The second canvas pointer contains the canvas name of the second application and the second canvas parameter. When the synthesis module determines that the canvas name of the second application is not a preset name, the synthesis module can use the second canvas parameter to create the second canvas of the second application and point the second canvas pointer to the second canvas. The second application can obtain the assignment information of the second canvas pointer. The assignment information of the second canvas pointer can be used to indicate that the second canvas pointer points to the second canvas. The second application can transmit the assigned second canvas pointer and the second drawing instruction to the rendering module through the view module and the window manager. The second drawing instruction can contain the second drawing parameter. The second drawing parameter can contain the view position of the second application or the view content of the second application, etc. When the rendering module determines that the canvas name of the second application is not a preset name, the number of buffers associated with the second canvas can be obtained based on the second canvas pointer, and the second buffer associated with the second canvas can be applied according to the number of buffers associated with the second canvas. The second buffer is used to store the image of the second application.
[0110] When the first application is switched to the background and the second application is running in the foreground, the first application may transmit information indicating the destruction of the canvas of the first application to the rendering module through the view module and the window manager. The rendering module cancels the communication connection between the first application and the rendering module. When the rendering module determines that the first canvas is referenced by the standby pointer, the first buffer associated with the first canvas is not released. The rendering module may transmit information indicating the destruction of the canvas of the first application to the synthesis module through the window manager. The synthesis module cancels the reference of the first canvas pointer to the first canvas and adds the address of the first canvas to the destruction queue. When the destruction module determines that the first canvas is used by the standby pointer, the first canvas is not destroyed.
[0111] When the first application is switched to the foreground again, the rendering module draws and renders the image of the first application in the first buffer that has not been released. When the synthesis module receives the information transmitted by the rendering module indicating that the image drawing of the first application is completed, the synthesis module synthesizes the image of the first application and sends it for display.
[0112] In this way, when the first application exits the foreground, the first canvas of the first application and the buffer associated with the first canvas are not destroyed. When the first application switches from running in the background to running in the foreground, the synthesis module does not need to create a canvas for the first application, and the rendering module does not need to apply for a buffer for the canvas of the first application. The image of the first application can be drawn and rendered in the buffer associated with the first canvas created previously, so that the image of the first application can be displayed in time when the second application exits the foreground, reducing the probability of freezes in the interface display of the first application.
[0113] Combine the following Figure 4A and Figure 4B The module interaction process provided in the embodiment of the present application is described. Figure 4A A schematic diagram of a module interaction process provided by an embodiment of the present application is shown. Figure 4A On the basis of Figure 4B Another schematic diagram of module interaction process provided in an embodiment of the present application is shown.
[0114] like Figure 4A As shown, the module interaction process may include:
[0115] S400: The electronic device may receive an operation for causing the first application to run in the foreground.
[0116] Exemplarily, taking the first application as a desktop application as an example, the operation of making the first application run in the foreground may be an unlocking operation.
[0117] S401. A first application may transmit a first canvas pointer to a view module.
[0118] The first canvas pointer may carry the first canvas parameters. The first canvas parameters may include the canvas name of the first application, the length of the first canvas, and the width of the first canvas. It should be understood that the length of the canvas and the width of the canvas may represent the size of the canvas. For example, the length of the first canvas and the width of the first canvas may represent the size of the first canvas.
[0119] Exemplarily, the first application may call a function (or method) in the view module for transmitting a canvas pointer, so as to transmit the first canvas pointer to the view module.
[0120] S402: The view module may transmit a first canvas pointer to the window manager.
[0121] Exemplarily, the view module may call a function in the window manager for transmitting a canvas pointer, so as to transmit the first canvas pointer to the window manager.
[0122] S403: The window manager may transmit the first canvas pointer to the synthesis module.
[0123] Exemplarily, the window manager may call a function (or method) in the composition module for transmitting a canvas pointer, so as to transmit the first canvas pointer to the composition module.
[0124] S404: When the first canvas pointer is obtained, the synthesis module may determine whether the canvas name of the first application is a preset name.
[0125] When the canvas name of the first application is a preset name, the synthesis module may determine whether there is a spare pointer.
[0126] When it is determined that there is no spare pointer, the synthesis module may create the first canvas using the first canvas parameter, and create the spare pointer using the first canvas parameter. The synthesis module may assign values to the first canvas pointer and the spare pointer so that both the first canvas pointer and the spare pointer point to the first canvas. The synthesis module may also maintain the identifier of the first flag as the first identifier. The first identifier may indicate that the canvas of the first application (such as the first canvas) is a new canvas. The first identifier may be false. The first flag may also be called a canvas flag.
[0127] The canvas name of the first application is a preset name, which may indicate that the first application is an application that switches between the foreground and the background frequently.
[0128] Optionally, the synthesis module may create the first canvas using the first canvas parameters before the synthesis module determines whether the canvas name of the first application is a preset name.
[0129] S405: The first application may transmit the assigned first canvas pointer to the view module.
[0130] It is understandable that when the synthesis module assigns a value to the first canvas pointer, the first application can obtain a callback function, which can include the value assigned to the first canvas pointer by the synthesis module, and then the first application can obtain the assigned first canvas pointer.
[0131] S406: The view module may transmit the assigned first canvas pointer to the rendering module.
[0132] S407. When the first canvas pointer after assignment is obtained, the rendering module can determine whether the canvas name of the first application is a preset name. When it is determined that the canvas name of the first application is a preset name, the rendering module reads the identifier of the first flag. When the first identifier is read, the rendering module can obtain the number of buffers associated with the first canvas from the synthesis module based on the first canvas pointer after assignment. Reading the first identifier can indicate that the buffer associated with the canvas of the first application has not been applied for.
[0133] S408: The rendering module may use the number of buffers associated with the first canvas to apply for buffers associated with the first canvas.
[0134] S409: The first application may transmit a first drawing instruction to the view module.
[0135] The first drawing instruction may include a first drawing parameter. The first drawing parameter may include a view position of the first application and a view content of the first application.
[0136] Exemplarily, when the first application obtains the callback function, the first application may transmit the first drawing instruction to the view module. It is understandable that when the first application obtains the callback function, the first application may periodically transmit the first drawing instruction to the view module so that the electronic device can update the interface of the first application in a timely manner. For example, the first application may transmit the first drawing instruction to the view module every second so that the electronic device can update the interface of the first application in a timely manner, so that the time displayed in the status bar on the interface of the first application displayed by the electronic device is synchronized with the real time.
[0137] Optionally, S409 and S405 may be executed concurrently. S409 and S405 may also be executed sequentially. For example, after S405 is executed, S409 may be executed.
[0138] S410: The view module may transmit a first drawing instruction to the rendering module.
[0139] S411: When a first drawing instruction is obtained, the rendering module may use a first drawing parameter to draw and render an image of the first application in a buffer associated with the first canvas pointed to by a first canvas pointer.
[0140] S412: When the rendering module completes drawing and rendering of the image of the first application, the rendering module may transmit information indicating that drawing of the image of the first application is completed to the synthesis module.
[0141] S413: When obtaining information indicating that the image drawing of the first application is completed, the synthesis module may synthesize and display the image of the first application drawn and rendered by the rendering module.
[0142] Exemplarily, the buffer associated with the first canvas stores an image of the first application. When information indicating that the image of the first application is drawn is obtained, the synthesis module may synthesize and display the buffer associated with the first canvas.
[0143] S414: The electronic device may receive an operation to start the second application, and the first application exits the foreground and runs in the background.
[0144] For example, still taking the first application as a desktop application, the second application may be an application corresponding to any application icon on the interface of the desktop application. The operation of starting the second application is, for example, a user touching an application icon on the interface of the desktop application.
[0145] It can be understood that when the electronic device receives an operation to start the second application, the first application and the second application can receive a touch event corresponding to the operation to start the second application.
[0146] When receiving the touch event corresponding to the operation of starting the second application, the first application may execute S415 and the second application may execute S422.
[0147] S415: When the electronic device receives an operation to start the second application, the first application may transmit first destruction information to the view module.
[0148] The first destruction information may include the assigned first canvas pointer. The first destruction information may be information indicating the destruction of the canvas of the first application, or information indicating the destruction of the canvas pointed to by the first canvas pointer.
[0149] S416: The view module may transmit first destruction information to the rendering module.
[0150] S417: When receiving the first destruction information, the rendering module may cancel the communication connection between the first application and the rendering module, and when the rendering module determines that the first canvas is pointed to by the backup pointer, the rendering module may not release the buffer associated with the first canvas. The first canvas being pointed to by the backup pointer may be referred to as the first canvas being referenced by the backup pointer.
[0151] The rendering module cancels the communication connection between the first application and the rendering module, so that the rendering module will not receive the first drawing instruction transmitted by the first application, which can reduce the power consumption of the electronic device and the probability of the electronic device still displaying the interface of the first application when exiting the foreground.
[0152] The rendering module does not release the buffer associated with the first canvas. In this way, when the first application is switched to the foreground again, there is no need to apply for the buffer associated with the canvas of the first application again. When a drawing instruction from the first application is received, the image of the first application can be drawn and rendered in the buffer associated with the first canvas, so that the electronic device can display the interface of the first application in a timely manner.
[0153] S418: The rendering module may transmit first destruction information to the window manager.
[0154] S419: The window manager may transmit first destruction information to the synthesis module.
[0155] S420: When the first destruction information is obtained, the synthesis module may cancel the first canvas pointer pointing to the first canvas, and add the address of the first canvas to the destruction queue. Canceling the first canvas pointer pointing to the first canvas may be referred to as: canceling the reference of the first canvas pointer to the first canvas.
[0156] S421: When it is determined that the first canvas is referenced by the backup pointer, the destroying module may not destroy the first canvas.
[0157] Exemplarily, the destruction module can periodically find the canvas corresponding to the address in the destruction queue based on the address in the destruction queue, and when it is determined that the found canvas is not referenced by the pointer, destroy the canvas not used by the pointer. When it is determined that the found canvas is referenced by the pointer, the canvas referenced by the pointer is not destroyed.
[0158] S422: When the electronic device receives an operation to start a second application, the second application may transmit a second canvas pointer to the view module.
[0159] The second canvas pointer may carry second canvas parameters, which may include the canvas name of the second application, the length of the second canvas, and the width of the second canvas.
[0160] Optionally, S422 and S415 may be executed concurrently, so that the electronic device can display the interface of the second application in a timely manner, thereby improving the user experience.
[0161] S423: The view module may transmit the second canvas pointer to the window manager.
[0162] S424: The window manager may transmit the second canvas pointer to the synthesis module.
[0163] Among them, the specific implementation principle of S422-S424 is similar to the specific implementation principle of S401-S403, and will not be repeated here.
[0164] S425: When the second canvas pointer is obtained, the synthesis module may determine whether the canvas name of the second application is a preset name.
[0165] When the canvas name of the second application is not a preset name, the synthesis module may create the first canvas using the second canvas parameter. The synthesis module may assign a value to the second canvas pointer so that the second canvas pointer points to the second canvas.
[0166] The canvas name of the second application is not a preset name, which may indicate that the second application is not an application that switches between the foreground and the background frequently.
[0167] S426: The second application may transmit the assigned second canvas pointer to the view module.
[0168] It is understandable that when the synthesis module assigns a value to the second canvas pointer, the second application can obtain a callback function, which can include the value assigned to the second canvas pointer by the synthesis module, and then the second application can obtain the assigned second canvas pointer.
[0169] S427: The view module may transmit the assigned second canvas pointer to the rendering module.
[0170] S428. When obtaining the second canvas pointer after the assignment, the rendering module can determine whether the canvas name of the second application is a preset name. When determining that the canvas name of the second application is not a preset name, the rendering module can obtain the number of buffers associated with the second canvas from the synthesis module based on the second canvas pointer after the assignment.
[0171] S429: The rendering module may use the number of buffers associated with the second canvas to apply for buffers associated with the second canvas.
[0172] S430: The second application may transmit a second drawing instruction to the view module.
[0173] The second drawing instruction may include a second drawing parameter, which may include a view position of the second application and a view content of the second application.
[0174] The specific implementation principle of this step is similar to that of S409 and will not be repeated here.
[0175] Optionally, S430 and S426 may be executed concurrently. S430 and S426 may also be executed sequentially. For example, after S426 is executed, S430 may be executed.
[0176] S431: The view module may transmit a second drawing instruction to the rendering module.
[0177] S432: When the second drawing instruction is obtained, the rendering module may use the second drawing parameter to draw and render the image of the second application in the buffer associated with the second canvas pointed to by the second canvas pointer.
[0178] S433: When the rendering module completes drawing and rendering of the image of the second application, the rendering module may transmit information indicating that drawing of the image of the second application is completed to the synthesis module.
[0179] S434: When obtaining information indicating that the image drawing of the second application is completed, the synthesis module may synthesize and display the image of the second application drawn and rendered by the rendering module.
[0180] Exemplarily, the buffer associated with the second canvas stores an image of the second application. When information indicating that the image of the second application is drawn is obtained, the synthesis module may synthesize and display the buffer associated with the second canvas.
[0181] exist Figure 4A On the basis of Figure 4B As shown, the module interaction process may also include:
[0182] S435: The electronic device may receive an operation to cause the second application to exit the foreground, the second application may exit the foreground, and the first application may switch to the foreground to run.
[0183] It can be understood that when the electronic device receives an operation that causes the second application to exit the foreground, the first application and the second application can receive a touch event corresponding to the operation that causes the second application to exit the foreground.
[0184] When receiving the touch event corresponding to the operation of causing the second application to exit the foreground, the second application may execute S436. The first application may execute S443.
[0185] S436: When the electronic device receives an operation that causes the second application to exit the foreground, the second application may transmit second destruction information to the view module.
[0186] The second destruction information may include the assigned second canvas pointer. The second destruction information may be information indicating the destruction of the canvas of the second application, or information indicating the destruction of the canvas pointed to by the second canvas pointer.
[0187] S437: The view module may transmit second destruction information to the rendering module.
[0188] S438. When the second destruction information is obtained, the rendering module may cancel the communication connection between the second application and the rendering module. Based on the assigned second canvas pointer, when it is determined that the second canvas is not pointed to by the standby pointer, the rendering module may release the buffer associated with the second canvas. The second canvas not being pointed to by the pointer may be referred to as: the second canvas is not referenced by the pointer.
[0189] The rendering module cancels the communication connection between the second application and the rendering module, so that the rendering module will not receive the second drawing instruction transmitted by the second application, which can reduce the power consumption of the electronic device and the probability of the electronic device still displaying the interface of the second application when exiting the foreground.
[0190] The rendering module releases the buffer associated with the second canvas, so that the memory occupation of the electronic device by the buffer associated with the second canvas can be reduced after the second application exits the foreground.
[0191] S439: The rendering module may transmit second destruction information to the window manager.
[0192] S440: The window manager may transmit second destruction information to the synthesis module.
[0193] S441: When the second destruction information is obtained, the synthesis module may cancel the second canvas pointer pointing to the second canvas, and add the address of the second canvas to the destruction queue. Canceling the second canvas pointer pointing to the second canvas may be referred to as: canceling the reference of the second canvas pointer to the second canvas.
[0194] S442: When it is determined that the second canvas is not pointed to by the pointer, the destroying module may destroy the second canvas. The fact that the second canvas is not pointed to by the pointer may be referred to as the second canvas is not referenced by the pointer.
[0195] S443: When the electronic device receives an operation to cause the second application to exit the foreground, the first application may transmit a third canvas pointer to the view module.
[0196] The third canvas pointer may carry third canvas parameters, which may include the canvas name of the first application, the length of the third canvas, the width of the third canvas, and the like.
[0197] Optionally, S443 and S436 may be executed concurrently, so that the electronic device can display the interface of the first application in a timely manner, thereby improving the user experience.
[0198] S444: The view module may transmit the third canvas pointer to the window manager.
[0199] S445: The window manager may transmit the third canvas pointer to the synthesis module.
[0200] Among them, the specific implementation principle of S443-S445 is similar to the specific implementation principle of S401-S403, and will not be repeated here.
[0201] S446: When the third canvas pointer is obtained, the synthesis module may determine whether the canvas name of the first application is a preset name.
[0202] When the canvas name of the first application is a preset name, the synthesis module may determine whether there is a spare pointer.
[0203] In the case where a spare pointer exists, the synthesis module may determine whether the third canvas parameter is the same as the parameter of the spare pointer.
[0204] When it is determined that the third canvas parameter is the same as the parameter of the standby pointer, the synthesis module may use the parameter of the standby pointer to assign a value to the third canvas pointer so that the third canvas pointer points to the first canvas. The synthesis module may also maintain the identifier of the first flag as a second identifier. The second identifier may indicate that the canvas of the first application (such as the first canvas) is an old canvas. The second identifier may be true.
[0205] S447: The first application may transmit the assigned third canvas pointer to the view module.
[0206] It is understandable that when the synthesis module assigns a value to the third canvas pointer, the first application can obtain a callback function, which can include the value assigned to the third canvas pointer by the synthesis module, and then the first application can obtain the third canvas pointer after the assignment.
[0207] S448. The view module may transmit the assigned third canvas pointer to the rendering module.
[0208] S449. When the third canvas pointer after the assignment is obtained, the rendering module can determine whether the canvas name of the first application is a preset name. When it is determined that the canvas name of the first application is a preset name, the rendering module reads the identifier of the first flag. When the second identifier is read, the electronic device can execute S452 based on the third canvas pointer. Reading the second identifier can indicate that the buffer associated with the canvas of the first application has been applied for.
[0209] S450: The first application may transmit a third drawing instruction to the view module.
[0210] The third drawing instruction may include a third drawing parameter. The third drawing parameter may include a view position of the first application and a view content of the first application, etc. The third drawing parameter may be the same as the first drawing parameter.
[0211] The specific implementation principle of this step is similar to that of S409 and will not be repeated here.
[0212] Optionally, S450 and S447 may be executed concurrently. S450 and S447 may also be executed sequentially. For example, after S447 is executed, S450 may be executed.
[0213] S451: The view module may transmit a third drawing instruction to the rendering module.
[0214] S452: When the third drawing instruction is obtained, the rendering module may use the third drawing parameter to draw and render the image of the first application in the buffer associated with the first canvas pointed to by the third canvas pointer.
[0215] S453: When the rendering module completes drawing and rendering of the image of the first application, the rendering module may transmit information indicating that drawing of the image of the first application is completed to the synthesis module.
[0216] S454: When obtaining information indicating that the image drawing of the first application is completed, the synthesis module can synthesize and display the image of the first application drawn and rendered by the rendering module. The specific implementation principle of this step can refer to the specific implementation principle of S413, which will not be repeated here.
[0217] S455: The electronic device may receive an operation to cause the first application to exit the foreground, and the first application exits the foreground and runs in the background.
[0218] Still taking the first application as a desktop application as an example, the operation to make the first application exit the foreground is, for example, a touch operation on an application icon on the desktop application interface.
[0219] It can be understood that, when the electronic device receives an operation that causes the first application to exit the foreground, the first application can receive a touch event corresponding to the operation that causes the first application to exit the foreground.
[0220] S456: When the electronic device receives an operation that causes the first application to exit the foreground, the first application may transmit third destruction information to the view module.
[0221] The third destruction information may include the assigned third canvas pointer. The third destruction information may be information indicating the destruction of the canvas of the first application, or information indicating the destruction of the canvas pointed to by the third canvas pointer.
[0222] S457: The view module may transmit the third destruction information to the rendering module.
[0223] S458. When the third destruction information is obtained, the rendering module may cancel the communication connection between the first application and the rendering module. Based on the assigned third canvas pointer, when it is determined that the first canvas is pointed to by the standby pointer, the rendering module may not release the buffer associated with the first canvas. The first canvas being pointed to by the standby pointer may be referred to as: the first canvas is referenced by the standby pointer.
[0224] The specific implementation principle and technical effect of this step are similar to those of S417, and will not be repeated here.
[0225] S459: The rendering module may transmit the third destruction information to the window manager.
[0226] S460: The window manager may transmit third destruction information to the synthesis module.
[0227] S461: When the third destruction information is obtained, the synthesis module may cancel the third canvas pointer pointing to the first canvas, and add the address of the first canvas to the destruction queue. Canceling the third canvas pointer pointing to the first canvas may be referred to as: canceling the reference of the third canvas pointer to the first canvas.
[0228] S462: When it is determined that the first canvas is referenced by the backup pointer, the destroying module does not destroy the first canvas.
[0229] like Figure 4A and Figure 4B As shown, in the module interaction process provided by the embodiment of the present application, when the first application is running in the foreground, the first application can transmit the first canvas pointer to the synthesis module through the view module and the window manager. The first canvas pointer contains the canvas name and the first canvas parameter of the first application. When the synthesis module determines that the canvas name of the first application is a preset name and there is no spare pointer, the synthesis module can create a spare pointer and use the first canvas parameter to create the first canvas of the first application. The synthesis module can point both the first canvas pointer and the spare pointer to the first canvas. The fact that both the first canvas pointer and the spare pointer point to the first canvas can be understood as the first canvas pointer and the spare pointer both refer to the first canvas. The synthesis module can also maintain the identification of the first flag as the first identification indicating that the canvas of the first application is a new canvas. The first application can transmit the first drawing parameter and the assigned first canvas pointer to the rendering module through the view module and the window manager. The first drawing parameter can include the view position of the first application or the view content of the first application, etc. When the rendering module determines that the canvas name of the first application is a preset name, the rendering module can read the identifier of the first flag from the synthesis module, and obtain the number of buffers associated with the first canvas based on the first canvas pointer. When the first identifier is read, the rendering module can apply for the buffer associated with the first canvas according to the number of buffers associated with the first canvas, and use the first drawing parameters to draw and render the image of the first application in the buffer associated with the first canvas. The synthesis module can synthesize and display the image of the first application that has been drawn and rendered.
[0230] When the first application is switched to the background and the second application is running in the foreground, the first application can transmit information indicating the destruction of the canvas of the first application to the rendering module through the view module and the window manager. The rendering module cancels the communication connection between the first application and the rendering module. When the rendering module determines that the first canvas is referenced by the standby pointer, the buffer associated with the first canvas is not released. The rendering module can transmit information indicating the destruction of the canvas of the first application to the synthesis module through the window manager. The synthesis module cancels the reference of the first canvas pointer to the first canvas and adds the address of the first canvas to the destruction queue. When the destruction module determines that the first canvas is applied by the standby pointer, it does not destroy the first canvas. When the first application is switched to the foreground again, the synthesis module does not need to create a canvas for the first application, the rendering module does not need to apply for a buffer for the canvas of the first application, and the rendering module can draw and render the image of the first application in the buffer associated with the canvas of the first application that has not been released. When the synthesis module receives the information transmitted by the rendering module indicating that the image drawing of the first application is completed, the synthesis module synthesizes and displays the image of the first application. In this way, the image of the first application can be displayed in time when the second application exits the foreground, reducing the probability of freeze in the interface display of the first application.
[0231] exist Figure 4B On the basis of Figure 5 Another module interaction flow diagram provided in an embodiment of the present application is shown.
[0232] like Figure 5 As shown, the module interaction process may include:
[0233] S500: The electronic device may receive an operation to enable the first application to run in the foreground, and the first application is switched from the background to the foreground.
[0234] For example, Figure 4B The operation of causing the first application to exit the foreground shown in S455 is: taking a touch operation on the application icon of the third application on the desktop application interface as an example, when the electronic device receives the operation of causing the first application to exit the foreground, the third application can run in the foreground. The third application can be an application market. When the third application runs in the foreground and the interface of the third application is displayed, the user can download the fourth application on the interface of the third application. The electronic device can download the fourth application. The application icon of the fourth application can be deployed on the interface of the first application, so the download of the fourth application will cause the interface of the first application to change.
[0235] When the download of the fourth application is completed, the user can touch the control on the interface of the third application to make the third application exit the foreground. The operation of making the third application exit the foreground is the operation of making the first application run in the foreground.
[0236] It can be understood that, when the electronic device receives an operation to make the first application run in the foreground, the first application can receive a touch event corresponding to the operation to make the first application run in the foreground, and the first application can execute S501.
[0237] S501. The first application may transmit a fourth canvas pointer to the view module.
[0238] The fourth canvas pointer may carry fourth canvas parameters, which may include the canvas name of the first application, the length of the fourth canvas, the width of the fourth canvas, and the like.
[0239] S502: The view module may transmit a fourth canvas pointer to the window manager.
[0240] S503: The window manager may transmit the fourth canvas pointer to the synthesis module.
[0241] Among them, the specific implementation principle of S501-S503 is similar to the specific implementation principle of S401-S403, and will not be repeated here.
[0242] S504: When the fourth canvas pointer is obtained, the synthesis module may determine whether the canvas name of the first application is a preset name.
[0243] When the canvas name of the first application is a preset name, the synthesis module may determine whether there is a spare pointer.
[0244] In the case where a spare pointer exists, the synthesis module may determine whether the fourth canvas parameter is the same as the parameter of the spare pointer.
[0245] When it is determined that the fourth canvas parameter is different from the parameter of the standby pointer, the synthesis module may create the fourth canvas using the fourth canvas parameter and set the standby pointer to zero. Setting the standby pointer to zero may be understood as the standby pointer not pointing to the canvas. Setting the standby pointer to zero, for example, clears the value assigned to the standby pointer. The difference between the fourth canvas parameter and the standby pointer parameter may be caused by a change in the interface of the first application.
[0246] The synthesis module may assign values to the fourth canvas pointer and the spare pointer after being set to zero, so that the fourth canvas pointer and the spare pointer both point to the fourth canvas. The synthesis module may also maintain the identifier of the first flag as the first identifier. The fourth canvas pointer and the spare pointer both point to the fourth canvas, which can be understood as the fourth canvas pointer and the spare pointer both refer to the fourth canvas.
[0247] It is understandable that in this step, after the standby pointer is set to null, the first canvas is not referenced by the pointer. In this way, the destroy module can destroy the first canvas based on the address of the first canvas in the destroy queue, if the first canvas is found and it is determined that the first canvas is not referenced by the pointer.
[0248] S505: The first application may transmit the assigned fourth canvas pointer to the view module.
[0249] It is understandable that when the synthesis module assigns a value to the fourth canvas pointer, the first application can obtain a callback function, which can include the value assigned to the fourth canvas pointer by the synthesis module, and then the first application can obtain the assigned fourth canvas pointer.
[0250] S506: The view module may transmit the assigned fourth canvas pointer to the rendering module.
[0251] S507. When the fourth canvas pointer after the assignment is obtained, the rendering module can determine whether the canvas name of the first application is a preset name. When it is determined that the canvas name of the first application is a preset name, the rendering module reads the identifier of the first flag. If the first identifier is read, it can indicate that the buffer associated with the canvas of the first application has not been applied for. The rendering module can obtain the number of buffers associated with the fourth canvas from the synthesis module based on the fourth canvas pointer after the assignment, so as to apply for the buffer associated with the fourth canvas.
[0252] S508: The rendering module may use the number of buffers associated with the fourth canvas to apply for buffers associated with the fourth canvas.
[0253] S509: The first application may transmit a fourth drawing instruction to the view module.
[0254] The fourth drawing instruction may include a fourth drawing parameter. The fourth drawing parameter may include a view position of the first application and a view content of the first application.
[0255] The specific implementation principle of this step is similar to that of S409 and will not be repeated here.
[0256] Optionally, S509 and S505 may be executed concurrently. S509 and S505 may also be executed sequentially. For example, after S505 is executed, S509 may be executed.
[0257] S510: The view module may transmit a fourth drawing instruction to the rendering module.
[0258] S511: When a fourth drawing instruction is obtained, the rendering module may use a fourth drawing parameter to draw and render the image of the first application in a buffer associated with a fourth canvas.
[0259] S512: When the rendering module completes drawing and rendering of the image of the first application, the rendering module may transmit information indicating that drawing of the image of the first application is completed to the synthesis module.
[0260] S513: When obtaining information indicating that the image drawing of the first application is completed, the synthesis module may synthesize and display the image of the first application drawn and rendered by the rendering module.
[0261] The specific implementation principle of this step is similar to that of S413 and will not be repeated here.
[0262] S514: The electronic device may receive an operation to start a fourth application, and the first application exits the foreground and runs in the background.
[0263] Exemplarily, taking the first application as a desktop application as an example, the operation of starting the fourth application is, for example: a user touches the application icon of the fourth application on the interface of the desktop application.
[0264] S515: When the electronic device receives an operation to start a fourth application, the first application may transmit fourth destruction information to the view module.
[0265] The fourth destruction information may include the fourth canvas pointer after the assignment. The fourth destruction information may be information indicating the destruction of the canvas of the first application, or information indicating the destruction of the canvas pointed to by the fourth canvas pointer. The canvas pointed to by the fourth canvas pointer may be referred to as: the canvas referenced by the fourth canvas pointer.
[0266] S516: The view module may transmit fourth destruction information to the rendering module.
[0267] S517: When receiving the fourth destruction information, the rendering module may cancel the communication connection between the first application and the rendering module. Based on the assigned fourth canvas pointer, when it is determined that the fourth canvas is pointed to by the standby pointer, the rendering module may not release the buffer associated with the fourth canvas. The fourth canvas being pointed to by the standby pointer may be referred to as: the fourth canvas is referenced by the standby pointer.
[0268] The specific implementation principle and technical effect of the rendering module not releasing the buffer associated with the fourth canvas in this step are similar to those of S417, and will not be described in detail here.
[0269] It is understandable that, taking the example of the standby pointer before being set to null in S504 referencing the first canvas, in this step, when it is determined that the first canvas is not referenced by the pointer, the rendering module can release the buffer associated with the first canvas. In this way, the memory usage of the electronic device can be reduced.
[0270] Optionally, when the destruction module destroys the first canvas, the destruction module may transmit information indicating that the first canvas is destroyed to the rendering module. When receiving the information indicating that the first canvas is destroyed, the rendering module may release the buffer associated with the first canvas.
[0271] S518: The rendering module may transmit fourth destruction information to the window manager.
[0272] S519: The window manager may transmit fourth destruction information to the synthesis module.
[0273] S520: When the fourth destruction information is obtained, the synthesis module may cancel the reference of the fourth canvas pointer to the fourth canvas, and add the address of the fourth canvas to the destruction queue.
[0274] S521: When it is determined that the fourth canvas is referenced by the backup pointer, the destroying module may not destroy the fourth canvas.
[0275] Exemplarily, the destruction module may periodically find the canvas corresponding to the address in the destruction queue based on the address in the destruction queue, and when it is determined that the found canvas is not referenced by the pointer, destroy the canvas not applied by the pointer. When it is determined that the found canvas is referenced by the pointer, the canvas applied by the pointer is not destroyed.
[0276] Exemplarily, taking the case where the standby pointer points to the first canvas before being set to zero in S504, in this step, when the first canvas is found based on the address of the first canvas in the destruction queue and it is determined that the first canvas is not referenced by the pointer, the destruction module can destroy the first canvas and transmit information indicating that the first canvas is destroyed to the rendering module.
[0277] In the module interaction process provided by the embodiment of the present application, when the first application switches from the background to the foreground, if the synthesis module determines that the canvas name of the first application in the fourth canvas pointer is a preset name, and the fourth canvas parameter in the fourth canvas pointer is different from the parameter of the standby pointer, indicating that the interface of the first application has changed, the synthesis module can use the fourth canvas parameter to create a fourth canvas for the first application and set the standby pointer to zero.
[0278] The synthesis module may assign values to the fourth canvas pointer and the spare pointer after being set to zero, so that the fourth canvas pointer and the spare pointer both point to the fourth canvas. The synthesis module may also maintain the identification of the first flag as the first identification indicating that the canvas of the first application is a new canvas. The first application may transmit the fourth drawing instruction and the fourth canvas pointer after the assignment to the rendering module through the view module and the window manager. The fourth drawing instruction may include a fourth drawing parameter. The fourth drawing parameter may include the view position of the first application or the view content of the first application, etc. When the rendering module determines that the canvas name of the first application is a preset name, the rendering module may read the identification of the first flag from the synthesis module, and obtain the number of buffers associated with the fourth canvas based on the first canvas pointer. When the first identification is read, the rendering module may apply for the buffer associated with the fourth canvas according to the number of buffers associated with the fourth canvas, and use the fourth drawing parameter to draw and render the image of the first application in the buffer associated with the fourth canvas. The synthesis module may synthesize and display the image of the first application that has been drawn and rendered. Among them, when the interface of the first application changes, creating a new canvas (such as the fourth canvas) for the first application and applying for a buffer associated with the new canvas can reduce the probability that the canvas of the first application does not meet the drawing and rendering requirements of the first application's image. Setting the standby pointer to null can destroy the canvas pointed to before the standby pointer is set to null, and release the buffer associated with the canvas pointed to before the standby pointer is set to null, reducing the memory usage of the electronic device.
[0279] When the first application switches to background operation, the first application can transmit information indicating the destruction of the canvas of the first application to the rendering module through the view module and the window manager. The rendering module cancels the communication connection between the first application and the rendering module. When the rendering module determines that the fourth canvas is referenced by the standby pointer, the fourth canvas associated buffer is not released. When the first canvas is determined not to be referenced by the pointer or when receiving information indicating that the first canvas is destroyed, the buffer associated with the first canvas can be released. The rendering module can transmit information indicating the destruction of the canvas of the first application to the synthesis module through the window manager. The synthesis module cancels the reference of the fourth canvas pointer to the fourth canvas, and adds the address of the fourth canvas to the destruction queue. The destruction module does not destroy the fourth canvas when it determines that the fourth canvas is used by the standby pointer. In this way, when the first application is switched back to the foreground, the synthesis module does not need to create a canvas for the first application, and the rendering module does not need to apply for a buffer for the canvas of the first application. The rendering module can draw and render the image of the first application in the buffer associated with the fourth canvas that has not been released, so that the image of the first application can be displayed in time when the first application is switched back to the foreground, reducing the probability of the interface display of the first application being stuck. The destruction module can destroy the first canvas when it is determined that the first canvas is not used by the pointer application, so as to reduce the memory occupied by the first canvas of the electronic device.
[0280] Combine the following Figure 6 The module interaction process provided in the embodiment of the present application is described. Figure 6 Another module interaction flow diagram provided in an embodiment of the present application is shown.
[0281] Still taking the first application as a desktop application as an example, Figure 6 As shown, the module interaction process may include: S400-S415, S601, S422-436, S602, S438-S456 and S603.
[0282] The specific implementation principles of S400-S415, S422-436, and S438-S456 can all be found in Figure 4A and Figure 4B The specific implementation principle shown will not be repeated here.
[0283] S601: When receiving the first destruction information, the view module may determine whether the canvas name of the first application in the first canvas pointer is a preset name.
[0284] When the canvas name of the first application is a preset name, the view module may not transmit the first destruction information to the rendering module, and stop transmitting the drawing instructions transmitted by the first application to the rendering module, so as to reduce the probability of the electronic device displaying the interface of the first application after the first application exits the foreground. The drawing instructions transmitted by the first application are, for example, the first drawing instructions. The view module not transmitting the first destruction information to the rendering module can be understood as: the view module does not process the first destruction information.
[0285] In the case where the view module does not transmit the first destruction information to the rendering module, the rendering module, the window manager, the synthesis module, the destruction module, etc. may not execute the process of destroying the canvas of the first application and the process of releasing the buffer associated with the canvas of the first application based on the first destruction information. In this way, the power consumption of the electronic device can be reduced.
[0286] S602: When receiving the second destruction information, the view module may determine whether the canvas name of the second application in the second canvas pointer is a preset name. If the canvas name of the second application is not a preset name, the view module may transmit the second destruction information to the rendering module.
[0287] S603: When receiving the third destruction information, the view module may determine whether the canvas name of the first application in the third canvas pointer is a preset name. When the canvas name of the first application is the preset name, the view module may not transmit the third destruction information to the rendering module, and stop transmitting the drawing instruction (such as the third drawing instruction) transmitted by the first application to the rendering module.
[0288] like Figure 6As shown, in the module interaction process provided by the embodiment of the present application, when the first application is running in the foreground, the first application can transmit the first canvas pointer to the synthesis module through the view module and the window manager. When the synthesis module determines that the canvas name of the first application is a preset name and there is no spare pointer, the synthesis module can create a spare pointer and use the first canvas parameter to create the first canvas of the first application. The synthesis module can point both the first canvas pointer and the spare pointer to the first canvas. The synthesis module can also maintain the identification of the first flag bit as the first identification indicating that the canvas of the first application is a new canvas. The first application can transmit the first drawing instruction and the assigned first canvas pointer to the rendering module through the view module and the window manager. The first drawing instruction may include the first drawing parameter. The first drawing parameter may include the view position of the first application or the view content of the first application, etc. When the rendering module determines that the canvas name of the first application is a preset name, the rendering module can read the identification of the first flag bit from the synthesis module and obtain the number of buffers associated with the first canvas based on the first canvas pointer. When the first identifier is read, the rendering module may apply for the buffer associated with the first canvas according to the number of buffers associated with the first canvas, and use the first drawing parameters to draw and render the image of the first application in the buffer associated with the first canvas. The synthesis module may synthesize and display the image of the first application that has been drawn and rendered.
[0289] When the first application is switched to the background and the second application is running in the foreground, the first application can transmit information indicating the destruction of the canvas of the first application to the view module. When the view module determines that the canvas name of the first application is a preset name, it stops transmitting the drawing instructions transmitted by the first application to the rendering module, and does not transmit information indicating the destruction of the canvas of the first application to the rendering module. In this way, the electronic device does not execute the process of destroying the first canvas, nor does it execute the process of releasing the buffer associated with the first canvas. When the first application is switched to the foreground again, the synthesis module does not need to create a canvas for the first application, the rendering module does not need to apply for a buffer for the canvas of the first application, and the rendering module can draw and render the image of the first application in the buffer associated with the canvas of the first application that has not been released. When the synthesis module receives the information transmitted by the rendering module indicating that the image drawing of the first application is completed, the synthesis module synthesizes and displays the image of the first application. In this way, the image of the first application can be displayed in time when the second application exits the foreground, reducing the probability of the interface display of the first application being stuck.
[0290] Figure 7 Another module interaction flow diagram provided in an embodiment of the present application is shown.
[0291] exist Figure 6 On the basis of Figure 7 As shown, the module interaction process may include: S700-S704, S505-S515, S705 and S706.
[0292] The specific implementation principles and technical effects of S700-S703 are similar to those of S500-S503. The specific implementation principles and technical effects of S500-S503, as well as the specific implementation principles and technical effects of S505-S515, can be found in Figure 5 The specific implementation principles and technical effects shown will not be repeated here.
[0293] S700: The electronic device may receive an operation to cause the first application to run in the foreground, and the first application is switched from the background to the foreground.
[0294] S701. The first application may transmit a fourth canvas pointer to the view module.
[0295] S702: The view module may transmit a fourth canvas pointer to the window manager.
[0296] S703: The window manager may transmit the fourth canvas pointer to the synthesis module.
[0297] S704: When the fourth canvas pointer is obtained, the synthesis module may determine whether the canvas name of the first application is a preset name.
[0298] When the canvas name of the first application is a preset name, the synthesis module may determine whether there is a spare pointer.
[0299] In the case where a spare pointer exists, the synthesis module may determine whether the fourth canvas parameter is the same as the parameter of the spare pointer.
[0300] When it is determined that the fourth canvas parameter is different from the parameter of the standby pointer, the synthesis module may create the fourth canvas using the fourth canvas parameter and set the standby pointer to 0. Setting the standby pointer to 0 means, for example, clearing the value assigned to the standby pointer.
[0301] The synthesis module may assign values to the fourth canvas pointer and the empty spare pointer, so that both the fourth canvas pointer and the spare pointer point to the fourth canvas. The synthesis module may also maintain the identifier of the first flag bit as the first identifier.
[0302] It can be understood that, in this step, in order to realize that each application corresponds to a valid canvas pointer, when the synthesis module assigns a value to the fourth canvas pointer, the synthesis module can cancel the reference of the third canvas pointer to the first canvas or clear the third canvas pointer, and add the address of the first canvas to the destruction queue. In addition, after the standby pointer is set to null, the first canvas is not referenced by the pointer. In this way, the destruction module can execute S706.
[0303] S705: When receiving the fourth destruction information, the view module may determine whether the canvas name of the first application in the fourth canvas pointer is a preset name. When the canvas name of the first application is the preset name, the view module may not transmit the fourth destruction information to the rendering module, and stop transmitting the drawing instructions transmitted by the first application to the rendering module.
[0304] S706: The destroying module may destroy the first canvas if it is determined that the first canvas is not used by the pointer, so as to reduce the occupation of the first canvas on the memory of the electronic device.
[0305] When the destruction module destroys the first canvas, the destruction module may transmit information indicating that the first canvas is destroyed to the rendering module. When receiving the information indicating that the first canvas is destroyed, the rendering module may release the buffer associated with the first canvas.
[0306] In the module interaction process provided by the embodiment of the present application, when the first application switches from the background to the foreground, if the synthesis module determines that the canvas name of the first application in the fourth canvas pointer is a preset name, and the fourth canvas parameter in the fourth canvas pointer is different from the parameter of the standby pointer, the synthesis module can use the fourth canvas parameter to create a fourth canvas for the first application, set the standby pointer to zero, and cancel the third canvas pointer pointing to the first canvas.
[0307] The synthesis module can assign values to the fourth canvas pointer and the spare pointer after being set to zero, so that the fourth canvas pointer and the spare pointer both point to the fourth canvas. The synthesis module can also maintain the identification of the first flag as the first identification indicating that the canvas of the first application is a new canvas. The first application can transmit the fourth drawing instruction and the fourth canvas pointer after the assignment to the rendering module through the view module and the window manager. In the case where the rendering module determines that the canvas name of the first application is a preset name, the rendering module can read the identification of the first flag from the synthesis module, and obtain the number of buffers associated with the fourth canvas based on the first canvas pointer. In the case of reading the first identification, the rendering module can apply for the buffer associated with the fourth canvas according to the number of buffers associated with the fourth canvas, and use the fourth drawing parameters to draw and render the image of the first application in the buffer associated with the fourth canvas. The synthesis module can synthesize and display the image of the first application that has been drawn and rendered. Among them, the standby pointer is set to null and the third canvas pointer is cancelled from pointing to the first canvas, so that the first canvas pointed to by the standby pointer before being set to null can be destroyed and the buffer associated with the first canvas can be released, thereby reducing the memory usage of the electronic device.
[0308] When the first application is switched to the background, the first application can transmit information indicating the destruction of the canvas of the first application to the view module. When the view module determines that the canvas name of the first application is a preset name, it stops transmitting the drawing instructions transmitted by the first application to the rendering module, and does not transmit information indicating the destruction of the canvas of the first application to the rendering module. In this way, the electronic device does not execute the process of destroying the first canvas, nor does it execute the process of releasing the buffer associated with the first canvas. When the first application is switched to the foreground again, the synthesis module does not need to create a canvas for the first application, and the rendering module does not need to apply for a buffer for the canvas of the first application. The rendering module can draw and render the image of the first application in the buffer associated with the canvas of the first application that has not been released. When the synthesis module receives the information transmitted by the rendering module indicating that the image drawing of the first application is completed, the synthesis module synthesizes and displays the image of the first application. In this way, the image of the first application can be displayed in time when the first application is switched to the foreground again, reducing the probability of the interface display of the first application being stuck.
[0309] It can be understood that the application management method provided in the embodiment of the present application will destroy the canvas of the stopped application and release the buffer associated with the canvas of the stopped application, and clear the pointer associated with the stopped application when the application on the electronic device stops running.
[0310] The present application also provides an application management method, which may include:
[0311] When the first application is running in the foreground, a first canvas of the first application is created and at least one first buffer associated with the first canvas is applied; the first buffer is used to store images of the first application;
[0312] When the first application is switched to the background and the second application is running in the foreground, a second canvas of the second application is created and at least one second buffer associated with the second canvas is requested; the second buffer is used to store the image of the second application; the first canvas is not destroyed and at least one first buffer is not released;
[0313] When the first application is switched to run in the foreground again, the image of the first application is drawn in the at least one first buffer that has not been released.
[0314] For example, Figure 4A As shown in S400-S413, when an operation is received to make the first application run in the foreground, when the first application runs in the foreground, the electronic device creates a first canvas of the first application, and uses the number of buffers associated with the first canvas to apply for a buffer associated with the first canvas. The buffer associated with the first canvas applied for is at least one first buffer zone associated with the first canvas.
[0315] like Figure 4A As shown in S414-S434, when the operation of starting the second application is received, when the first application is switched to the background and the second application is running in the foreground, the electronic device creates a second canvas of the second application, and uses the number of buffers associated with the second canvas to apply for a buffer associated with the second canvas. The buffer associated with the second canvas applied for is at least one second buffer associated with the second canvas; because the first canvas is referenced by the standby pointer, the second canvas is not destroyed and at least one first buffer associated with the second canvas is not released.
[0316] like Figure 4B In S443-S454, when receiving an operation to cause the second application to exit the foreground, when the first application is switched to the foreground again, the electronic device may draw the image of the first application in at least one first buffer that has not been released. Figure 4B As shown in S435-S442, when an operation is received to cause the second application to exit the foreground, the second canvas may be destroyed and at least one second buffer associated with the second canvas may be released, thereby reducing the memory occupied by the second canvas and the second buffer of the second application.
[0317] Optionally, for a scenario where the memory of the electronic device is large, when an operation to start the second application is received, when the first application switches to the background and the second application runs in the foreground, the electronic device can create a spare pointer for the second application when creating the second canvas of the second application, and point the spare pointer to the second canvas, so that when an operation to cause the second application to exit the foreground is received, the second canvas is not destroyed, and at least one second buffer associated with the second canvas is not released. In this way, when the second application switches from the background to the foreground, the electronic device can display the interface of the second application in a timely manner, thereby improving the user experience.
[0318] The application management method provided in the embodiment of the present application creates a first canvas and applies for at least one first buffer associated with the first canvas when the first application is running in the foreground. The electronic device can draw and render the image of the first application in the at least one first buffer so that the electronic device displays the interface of the first application. When the second application is running in the foreground and the first application is running in the background, the canvas of the first application is not destroyed, and at least one first buffer is not released, so that when the first application is switched to run in the foreground again, the electronic device does not need to create a canvas for the first application again, nor does it need to apply for an associated buffer for the canvas of the first application again. The electronic device can draw and render in at least one first buffer that has not been released, so that the electronic device can display the interface of the first application in a timely manner. In this way, the probability of the interface display of the first application being stuck when the first application enters the foreground from the background can be reduced.
[0319] Optionally, when the first application is running in the foreground, the method further includes:
[0320] A first canvas pointer of a first application is obtained, where the first canvas pointer includes a first canvas parameter.
[0321] A backup pointer is created based on the first canvas parameter, wherein both the first canvas pointer and the backup pointer point to the first canvas.
[0322] Exemplarily, when obtaining the first canvas pointer of the first application, the electronic device can use the first canvas parameters to create a backup pointer for the first application, so that when the first application runs in the background, the canvas of the first application is not destroyed and the buffer associated with the canvas of the first application is not released, so that the interface of the first application can be displayed in time when the first application switches from the background to the foreground, reducing the probability of lag in the interface display of the first application.
[0323] It can be understood that when an electronic device obtains the canvas pointer of any application, the electronic device can use the canvas parameters carried in the canvas pointer of any application to create a backup pointer, so that when any application runs in the background, the canvas of any application is not destroyed, and the buffer associated with the canvas of any application is not released, so that when any application is switched from the background to the foreground, the interface of any application can be displayed in time, reducing the probability of freeze in the interface display of any application.
[0324] Optionally, the first canvas parameter includes a canvas identifier of the first application. Creating a standby pointer based on the first canvas parameter includes:
[0325] When the canvas identifier of the first application is a preset identifier, a standby pointer is created based on the first canvas parameters.
[0326] The first-use canvas identifier may be the first-use canvas name, and the preset identifier may be a preset name.
[0327] In this way, applications that frequently switch between the foreground and the background can be identified through a preset identifier. The canvas identifier of the first application is a preset identifier, which can indicate that the first application is an application that frequently switches between the foreground and the background, and a backup pointer can be created for the canvas of the first application, so that when the first application exits the foreground and runs in the background, the first canvas is not destroyed, and the buffer associated with the first canvas is not released. If it is identified based on the preset identifier that the application that exits the foreground is not an application that frequently switches between the foreground and the background, when the application that does not frequently switch between the foreground and the background exits the foreground, the canvas corresponding to the application that does not frequently switch between the foreground and the background can be destroyed and the buffer associated with the corresponding canvas can be released to reduce the memory usage of the electronic device.
[0328] Optionally, when the first application is switched to run in the background and the second application is run in the foreground, the method further includes:
[0329] Cancel the first canvas pointer pointing to the first canvas, and add the address of the first canvas to the destruction queue.
[0330] When it is determined that the first canvas is pointed to by the standby pointer, the first canvas is not destroyed.
[0331] In this way, by determining that the first canvas is pointed to by the standby pointer, it indicates that the application corresponding to the first canvas is an application that switches frequently between the foreground and the background, and the first canvas need not be destroyed. When the application corresponding to the first canvas switches to the foreground, the image can be drawn and rendered in the buffer associated with the first canvas, so that the electronic device can display the interface of the application corresponding to the first canvas in a timely manner, reducing the probability of freezes in the interface display of the application corresponding to the first canvas.
[0332] Optionally, before canceling the first canvas pointer pointing to the first canvas, the method further includes:
[0333] When it is determined that the first canvas is pointed to by the standby pointer, at least one first buffer associated with the first canvas is not released.
[0334] In this way, by determining that the first canvas is pointed to by the standby pointer, it indicates that the application corresponding to the first canvas is an application that switches frequently between the foreground and the background, and at least one first buffer associated with the first canvas may not be released, so that when the application corresponding to the first canvas is switched to the foreground, the image can be drawn and rendered in the at least one first buffer, so that the electronic device can display the interface of the application corresponding to the first canvas in a timely manner, reducing the probability of freeze in the interface display of the application corresponding to the first canvas.
[0335] Optionally, when creating the first canvas of the first application, the method further includes:
[0336] The identifier of the first flag bit is maintained as the first identifier, and the first identifier indicates that the canvas of the first application is a new canvas.
[0337] Applying for at least one first buffer associated with the first canvas includes:
[0338] When the first identifier is read, at least one first buffer associated with the first canvas is requested.
[0339] In this way, if the first identifier is read, it means that the buffer associated with the canvas of the first application has not been applied for, and at least one first buffer associated with the first canvas can be applied for, so that the electronic device can draw and render the image of the first application in the at least one first buffer, so that the electronic device can display the interface of the first application.
[0340] Optionally, when the first application is switched back to run in the foreground, the method further includes:
[0341] A third canvas pointer of the first application is obtained, where the third canvas pointer includes a third canvas parameter.
[0342] When the parameter of the standby pointer is the same as the parameter of the third canvas, the parameter of the standby pointer is used to assign a value to the third canvas pointer, so that the third canvas pointer points to the first canvas.
[0343] In this way, if the parameters of the standby pointer are the same as the parameters of the third canvas, it can be said that the canvas pointed to by the standby pointer meets the requirements of the third canvas parameters. There is no need to create a canvas for the first application again. The parameters of the standby pointer are used to assign values to the third canvas pointer so that the third canvas pointer points to the first canvas, so that the electronic device can find the first canvas based on the assigned third canvas pointer and draw the image of the first application in the buffer associated with the first canvas, so that the electronic device can display the interface of the first application in a timely manner.
[0344] Optionally, when the parameter of the standby pointer is used to assign a value to the third canvas pointer, the method further includes: maintaining the identifier of the first flag bit as a second identifier, the second identifier indicating that the canvas of the first application is an old canvas.
[0345] After maintaining the identifier of the first flag bit as the second identifier, the method further includes:
[0346] When the second identifier is read, the process of applying for the buffer associated with the canvas of the first application is not executed.
[0347] In this way, if the second identifier is read, it can indicate that the buffer associated with the canvas of the first application has been applied for, and there is no need to apply for the buffer associated with the canvas of the first application again, and there is no need to execute the process of applying for the buffer associated with the canvas of the first application, which can reduce the power consumption of the electronic device and facilitate the electronic device to find the first canvas in time based on the assigned third canvas pointer, and draw the image of the first application in the buffer associated with the first canvas, so that the electronic device can display the interface of the first application in time.
[0348] Optionally, the method further comprises:
[0349] When the first application is switched to the background and the third application is running in the foreground, a third canvas of the third application is created and at least one third buffer associated with the third canvas is applied. The third buffer is used to store the image of the third application. The first canvas is not destroyed and at least one first buffer is not released.
[0350] An operation to download a fourth application is received, and the fourth application is downloaded. The download of the fourth application causes the interface of the first application to change.
[0351] When the first application is switched to run in the foreground again, a fourth canvas of the first application is created and at least one fourth buffer associated with the fourth canvas is applied for. The fourth buffer is used to store the image of the first application.
[0352] The specific implementation principle of the embodiment of this application can be found in Figure 5 The specific implementation principle of the embodiment.
[0353] In this way, when the interface of the first application changes and the first application is switched to the foreground again, a new canvas (such as the fourth canvas) is recreated for the first application and a buffer associated with the new canvas (such as at least one fourth buffer) is applied for, which can reduce the probability that the canvas of the first application does not meet the drawing and rendering requirements of the image of the first application.
[0354] Optionally, when the first application is switched to run in the foreground again, the method further includes:
[0355] A fourth canvas pointer of the first application is obtained, where the fourth canvas pointer includes fourth canvas parameters.
[0356] When the parameters of the standby pointer are different from the fourth canvas parameters, the fourth canvas of the first application is created using the fourth canvas parameters, and the standby pointer is set to zero to obtain a zeroed standby pointer that does not point to the canvas.
[0357] Assign values to the fourth canvas pointer and the spare pointer that has been set to zero, so that both the fourth canvas pointer and the spare pointer point to the fourth canvas.
[0358] In this way, when the first application runs in the background again, the fourth canvas will not be destroyed and the buffer associated with the fourth canvas will not be released, so that when the first application switches from the background to the foreground again, the electronic device does not need to create a new canvas for the first application again, nor does it need to apply for the buffer associated with the canvas of the first application again, so that the electronic device can display the interface of the first application in a timely manner and reduce the probability of freezes in the interface display of the first application.
[0359] Optionally, the method further comprises:
[0360] When the standby pointer points to the fourth canvas, it is determined that the first canvas is not pointed to by the pointer, the first canvas is destroyed, and at least one first buffer associated with the first canvas is released.
[0361] In this way, the occupation of the electronic device memory by the unnecessary first canvas and the buffer associated with the first canvas can be reduced.
[0362] Optionally, when the first application is switched to run in the background and the second application is run in the foreground, the method further includes:
[0363] A second canvas pointer of the second application is obtained, wherein the second canvas pointer includes a second canvas parameter, and the second canvas parameter includes a canvas identifier of the second application, wherein the canvas identifier of the second application may be a canvas name of the second application.
[0364] Create a second canvas for the second application, including:
[0365] When the canvas identifier of the second application is not a preset identifier, a second canvas is created based on the second canvas parameters. The second canvas pointer points to the second canvas.
[0366] In this way, the canvas identifier of the second application is not a preset identifier, which can indicate that the second application is not an application that frequently switches between the foreground and the background. No backup pointer is created for the second application, so that the canvas of the second application is destroyed and the buffer associated with the canvas of the second application is released when the second application exits the foreground, so as to reduce the memory usage of the electronic device.
[0367] Optionally, when the first application is switched back to run in the foreground, the method further includes:
[0368] Cancel the second canvas pointer pointing to the second canvas, and add the address of the second canvas to the destruction queue.
[0369] When it is determined that the second canvas is not referenced by the pointer, the second canvas is destroyed.
[0370] In this way, the canvas of the second application can be destroyed when the second application exits the foreground, so as to reduce the memory occupation of the electronic device.
[0371] Optionally, before canceling the second canvas pointer pointing to the second canvas, the method further includes:
[0372] When it is determined that the second canvas is not referenced by the standby pointer, at least one second buffer associated with the second canvas is released.
[0373] In this way, when the second application exits the foreground, the buffer associated with the canvas of the second application can be released, so as to reduce the memory occupation of the electronic device.
[0374] Optionally, the first canvas parameter includes a canvas identifier of the first application. When the first application is switched to run in the background and the second application is run in the foreground, the method further includes:
[0375] When the canvas identifier of the first application is a preset identifier, the process of destroying the first canvas is not executed, and the process of releasing at least one first buffer associated with the first canvas is not executed.
[0376] The specific implementation principle of the embodiment of this application can be found in Figure 6 The specific implementation principle shown.
[0377] In this way, when the canvas identifier of the first application is the preset identifier, the process of destroying the first canvas is not executed, and the process of releasing at least one first buffer associated with the first canvas is not executed, so that when the first application is running in the background, the canvas of the first application is not destroyed, and the buffer associated with the canvas of the first application is not released, so that when the first application switches from the background to the foreground, the electronic device can display the interface of the first application in time, reducing the probability of the interface display of the first application being stuck. Not executing the process of destroying the first canvas and not executing the process of releasing at least one first buffer associated with the first canvas can also reduce the power consumption of the electronic device.
[0378] Optionally, when the first application is switched back to run in the foreground, the method further includes:
[0379] If the canvas identifier of the second application is not a preset identifier, a process of destroying the second canvas is executed, and a process of releasing at least one second buffer associated with the second canvas is executed. The canvas identifier of the second application is carried in the second canvas pointer of the second application.
[0380] The specific implementation principle of the embodiment of this application can be found in Figure 6 The specific implementation principle shown.
[0381] In this way, the canvas identifier of the second application is not a preset identifier, indicating that the second application is not an application that frequently switches between the foreground and the background. When the first application switches to the foreground again and the second application exits the foreground, the process of destroying the second canvas is executed, and the process of releasing at least one second buffer associated with the second canvas is executed. This can achieve the situation where the canvas of the second application is destroyed and the buffer associated with the canvas of the second application is released when the second application is running in the background, so as to reduce the memory usage of the electronic device.
[0382] Optionally, the first application is a desktop application.
[0383] It should be noted that the module names involved in the embodiments of the present application can be defined as other names as long as the functions of each module can be achieved, and there is no specific restriction on the names of the modules.
[0384] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0385] The application management method of the embodiment of the present application has been described above, and the device for executing the above method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the relevant device provided by the embodiment of the present application can execute the steps in the above application management method.
[0386] The application management method provided in the embodiment of the present application can be applied to electronic devices with communication functions. The electronic devices include terminal devices, and the specific device form of the terminal devices can refer to the above related descriptions, which will not be repeated here.
[0387] The embodiment of the present application provides an electronic device, the electronic device includes: one or more processors and a memory. The memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the above method. Its implementation principle and technical effect are similar to those of the above-mentioned related embodiments, and will not be repeated here.
[0388] The embodiment of the present application provides a chip system, which is applied to electronic devices, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.
[0389] Figure 8 A schematic diagram of the chip system structure provided in an embodiment of the present application is shown.
[0390] like Figure 8 As shown, the embodiment of the present application provides a chip system, the chip system includes at least one processor 81 and a communication interface 83, the communication interface 83 and the at least one processor 81 are interconnected through a line, and the at least one processor 81 is used to run a computer program or instruction to execute the above method. Its implementation principle and technical effect are similar to those of the above-mentioned related embodiments, and will not be repeated here.
[0391] Exemplarily, at least one processor 81 is used to call and run the computer program or instruction in the memory 84 to execute the above method. The communication interface 83 and the at least one processor 81 may be interconnected via a bus 82 .
[0392] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. The above method is implemented when the computer program is executed by the processor. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.
[0393] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the required program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave) is used to transmit software from a website, server or other remote source, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVD), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer-readable media.
[0394] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.
[0395] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0396] The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.
Claims
1. An application management method, characterized in that: include: When the first application is running in the foreground, creating a first canvas of the first application and applying for at least one first buffer associated with the first canvas; The first buffer is used to store the image of the first application; When the first application is switched to the background and the second application is running in the foreground, a second canvas of the second application is created and at least one second buffer associated with the second canvas is requested; the second buffer is used to store the image of the second application; the first canvas is not destroyed and the at least one first buffer is not released; When the first application is switched to run in the foreground again, the image of the first application is drawn in the at least one first buffer that has not been released.
2. The method according to claim 1, characterized in that When the first application is running in the foreground, the method further includes: Obtaining a first canvas pointer of the first application, where the first canvas pointer includes a first canvas parameter; A backup pointer is created based on the first canvas parameter; wherein the first canvas pointer and the backup pointer both point to the first canvas.
3. The method according to claim 2, characterized in that The first canvas parameter includes a canvas identifier of the first application; and the step of creating a standby pointer based on the first canvas parameter includes: When the canvas identifier of the first application is a preset identifier, a standby pointer is created based on the first canvas parameters.
4. The method according to any one of claims 2 to 3, characterized in that: When the first application is switched to run in the background and the second application is run in the foreground, the method further includes: cancel the first canvas pointer pointing to the first canvas, and add the address of the first canvas to a destruction queue; When it is determined that the first canvas is pointed to by the standby pointer, the first canvas is not destroyed.
5. The method according to claim 4, characterized in that Before canceling the first canvas pointer pointing to the first canvas, the method further includes: When it is determined that the first canvas is pointed to by the standby pointer, at least one first buffer associated with the first canvas is not released.
6. The method according to any one of claims 2 to 5, characterized in that: When creating the first canvas of the first application, the method further includes: Maintaining the identifier of the first flag as a first identifier, wherein the first identifier indicates that the canvas of the first application is a new canvas; The applying for at least one first buffer associated with the first canvas includes: When the first identifier is read, at least one first buffer associated with the first canvas is requested.
7. The method according to any one of claims 2 to 6, characterized in that: When the first application is switched to run in the foreground again, the method further includes: Obtaining a third canvas pointer of the first application, where the third canvas pointer includes a third canvas parameter; In the case that the parameter of the standby pointer is the same as the parameter of the third canvas, the parameter of the standby pointer is used to assign a value to the third canvas pointer, so that the third canvas pointer points to the first canvas.
8. The method according to claim 7, characterized in that When the parameter of the standby pointer is used to assign a value to the third canvas pointer, the method further includes: maintaining an identifier of the first flag bit as a second identifier, wherein the second identifier indicates that the canvas of the first application is an old canvas; After the identifier of maintaining the first flag bit is changed to the second identifier, the method further includes: When the second identifier is read, the process of applying for a buffer associated with the canvas of the first application is not executed.
9. The method according to any one of claims 2 to 8, characterized in that: The method further comprises: When the first application is switched to the background and the third application is running in the foreground, a third canvas of the third application is created and at least one third buffer associated with the third canvas is requested; the third buffer is used to store the image of the third application; the first canvas is not destroyed and the at least one first buffer is not released; receiving an operation to download a fourth application, and downloading the fourth application; the downloading of the fourth application causes the interface of the first application to change; When the first application is switched to run in the foreground again, a fourth canvas of the first application is created and at least one fourth buffer associated with the fourth canvas is applied for; the fourth buffer is used to store the image of the first application.
10. The method according to claim 9, characterized in that When the first application is switched to run in the foreground again, the method further includes: Obtaining a fourth canvas pointer of the first application, where the fourth canvas pointer includes fourth canvas parameters; In the case that the parameters of the standby pointer are different from the fourth canvas parameters, the fourth canvas of the first application is created by using the fourth canvas parameters, and the standby pointer is emptied to obtain a emptied standby pointer; the emptied standby pointer does not point to the canvas; Assign values to the fourth canvas pointer and the spare pointer that is cleared, so that both the fourth canvas pointer and the spare pointer point to the fourth canvas.
11. The method according to claim 10, characterized in that The method further comprises: When the standby pointer points to the fourth canvas, it is determined that the first canvas is not pointed to by the pointer, the first canvas is destroyed, and at least one first buffer associated with the first canvas is released.
12. The method according to any one of claims 2 to 11, characterized in that: When the first application is switched to run in the background and the second application is run in the foreground, the method further includes: Obtaining a second canvas pointer of the second application, where the second canvas pointer includes a second canvas parameter, and the second canvas parameter includes a canvas identifier of the second application; The creating a second canvas of the second application includes: When the canvas identifier of the second application is not a preset identifier, the second canvas is created based on the second canvas parameters; and the second canvas pointer points to the second canvas.
13. The method according to claim 12, characterized in that When the first application is switched to run in the foreground again, the method further includes: cancel the second canvas pointer pointing to the second canvas, and add the address of the second canvas to a destruction queue; When it is determined that the second canvas is not referenced by the pointer, the second canvas is destroyed.
14. The method according to claim 12, characterized in that Before canceling the second canvas pointer pointing to the second canvas, the method further includes: When it is determined that the second canvas is not referenced by the standby pointer, at least one second buffer associated with the second canvas is released.
15. The method according to claim 2 or 3, characterized in that: The first canvas parameter includes a canvas identifier of the first application; When the first application is switched to run in the background and the second application is run in the foreground, the method further includes: When the canvas identifier of the first application is a preset identifier, a process of destroying the first canvas is not performed, and a process of releasing at least one first buffer associated with the first canvas is not performed.
16. The method according to claim 15, characterized in that When the first application is switched to run in the foreground again, the method further includes: When the canvas identifier of the second application is not the preset identifier, a process of destroying the second canvas is executed, and a process of releasing at least one second buffer associated with the second canvas is executed; wherein the canvas identifier of the second application is carried in the second canvas pointer of the second application.
17. The method according to any one of claims 1 to 16, characterized in that The first application is a desktop application.
18. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes the method as described in any one of claims 1 to 17.
19. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 17.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device is caused to perform the method as claimed in any one of claims 1 to 17.
21. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 17.
Citation Information
Patent Citations
Application program switching method and device
CN114942807A
Display method, electronic equipment and storage medium
CN116501210A
Stack management method in interface display and related device
CN116737037A
Interface switching method and electronic equipment
CN117289837A
Tracking and restoring pointer positions among applications
US11221729B1