Application management method and related device

By retaining the canvas and buffer when the desktop application runs in the background, the problem of interface display jamming when the desktop application switches to the foreground is solved, and a smoother interface display is achieved.

CN119271318BActive Publication Date: 2025-09-16HONOR DEVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410027541.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-04
Publication Date
2025-09-16
Estimated Expiration
2044-01-04

AI Technical Summary

Technical Problem

When a desktop application switches from the background to the foreground, the interface display of the electronic device is prone to lag, affecting the user experience.

Method used

When a desktop application switches to the background, its canvas is not destroyed and the buffer is not released. The state of the canvas and buffer is maintained so that the image can be directly drawn and rendered when it is switched back to the foreground, reducing the time consumed in interface display.

Benefits of technology

By maintaining the status of the canvas and buffer, the probability of interface display freezes is reduced, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271318B_ABST
    Figure CN119271318B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides an application management method and related devices, which relate to the field of terminal technology. The method includes: when a 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 a second application is running in the foreground, creating a second canvas of the second application and applying 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 the 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 the at least one first buffer that has not been released. In this way, the probability of the interface display of the first application being stuck can be reduced.
Need to check novelty before this filing date? Find Prior Art

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 have multiple applications installed to provide users with a variety of application services. These multiple applications include desktop applications and other applications. The desktop application interface includes at least one application icon. The application icon can be an icon of another application.

[0003] When a desktop application is running in the foreground, the user can click an application icon on the desktop application interface 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] An 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 a file management application) 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 taken from the start 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, thereby reducing the probability of the desktop application interface display being stuck. 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 the operation that makes the desktop application 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 a first application runs 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 switches to the background and a second application runs 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 switches back to the foreground, the image of the first application is drawn in the 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 scenarios where the electronic device has a large amount of memory, upon receiving an operation to launch a second application, when the first application switches to the background and the second application is running in the foreground, the electronic device can create a backup pointer for the second application when creating a second canvas for the second application, and point the backup pointer to the second canvas. This ensures that upon receiving an operation to cause the second application to exit the foreground, 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 promptly display the interface of the second application, 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 can display 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 the 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 the 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 one 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 first canvas parameters, and creating a backup pointer based on the first canvas parameters. The first canvas pointer and the backup pointer both point to the first canvas.

[0012] For example, when 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 the standby pointer based on the first canvas parameter includes: creating the 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 by 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 one possible implementation, when the first application switches to the background and the second application runs 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 can be kept intact. 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 the 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. Therefore, when the application corresponding to the first canvas switches 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 one 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. Requesting at least one first buffer associated with the first canvas includes: upon reading the first identifier, requesting at least one first buffer associated with the first canvas.

[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 one 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, where the third canvas pointer includes third canvas parameters. If the parameters of the standby pointer are the same as the third canvas parameters, assigning a value to the third canvas pointer using the parameters of the standby 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 one possible implementation, when assigning a value to the third canvas pointer using the spare pointer parameter, the method further includes: maintaining the first flag bit as a second flag, where the second flag indicates that the first application's canvas is an old canvas. After maintaining the first flag bit as the second flag, the method further includes: if the second flag is read, not executing the process of requesting a buffer associated with the first application's canvas.

[0024] In this way, if the second identifier is read, it may 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. This can reduce the power consumption of the electronic device, and it is also convenient for the electronic device to find the first canvas in a timely manner 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.

[0025] In one possible implementation, the method further includes: when the first application switches to the background and the third application runs 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. Upon receiving an operation to download the fourth application, the fourth application is downloaded. The download of the fourth application causes the interface of the first application to change. When the first application switches to the foreground again, a fourth canvas of the first application is created 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 created for the first application and a buffer associated with the new canvas (such as at least one fourth buffer) is requested. This 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 one possible implementation, when the first application is switched to the foreground again, the method further includes: obtaining a fourth canvas pointer of the first application, the fourth canvas pointer including fourth canvas parameters. If the parameters of the standby pointer are different from the fourth canvas parameters, creating a fourth canvas of the first application using the fourth canvas parameters, and setting the standby pointer to NULL to obtain a NULLed standby pointer. The NULLed standby pointer does not point to the canvas. Assigning values ​​to the fourth canvas pointer and the NULLed standby pointer so that both the fourth canvas pointer and the standby pointer 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, reducing the probability of the interface display of the first application being stuck.

[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 memory usage of the electronic device by the unnecessary first canvas and the buffer associated with the first canvas can be reduced.

[0031] In one 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 including second canvas parameters, and the second canvas parameters including a canvas identifier of the second application. Creating a second canvas of the second application includes: if the canvas identifier of the second application is not a preset identifier, creating the second canvas based on the second canvas parameters. 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 one possible implementation, when the first application is switched back to the foreground, the method further includes: canceling the second canvas pointer pointing to the second canvas, adding the address of the second canvas to a destruction queue, and destroying the second canvas if it is determined that the second canvas is not referenced by the pointer.

[0034] In this way, the canvas of the second application can be destroyed when the second application exits the foreground, thereby reducing the memory usage 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 backup pointer, releasing at least one second buffer associated with the second canvas.

[0036] In this way, the buffer associated with the canvas of the second application can be released when the second application exits the foreground, thereby reducing 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. This can ensure 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. Therefore, when the first application switches from the background to the foreground, the electronic device can promptly display the interface of the first application, reducing the probability of lag in the display of the first application interface. 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 one 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 second application is running in the background, destroying the canvas of the second application and releasing the buffer associated with the canvas of the second application, 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 within 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 within 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, embodiments of the present application provide an electronic device, comprising one or more processors and a memory. The memory is coupled to the one or more processors, and is configured to store computer program code, the computer program code comprising computer instructions, and the one or more processors invoke the computer instructions to cause 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 instruction is stored. When the computer program or instruction is 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 comprising a computer program, which, when the computer program runs on a computer, enables the computer to execute the method described in the first aspect or any possible implementation of the first aspect.

[0046] In a sixth aspect, the present application provides a chip or chip system, comprising at least one processor and a communication interface, wherein the communication interface and the at least one processor are interconnected via a line, and the at least one processor is configured to execute a computer program or instruction to perform the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip may be an input / output interface, a pin, or a circuit.

[0047] In one possible implementation, the chip or chip system described above in this application further includes at least one memory, in which instructions are stored. The memory may be a storage unit within 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 in 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 the chip system structure provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] To facilitate a clear description of the technical solutions of the embodiments of the present application, some of the terms and technologies involved in the embodiments of the present application are briefly introduced below:

[0059] 1. Other terms

[0060] In the embodiments of this application, terms such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. For example, the terms "first chip" and "second chip" are used solely to distinguish between different chips and do not define their order. Those skilled in the art will understand that terms such as "first" and "second" do not define the quantity or execution order, and do not necessarily define differences.

[0061] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0062] In the embodiments of the present application, "at least one" refers to one or more, and "more" 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: the existence of A alone, the existence of A and B at the same time, and the existence of B 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 items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.

[0063] 2. Electronic devices

[0064] The electronic devices of the embodiments of the present application may include handheld devices, vehicle-mounted devices, etc. with control functions. For example, some electronic devices include: 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 (PLMNs), and so on. The terminal equipment in the network (PLMN), etc., is not limited to this in the embodiments of the present application.

[0065] As an example and not a 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 achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are fully functional, large in size, and can achieve complete or partial functions without relying on smartphones, such as smart watches or smart glasses, as well as those 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 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 of human-machine interconnection and object-to-object interconnection.

[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 the embodiments 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 memory (also known as main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a 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 by 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 the settings application, an application icon for the calendar application, an application icon 101 for the file management application, an application icon for the WeChat application, an application icon for the notes application, an application icon for the Toutiao application, an application icon for the phone application, an application icon for the camera application, and an application icon for the SMS application.

[0071] exist Figure 1In the interface shown in a in FIG, 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 is received on the application icon 101, the electronic device 100 can display the following Figure 1 The interface of the file management application shown in b in FIG, and the desktop application exits the foreground and runs in the background. Figure 1 The interface shown in b in FIG. 1 includes a status bar, a return control 102, the text "Document", a control indicating search, a sorting indicator and the text "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 named "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 named "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, 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 a 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 may 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 respective 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 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] Since the canvas of the negative-one-screen application and the buffer associated with the canvas of the negative-one-screen application need to be created before the electronic device creates the canvas of the desktop application, the 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 is relatively long, 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, which creates a desktop application canvas and applies for a buffer associated with the desktop application canvas when a desktop application is started and runs in the foreground. When the desktop application switches to run in the background and other applications (such as file management applications) run in the foreground, the desktop application canvas is not destroyed, and the buffer associated with the desktop application canvas is not released. When the desktop application switches to run in the foreground again, the image of the desktop application can be drawn in the buffer associated with the desktop application canvas that has not been released. In this way, the time taken 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 the desktop application interface display being stuck. Among them, the start of the desktop application switching to run in the foreground again can be the moment when the electronic device receives the 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 structural diagram 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 should 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, or may combine or separate certain 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] For example, when a first application is started and runs in the foreground, the processor 210 creates a first canvas for 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, processor 210 creates a second canvas for the second application and requests 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 the at least one first buffer is not released. The second application can be another application. The other application is not a desktop application. The other application can be an application corresponding to any application icon on the desktop application interface.

[0083] When the first application is switched to the foreground again, 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 The image of the interface shown in a.

[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. The image of the first application can be drawn and rendered in the buffer associated with the first canvas created previously. When the second application exits the foreground, the display screen 294 can promptly display the image of the first application, reducing the probability of freezes in the interface display of the first application.

[0085] The software system of the electronic device 200 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate 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] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, 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 applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0090] The application framework layer provides an application programming interface (API) and 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 module (render thread), a synthesis module (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 size, determine whether there is a status bar, lock the screen, take screenshots, 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. 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 and images. The view module can be used to build applications. A display interface can be composed of one or more views. For example, a display interface containing a text notification icon can include a view for displaying text and a view for displaying images. The view module can also be used to transmit application-transmitted information to the window manager.

[0098] The phone manager is used to provide communication functions for electronic devices, such as call status management (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 allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0101] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for scheduling and management of the Android system.

[0102] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0103] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0104] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0105] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.

[0106] For example, when the first application is started and runs in the foreground, the first application can transmit a first canvas pointer to the composition 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 backup pointer, the synthesis module can create a backup pointer and use the first canvas parameters to create the first canvas of the first application. The synthesis module can point both the first canvas pointer and the backup pointer to the first canvas. The fact that both the first canvas pointer and the backup pointer point to the first canvas can be understood as the first canvas pointer and the backup 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 for 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 switches to the background and the second application runs in the foreground, the second application may transmit a second canvas pointer to the composition module via the view module and the window manager. The second canvas pointer includes the second application's canvas name and second canvas parameters. If the composition module determines that the second application's canvas name is not a preset name, the composition module may use the second canvas parameters to create a second canvas for the second application and set the second canvas pointer to point to the second canvas. The second application may obtain the assignment information of the second canvas pointer. The assignment information of the second canvas pointer may be used to indicate that the second canvas pointer points to the second canvas. The second application may transmit the assigned second canvas pointer and second drawing instructions to the rendering module via the view module and the window manager. The second drawing instructions may include second drawing parameters. The second drawing parameters may include the view position or view content of the second application. If the rendering module determines that the second application's canvas name is not a preset name, the rendering module may obtain the number of buffers associated with the second canvas based on the second canvas pointer and apply for a second buffer associated with the second canvas based on 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 switches to the background and the second application runs in the foreground, the first application may transmit information indicating the destruction of the first application's canvas 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. If the rendering module determines that the first canvas is referenced by the backup pointer, it does not release the first buffer associated with the first canvas. The rendering module may transmit information indicating the destruction of the first application's canvas to the compositing module through the window manager. The compositing module cancels the reference to the first canvas by the first canvas pointer and adds the address of the first canvas to the destruction queue. If the destruction module determines that the first canvas is referenced by the backup pointer, it does not destroy the first canvas.

[0111] When the first application is switched back to the foreground, the rendering module draws and renders the image of the first application in the unreleased first buffer. Upon receiving the information transmitted by the rendering module indicating that the image drawing of the first application is complete, the compositing module composes the image of the first application and displays it.

[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 no longer needs to create a canvas for the first application, and the rendering module no longer needs 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 the interface display of the first application being stuck.

[0113] The following combination 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 module interaction flow diagram 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 to enable a 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 first canvas parameters. The first canvas parameters may include the name of the first application's canvas, the length of the first canvas, and the width of the first canvas. It should be understood that the length and width of the canvas may represent the size of the canvas. For example, the length and 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 composition 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 a spare pointer exists.

[0126] If it is determined that there is no backup pointer, the synthesis module may create the first canvas using the first canvas parameters and create the backup pointer using the first canvas parameters. The synthesis module may assign values ​​to the first canvas pointer and the backup pointer so that both point to the first canvas. The synthesis module may also maintain the identifier of the first flag as a first identifier. The first identifier may indicate that the canvas of the first application (e.g., the first canvas) is a new canvas. The first identifier may be false. The first flag may also be referred to as 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. Upon obtaining the assigned first canvas pointer, the rendering module may determine whether the canvas name of the first application is a preset name. Upon determining that the canvas name of the first application is a preset name, the rendering module reads the identifier of the first flag. Upon reading the first identifier, the rendering module may obtain the number of buffers associated with the first canvas from the synthesis module based on the assigned first canvas pointer. Reading the first identifier may indicate that no buffers associated with the canvas of the first application have been requested.

[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, which may include a view position of the first application, view content of the first application, and the like.

[0136] For example, when the first application receives a callback function, the first application may transmit a first drawing instruction to the view module. It is understood that when the first application receives a callback function, the first application may periodically transmit the first drawing instruction to the view module so that the electronic device can promptly update the interface displayed by the first application. For example, the first application may transmit the first drawing instruction to the view module every second so that the electronic device can promptly update the interface displayed by the first application, so that the time displayed in the status bar of 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 the first drawing parameter to draw and render the image of the first application in a buffer associated with the first canvas pointed to by the 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 information indicating that the image drawing of the first application is completed is obtained, the synthesis module may synthesize the image of the first application drawn and rendered by the rendering module and send it for display.

[0142] For example, the buffer associated with the first canvas stores an image of the first application. When information indicating that the image drawing of the first application is completed is obtained, the synthesis module may synthesize the buffer associated with the first canvas and display it.

[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 can 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 is understandable that, when the electronic device receives an operation to start the second application, the first application and the second application may 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: Upon receiving the first destruction information, the rendering module may cancel the communication connection between the first application and the rendering module. Furthermore, if 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. In this way, 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 reduce 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 for the first application again. In addition, 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 composition module.

[0155] S420: Upon obtaining the first destruction information, the composition module may cancel the first canvas pointer pointing to the first canvas and add the address of the first canvas to a 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 destruction module may not destroy the first canvas.

[0157] For example, the destruction module may periodically search for canvases corresponding to addresses in the destruction queue based on the addresses in the destruction queue, and when determining that the found canvases are not referenced by a pointer, destroy the canvases not referenced by the pointers. When determining that the found canvases are referenced by a pointer, the canvases referenced by the pointers are 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 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 composition module.

[0163] Among them, the specific implementation principles of S422-S424 are similar to those 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] If 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 and 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. After obtaining the assigned second canvas pointer, the rendering module may determine whether the canvas name of the second application is a preset name. If it is determined that the canvas name of the second application is not a preset name, the rendering module may obtain the number of buffers associated with the second canvas from the composition module based on the assigned second canvas pointer.

[0171] S429: The rendering module may apply for a buffer associated with the second canvas using the number of 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 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 completed, 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 parameters 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 information indicating that the image drawing of the second application is completed is obtained, the synthesis module may synthesize the image of the second application drawn and rendered by the rendering module and send it for display.

[0180] For example, the buffer associated with the second canvas stores an image of the second application. When information indicating that the image drawing of the second application is completed is obtained, the synthesis module may synthesize the buffer associated with the second canvas and display it.

[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 is understandable 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 , and the first application may execute S443 .

[0185] S436: When the electronic device receives an operation to cause 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 the second destruction information to the rendering module.

[0188] S438. Upon receiving the second destruction information, the rendering module may cancel the communication connection between the second application and the rendering module. Based on the assigned second canvas pointer, if it is determined that the second canvas is not pointed to by the backup pointer, the rendering module may release the buffer associated with the second canvas. The fact that the second canvas is not pointed to by a pointer can be referred to as the second canvas not being referenced by a pointer.

[0189] The rendering module cancels the communication connection between the second application and the rendering module. In this way, 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 reduce 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 occupied by the buffer associated with the second canvas on the electronic device can be reduced after the second application exits the foreground.

[0191] S439: The rendering module may transmit the second destruction information to the window manager.

[0192] S440: The window manager may transmit second destruction information to the composition module.

[0193] S441: Upon obtaining the second destruction information, the composition module may cancel the second canvas pointer pointing to the second canvas and add the address of the second canvas to a 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: If 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 not being 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 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 composition module.

[0200] Among them, the specific implementation principles of S443-S445 are similar to those 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 a spare pointer exists.

[0203] In the case that 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] If it is determined that the third canvas parameters are the same as the parameters of the backup pointer, the synthesis module may use the parameters of the backup 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 first flag as a second flag. The second flag may indicate that the canvas of the first application (e.g., the first canvas) is an old canvas. The second flag 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 assigned third canvas pointer.

[0207] S448. The view module may transmit the assigned third canvas pointer to the rendering module.

[0208] S449. Upon obtaining the assigned third canvas pointer, the rendering module may determine whether the first application's canvas name is a preset name. If the first application's canvas name is determined to be a preset name, the rendering module reads the identifier of the first flag. If the second identifier is read, the electronic device may execute S452 based on the third canvas pointer. Reading the second identifier may indicate that the buffer associated with the first application's canvas has been claimed.

[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. 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 completed, 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: Upon obtaining information indicating that the image drawing of the first application is complete, the synthesis module may synthesize and display the image of the first application drawn and rendered by the rendering module. The specific implementation principle of this step can be found in the specific implementation principle of S413 and 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 for causing the first application to exit the foreground is, for example, a touch operation on an application icon on the desktop application interface.

[0219] It is understandable that, when the electronic device receives an operation that causes the first application to exit the foreground, the first application may 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: Upon receiving the third destruction information, the rendering module may cancel the communication connection between the first application and the rendering module. Based on the assigned third canvas pointer, if it is determined 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.

[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 composition module.

[0227] S461: Upon obtaining the third destruction information, the composition module may cancel the third canvas pointer pointing to the first canvas and add the address of the first canvas to a 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 destruction module does not destroy the first canvas.

[0229] like Figure 4A and Figure 4B As shown, in the module interaction process provided by an embodiment of the present application, when the first application is running 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. 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 parameters 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 flag indicating that the canvas of the first application is a new canvas. The first application can transmit the first drawing parameters and the assigned first canvas pointer to the rendering module through the view module and the window manager. The first drawing parameters can include the view position of the first application or the view content of the first application, etc. If 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. If the first identifier is read, the rendering module can apply for the buffers 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 drawn and rendered image of the first application.

[0230] When a first application switches to the background and a second application runs in the foreground, the first application can transmit information to the rendering module through the view module and the window manager indicating the destruction of the first application's canvas. The rendering module cancels the communication connection between the first application and the rendering module. If the rendering module determines that the first canvas is referenced by a backup pointer, it does not release the buffer associated with the first canvas. The rendering module can transmit information to the compositing module through the window manager indicating the destruction of the first application's canvas. The compositing module cancels the reference to the first canvas by the first canvas pointer and adds the address of the first canvas to a destruction queue. If the destruction module determines that the first canvas is referenced by the backup pointer, it does not destroy the first canvas. When the first application switches back to the foreground, the compositing module no longer needs to create a canvas for the first application, and the rendering module no longer needs to allocate a buffer for the first application's canvas. The rendering module can draw and render the first application's image in the buffer associated with the first application's canvas that has not been released. Upon receiving information from the rendering module indicating that the first application's image drawing is complete, the compositing module composes the first application's image and displays it. 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.

[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 a first application to run in the foreground, and the first application may be switched from the background to the foreground.

[0234] For example, Figure 4B In step S455, the operation of causing the first application to exit the foreground is, for example, a touch operation on the application icon of a third application on the desktop application interface. When the electronic device receives the operation 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 its interface is displayed, the user can download a fourth application on the third application's interface. 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. Therefore, downloading 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 to make the first application run in the foreground.

[0236] It is understandable that, when the electronic device receives an operation to make the first application run in the foreground, the first application may receive a touch event corresponding to the operation to make the first application run in the foreground, and the first application may 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 composition module.

[0241] The specific implementation principles of S501-S503 are similar to those 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 a spare pointer exists.

[0244] In the case that 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] If it is determined that the fourth canvas parameters differ from the parameters of the backup pointer, the synthesis module may create a fourth canvas using the fourth canvas parameters and set the backup pointer to null. Setting the backup pointer to null can be understood as meaning that the backup pointer does not point to the canvas. For example, setting the backup pointer to null means clearing the value assigned to the backup pointer. The difference between the fourth canvas parameters and the backup pointer parameters 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 nulled backup pointer, such that both the fourth canvas pointer and the backup pointer point to the fourth canvas. The synthesis module may also maintain the first flag as the first flag. The fourth canvas pointer and the backup pointer both pointing to the fourth canvas can be understood as referring 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 any pointer. In this way, the destruction module can destroy the first canvas based on the address of the first canvas in the destruction queue, if it finds the first canvas and determines that the first canvas is not referenced by any 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. Upon obtaining the assigned fourth canvas pointer, the rendering module may determine whether the first application's canvas name is a preset name. If the first application's canvas name is determined to be a preset name, the rendering module reads the identifier of the first flag. If the first identifier is read, it may indicate that the buffer associated with the first application's canvas has not been requested. The rendering module may obtain the number of buffers associated with the fourth canvas from the synthesis module based on the assigned fourth canvas pointer to facilitate requesting 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 a buffer 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 fourth drawing parameters, which may include a view position of the first application, view content of the first application, and the like.

[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 can be executed concurrently. S509 and S505 can also be executed sequentially. For example, after S505 is executed, S509 can be executed.

[0257] S510: The view module may transmit a fourth drawing instruction to the rendering module.

[0258] S511: When the fourth drawing instruction is obtained, the rendering module may use the fourth drawing parameters to draw and render the image of the first application in the buffer associated with the 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 information indicating that the image drawing of the first application is completed is obtained, the synthesis module may synthesize the image of the first application drawn and rendered by the rendering module and send it for display.

[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] For example, taking the first application as a desktop application, 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 the fourth application, the first application may transmit fourth destruction information to the view module.

[0265] The fourth destruction information may include the assigned fourth canvas pointer. The fourth destruction information may indicate the destruction of the first application's canvas, or may indicate 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: Upon 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, if it is determined that the fourth canvas is pointed to by the backup pointer, the rendering module may not release the buffer associated with the fourth canvas. The fourth canvas being pointed to by the backup pointer may be referred to as the fourth canvas being referenced by the backup 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 in S417 and will not be repeated 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, if 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. This can reduce the memory usage of the electronic device.

[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. Upon 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 composition 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 destruction module may not destroy the fourth canvas.

[0275] For example, the destruction module may periodically search for canvases corresponding to addresses in the destruction queue based on the addresses in the destruction queue, and when determining that the found canvases are not referenced by a pointer, destroy the canvases not referenced by the pointers. When determining that the found canvases are referenced by a pointer, the canvases referenced by the pointers are not destroyed.

[0276] For example, taking the case where the standby pointer points to the first canvas before being set to null 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 may destroy the first canvas and transmit information indicating that the first canvas has been 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 parameters in the fourth canvas pointer are different from the parameters of the standby pointer, indicating that the interface of the first application has changed, the synthesis module can use the fourth canvas parameters to create a fourth canvas for the first application and set the standby pointer to 0.

[0278] The composition module can assign values ​​to the fourth canvas pointer and the cleared backup pointer so that both point to the fourth canvas. The composition module can also maintain the first flag as a first flag indicating that the first application's canvas is a new canvas. The first application can transmit a fourth drawing instruction and the assigned fourth canvas pointer to the rendering module via the view module and the window manager. The fourth drawing instruction can include fourth drawing parameters. The fourth drawing parameters can include the view position or content of the first application's view. If the rendering module determines that the first application's canvas name is a preset name, the rendering module can read the first flag from the composition module and obtain the number of buffers associated with the fourth canvas based on the first canvas pointer. If the first flag is read, the rendering module can apply for the buffers 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 first application's image in the buffers associated with the fourth canvas. The composition module can then composite and display the completed drawn and rendered image of the first application. 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 the buffer associated with the new canvas can reduce the probability of the first application's canvas not meeting 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 backup pointer, the rendering module does not release the buffer associated with the fourth canvas. When it determines that the first canvas is not referenced by the pointer or receives 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 backup pointer. In this way, when the first application is switched back to the foreground, the synthesis module no longer needs to create a canvas for the first application, and the rendering module no longer needs to apply for a buffer for the first application's canvas. The rendering module can draw and render the image of the first application in the buffer associated with the unreleased fourth canvas, so that the image of the first application can be displayed in a timely manner 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 if it determines that the first canvas is not being used by the pointer, so as to reduce the memory occupied by the first canvas on the electronic device.

[0280] The following combination 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 be found in Figure 4A and Figure 4B The specific implementation principle shown will not be repeated here.

[0283] S601: Upon 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] If 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 may stop transmitting the drawing instructions transmitted by the first application to the rendering module, thereby reducing the probability that the electronic device will display 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's failure to transmit the first destruction information to the rendering module can be understood as: the view module does not process the first destruction information.

[0285] If the view module does not transmit the first destruction information to the rendering module, the rendering module, the window manager, the compositing module, and the destruction module may not execute the process of destroying the first application's canvas and releasing the buffer associated with the first application's canvas based on the first destruction information. This can reduce power consumption of the electronic device.

[0286] S602: Upon 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: Upon 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. If 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 may stop transmitting the drawing instructions (e.g., the third drawing instructions) transmitted by the first application to the rendering module.

[0288] like Figure 6As shown, in the module interaction process provided by an embodiment of the present application, when the first application is running in the foreground, the first application can transmit a first canvas pointer to the synthesis module through the view module and the window manager. If 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 parameters 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 first flag as a first flag indicating that the canvas of the first application is a new canvas. The first application can transmit a 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 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. If the rendering module determines that the canvas name of the first application is a preset name, the rendering module can read 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 may apply for a 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 drawn and rendered image of the first application.

[0289] When the first application switches to the background and the second application runs in the foreground, the first application can transmit information to the view module indicating the destruction of the first application's canvas. When the view module determines that the name of the first application's canvas 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 first application's canvas to the rendering module. In this way, the electronic device does not execute the process of destroying the first canvas or the process of releasing the buffer associated with the first canvas. When the first application switches 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 first application's canvas. The rendering module can draw and render the first application's image in the buffer associated with the first application's canvas that has not been released. When the synthesis module receives information transmitted by the rendering module indicating that the first application's image drawing is complete, the synthesis module synthesizes the first application's image and displays it. In this way, the first application's image can be displayed promptly when the second application exits the foreground, reducing the probability of lag in the first application's interface display.

[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 enable the first application to run in the foreground, and the first application may be 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 composition 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 a spare pointer exists.

[0299] In the case that 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 parameters are different from the parameters of the standby pointer, the synthesis module may create a fourth canvas using the fourth canvas parameters and set the standby pointer to 0. Setting the standby pointer to 0 means 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 as the first identifier.

[0302] It is understood that in this step, to ensure that each application corresponds to a valid canvas pointer, when the composition module assigns a value to the fourth canvas pointer, the composition module can cancel or clear the reference of the third canvas pointer to the first canvas and add the address of the first canvas to the destruction queue. In addition, after setting the standby pointer to NULL, the first canvas is no longer referenced by any pointer. In this way, the destruction module can execute S706.

[0303] S705: Upon 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. If 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 may 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 memory occupied by the first canvas on 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. Upon 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 parameters in the fourth canvas pointer are different from the parameters of the standby pointer, the synthesis module can use the fourth canvas parameters 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 cleared, 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 assigned fourth canvas pointer to the rendering module through the view module and the window manager. 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 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 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, setting the standby pointer to NULL and canceling the third canvas pointer pointing to the first canvas can destroy the first canvas pointed to before the standby pointer is set to NULL, and release the buffer associated with the first canvas, thereby reducing the memory usage of the electronic device.

[0308] When the first application switches to the background, the first application can transmit information indicating the destruction of the first application's canvas to the view module. When the view module determines that the name of the first application's canvas 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 first application's canvas to the rendering module. In this way, the electronic device does not execute the process of destroying the first canvas or the process of releasing the buffer associated with the first canvas. When the first application switches 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 first application's canvas. The rendering module can draw and render the first application's image in the buffer associated with the first application's canvas that has not been released. When the synthesis module receives information transmitted by the rendering module indicating that the drawing of the first application's image is complete, the synthesis module synthesizes the first application's image and displays it. In this way, the first application's image can be displayed in a timely manner when the first application switches back to the foreground, reducing the probability of lag in the interface display of the first application.

[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 requested; the first buffer is used to store images of the first application;

[0312] When the first application switches to the background and the second application runs 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;

[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, upon receiving an operation to launch a second application, when the first application switches to the background and the second application runs in the foreground, the electronic device creates a second canvas for the second application and applies for a buffer associated with the second canvas using the number of buffers associated with the second canvas. The buffer associated with the second canvas applied for is the at least one second buffer associated with the second canvas. Because the first canvas is referenced by the backup pointer, the second canvas is not destroyed and the at least one first buffer associated with the second canvas is not released.

[0316] like Figure 4B In S443-S454, when receiving the operation to make the second application exit the foreground, when the first application is switched to the foreground again, the electronic device can 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 can be destroyed and at least one second buffer associated with the second canvas can be released. In this way, the memory occupied by the second canvas and the second buffer of the second application can be reduced.

[0317] Optionally, for scenarios where the electronic device has a large amount of memory, upon receiving an operation to launch a second application, when the first application switches to the background and the second application is running in the foreground, the electronic device can create a backup pointer for the second application when creating a second canvas for the second application, and point the backup pointer to the second canvas. This ensures that upon receiving an operation to cause the second application to exit the foreground, 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 promptly display the interface of the second application, 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 can display 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 the 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 the 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 first canvas parameters.

[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 the interface of any application can be displayed in time when the any application switches from the background to the foreground, reducing the probability of the interface display of any application being stuck.

[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 by 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 switches to background operation and the second application runs in the foreground, the method further includes:

[0329] Cancel the first canvas pointer from 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 can be kept intact. 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, the 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. Therefore, when the application corresponding to the first canvas switches 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 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 the foreground, the method further includes:

[0341] A third canvas pointer of the first application is obtained, where the third canvas pointer includes third canvas parameters.

[0342] In the case that the parameters of the standby pointer are the same as the parameters of the third canvas, the parameters of the standby pointer are 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 assigning a value to the third canvas pointer using the parameter of the standby pointer, the method further includes: maintaining the identifier of the first flag bit as a second identifier, where the second identifier indicates 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 may 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. This can reduce the power consumption of the electronic device, and it is also convenient for the electronic device to find the first canvas in a timely manner 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.

[0348] Optionally, the method further comprises:

[0349] When the first application switches to the background and the third application runs in the foreground, a third canvas is created for the third application and at least one third buffer associated with the third canvas is requested. The third buffer is used to store images of the third application. The first canvas is not destroyed and the 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 the foreground again, a fourth canvas of the first application is created and at least one fourth buffer associated with the fourth canvas is requested. 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 created for the first application and a buffer associated with the new canvas (such as at least one fourth buffer) is requested. This 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 NULL to obtain a NULLed standby pointer. The NULLed standby pointer 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, reducing the probability of the interface display of the first application being stuck.

[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 memory usage of the electronic device by the unnecessary first canvas and the buffer associated with the first canvas can be reduced.

[0362] Optionally, when the first application switches to background operation and the second application runs in the foreground, the method further includes:

[0363] A second canvas pointer of the second application is obtained, where the second canvas pointer includes a second canvas parameter, and the second canvas parameter includes a canvas identifier of the second application, where 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 the foreground, the method further includes:

[0368] Cancel the second canvas pointer from 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, thereby reducing the memory usage 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, the buffer associated with the canvas of the second application can be released when the second application exits the foreground, thereby reducing 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 switches to background operation and the second application runs 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. This can ensure 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. Therefore, when the first application switches from the background to the foreground, the electronic device can promptly display the interface of the first application, reducing the probability of lag in the display of the first application interface. 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 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 and a process of releasing at least one second buffer associated with the second canvas are 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 second application is running in the background, destroying the canvas of the second application and releasing the buffer associated with the canvas of the second application, 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. The following describes the apparatus for executing the above method provided in the embodiment of the present application. Those skilled in the art will appreciate that the method and apparatus can be combined and referenced with each other, and the relevant apparatus provided in 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. The specific device form of the terminal device can refer to the above related descriptions and will not be repeated here.

[0387] An embodiment of the present application provides an electronic device comprising one or more processors and a memory. The memory is coupled to the one or more processors and is configured to store computer program code, which includes computer instructions. The one or more processors invoke the computer instructions to cause the electronic device to execute the aforementioned method. The implementation principles and technical effects are similar to those of the aforementioned related embodiments and are not further elaborated here.

[0388] The present application provides a chip system, which is applied to an electronic device and includes one or more processors configured to invoke computer instructions to cause the electronic device to execute the technical solutions in the above-described embodiments. The implementation principles and technical effects are similar to those in the above-described related embodiments and will not be further elaborated 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, which includes at least one processor 81 and a communication interface 83. The communication interface 83 and the at least one processor 81 are interconnected via a line. The at least one processor 81 is used to run a computer program or instruction to perform the above method. Its implementation principle and technical effects are similar to those of the above-mentioned related embodiments and will not be repeated here.

[0391] Exemplarily, the at least one processor 81 is configured to call and run computer programs or instructions in the memory 84 to perform 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. When the computer program is executed by a processor, the above-mentioned method is implemented. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions 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 disc storage, magnetic disk storage or other magnetic storage devices, or any other medium intended to carry or store the desired program code in the form of instructions or data structures and accessible 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. Disk and optical disc as used herein include optical disc, laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks generally reproduce data magnetically, while optical discs reproduce data optically using lasers. Combinations of the above should also be included within 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 produce 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 steps in the process. 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 objectives, 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 replacements, 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 a 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 switches to the background and the second application runs 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 an 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 the foreground again, drawing the image of the first application in the at least one first buffer that has not been released; 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 first canvas parameters; creating a backup pointer based on the first canvas parameter; wherein the first canvas pointer and the backup pointer both point to the first canvas; When the first application is switched to the background and the second application is running in the foreground, and the standby pointer points to the first canvas, the first canvas is not destroyed.

2. The method according to claim 1, characterized in that The first canvas parameter includes a canvas identifier of the first application; and 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.

3. The method according to claim 1 or 2, characterized in that When the first application is switched to background operation and the second application is running in the foreground, the method further includes: The first canvas pointer is cancelled from pointing to the first canvas, and the address of the first canvas is added to a destruction queue.

4. The method according to claim 3, 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.

5. The method according to any one of claims 1 to 2 and 4, 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.

6. The method according to any one of claims 1-2 and 4, 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 third canvas parameters; In a case where the parameters of the standby pointer are the same as the parameters of the third canvas, the parameters of the standby pointer are used to assign a value to the third canvas pointer, so that the third canvas pointer points to the first canvas.

7. The method according to claim 6, characterized in that When assigning a value to the third canvas pointer using the parameter of the standby pointer, the method further includes: maintaining an 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 the identifier of the first flag bit is maintained as the second identifier, the method further includes: When the second identifier is read, the process of applying for the buffer associated with the canvas of the first application is not executed.

8. The method according to any one of claims 1-2, 4 and 7, characterized in that: The method further comprises: When the first application switches to the background and a third application runs 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 images 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; wherein the downloading of the fourth application causes an interface of the first application to change; When the first application is switched to the foreground again, a fourth canvas of the first application is created and at least one fourth buffer associated with the fourth canvas is requested; the fourth buffer is used to store the image of the first application.

9. The method according to claim 8, 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; 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 cleared to obtain a cleared standby pointer; the cleared standby pointer does not point to the canvas; 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.

10. The method according to claim 9, 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.

11. The method according to any one of claims 1-2, 4, 7, 9-10, characterized in that When the first application is switched to background operation and the second application is running 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.

12. The method according to claim 11, characterized in that 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, the second canvas is destroyed.

13. The method according to claim 11, characterized in that 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 backup pointer, at least one second buffer associated with the second canvas is released.

14. The method according to claim 1 or 2, characterized in that The first canvas parameter includes a canvas identifier of the first application; When the first application is switched to background operation and the second application is running 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.

15. The method according to claim 14, characterized in that When the first application is switched to run in the foreground again, the method further includes: If 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.

16. The method according to any one of claims 1-2, 4, 7, 9-10, 12-13, and 15, characterized in that The first application is a desktop application.

17. An electronic device, characterized in that: 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 method as described in any one of claims 1 to 16.

18. 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 to enable the electronic device to execute the method as described in any one of claims 1 to 16.

19. 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 according to any one of claims 1 to 16.

20. 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 16.

Citation Information

Patent Citations

  • Interface switching method and electronic equipment

    CN117289837A