Cache adjustment method and related device

By dynamically adjusting the cache space, the display lag problem of electronic devices when running more pictures or larger applications is solved. By dynamically adjusting the cache value according to application needs, the duplicate acquisition and deletion of image data is reduced, and the smoothness and user experience of the device are improved.

CN120295680APending Publication Date: 2025-07-11HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410015870.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-02
Publication Date
2025-07-11

Smart Images

  • Figure CN120295680A_ABST
    Figure CN120295680A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cache adjustment method and a related device, and relates to the technical field of terminals. The method comprises the following steps: in response to a first operation of starting a first application, setting a cache space as a first value, and running the first application in a foreground based on the cache space; in response to a second operation of quitting foreground running of the first application and starting a second application, setting the space of the cache as a second value, running the second application in the foreground, and running the first application in the background; the first value is different from the second value; and in response to a third operation of quitting foreground running of the second application and running the first application in the foreground, setting the space of the cache as a first value. Thus, the cache space is related to the foreground running application, so that the cache space is matched with the foreground running application, and the phenomenon of application display jamming caused by insufficient cache space can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of terminals, and in particular, to a cache adjustment method and related devices. Background Art

[0002] An electronic device is installed with multiple applications, such as a camera, a calendar, a phone, a text message, etc.

[0003] However, when the electronic device runs an application with a large number of pictures or large-sized pictures, there may be a situation of display lag. Summary of the Invention

[0004] Embodiments of this application provide a cache adjustment method and related devices, which are applied to the technical field of terminals. The cache space is related to the foreground-running application, so that the cache space is adapted to the foreground-running application, which can reduce the display lag of the application caused by insufficient cache space.

[0005] In a first aspect, an embodiment of this application proposes a cache adjustment method. The method includes: in response to an operation of starting a first application, setting the cache to a first value, and running the first application in the foreground based on the cache space; in response to a second operation of exiting the foreground running of the first application and starting a second application, setting the cache space to a second value, running the second application in the foreground, and running the first application in the background; the first value is different from the second value; in response to a third operation of exiting the foreground running of the second application and running the first application in the foreground, setting the cache space to the first value.

[0006] In this way, the size of the cache can be dynamically adjusted according to the foreground-running application. When the cache usage of the application is large within a preset time period, the cache value of the cache is increased to reduce the display lag of the application; when the cache usage of the application is small within a preset time period, the cache value of the cache is lowered to reduce the memory occupation of the application.

[0007] In a possible implementation manner, in response to the first operation of starting the first application, setting the cache space to the first value includes: in response to the first operation, according to the identifier of the first application and the correspondence between the application identifier and the cache value, confirming the first value; setting the cache space to the first value through the hardware acceleration rendering module.

[0008] In this way, storing the correspondence is convenient for obtaining the first value. The method is simple and easy to implement. In addition, the first value can be obtained through HWUI and the first value can be configured.

[0009] In a possible implementation, in response to a first operation, according to the identifier of a first application and the correspondence between the identifier of the application and the cache value, a first value is confirmed, including: in response to the first operation, the window manager transmits a first message to the hardware-accelerated rendering module, where the first message is used to indicate that the first application is running in the foreground, and the first message includes: the identifier of the first application; in response to the first message, the hardware-accelerated rendering module confirms the first value according to the identifier of the first application and the correspondence between the identifier of the application and the cache value.

[0010] In this way, the first value can be obtained through HWUI and the first value can be configured.

[0011] In a possible implementation, the hardware-accelerated rendering module sets the cache space to the first value, including: the hardware-accelerated rendering module transmits a first message to the memory allocation module, where the first message is used to indicate configuring the cache space to the first value, and the first message includes: the identifier of the first application and the first value; the memory allocation module transmits a second message to the hardware-accelerated rendering module, and the second message includes the cache address; the cache address is used to confirm the location of the cache space.

[0012] In a possible implementation, the first value is related to the cache value corresponding to the image data deleted from the cache space before the first operation.

[0013] In a possible implementation, before the first operation, the method further includes: in response to a sixth operation of starting the first application, setting the cache space to a third value and running the first application in the foreground; during the period when the first application is running in the foreground, storing the image data of the interface of the first application in the cache space to render the interface of the first application, where the third value is less than the first value; when the cache space is less than the image data of the interface of the first application, deleting all or part of the image data of the first application and recording the cache value corresponding to the deleted image data; in response to a seventh operation of exiting the foreground operation of the first application, running the first application in the background and saving the first value; the first value is the sum of the third value and a fourth value; or, the first value is a preset value, where the preset value is less than the sum of the third value and the fourth value, and the fourth value is the sum of the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation; or, the first value is the sum of the third value and a fifth value; or, the first value is a preset value, where the preset value is less than the sum of the third value and the fifth value; the fifth value is the maximum value among the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation.

[0014] In this way, when the cache is insufficient, the deleted image data is recorded, which is convenient for subsequent adjustment of the cache space corresponding to the application.

[0015] In a possible implementation, during the foreground running of the first application, the method includes: in response to a sixth operation, storing the image data of the first interface in the cache space to render the first interface; in response to an eighth operation, when the cache space is smaller than the image data of the second interface, deleting all or part of the image data of the first interface from the cache space and recording a sixth value, where the sixth value is the image data of the first interface deleted from the cache space; after deleting all or part of the image data of the first interface, storing the image data of the second interface in the cache space to render the second interface; the first value is the sum of the third value and the sixth value.

[0016] In this way, it can be applied to the situation where the image data of two interfaces in the application exceeds the cache.

[0017] In a possible implementation, during the foreground running of the first application, the method includes: in response to a sixth operation, storing the image data of the first interface in the cache space to render the first interface; in response to an eighth operation, when the cache space is smaller than the image data of the second interface, deleting all the cache of the first interface, configuring the expanded cache space as a seventh value, and recording an eighth value, where the eighth value is the sum of the image data of the first interface deleted from the cache space and the seventh value; storing the image data of the second interface in the cache space and the expanded cache space to render the second interface;

[0018] The first value is the sum of the third value and the eighth value, or the first value is a preset value, and the preset value is smaller than the sum of the third value and the eighth value.

[0019] In this way, it can be applied to the situation where the image data of one interface exceeds the cache.

[0020] Second aspect, an embodiment of the present application provides a cache adjustment device, which may be an electronic device, or a chip or chip system within the electronic device. The cache adjustment device may include a display unit and a processing unit. When the cache adjustment device is an electronic device, the display unit may be a display screen. The display unit is configured to perform the display step, so that the electronic device implements a cache adjustment method described in the first aspect or any possible implementation manner of the first aspect. When the cache adjustment device is an electronic device, the processing unit may be a processor. The cache adjustment device may further include a storage unit, which may be a memory. The storage unit is configured to store instructions, and the processing unit executes the instructions stored in the storage unit, so that the electronic device implements a cache adjustment method described in the first aspect or any possible implementation manner of the first aspect. When the cache adjustment device is a chip or chip system within the 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 a cache adjustment method described in the first aspect or any possible implementation manner of the first aspect. The storage unit may be a storage unit within the chip (for example, a register, a cache, etc.), or a storage unit outside the chip within the electronic device (for example, a read-only memory, a random access memory, etc.).

[0021] Exemplarily, the display unit is configured to display the interface of the application running in the foreground.

[0022] The processing unit is configured to set the cache to a first value in response to an operation of starting a first application, where the first value is determined by the cache usage of the first application within a preset time period; the processing unit is further configured to run the first application in the background in response to an operation of starting a second application; set the cache to a second value, where the second value is determined by the cache usage of the second application within a preset time period; the first value is different from the second value; the processing unit is further configured to set the cache to the first value in response to an operation of running the first application in the foreground.

[0023] In a possible implementation manner, the processing unit is specifically configured to confirm the first value according to the identifier of the first application and the corresponding relationship between the identifier of the application and the cache value; the processing unit is specifically configured to set the space of the cache to the first value through a hardware acceleration rendering module.

[0024] Third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where the memory is configured to store code instructions, and the processor is configured to run the code instructions to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0025] Fourthly, an embodiment of the present application provides a computer-readable storage medium storing a computer program or instruction. When the computer program or instruction runs on a computer, the computer is caused to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0026] Fifthly, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer is caused to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0027] Sixthly, the present application provides a chip or a chip system. The chip or the chip system includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line. The at least one processor is configured to run a computer program or instruction to execute the method described in the first aspect or any possible implementation manner of the first aspect. Wherein, the communication interface in the chip may be an input / output interface, a pin, a circuit, etc.

[0028] In a possible implementation, the chip or the chip system described above in the present application further includes at least one memory storing an instruction. The memory may be an internal storage unit of the chip, such as a register, a cache, etc., or a storage unit of the chip (such as a read-only memory, a random access memory, etc.).

[0029] 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. The beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar and will not be elaborated herein. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a schematic diagram of an interface of an electronic device provided by an embodiment of the present application;

[0031] Figure 2 It is a schematic diagram of a structure of an electronic device provided by an embodiment of the present application;

[0032] Figure 3 It is a schematic diagram of a software structure of an electronic device provided by an embodiment of the present application;

[0033] Figure 4 It is a schematic diagram of a process for switching foreground-running applications provided by an embodiment of the present application;

[0034] Figure 5 It is a timing diagram of GPU task execution provided by an embodiment of the present application;

[0035] Figure 6Schematic flowchart of a cache adjustment method provided by an embodiment of the present application;

[0036] Figure 7 Schematic flowchart of the adjustment process of the cache pool corresponding to Application A provided by an embodiment of the present application;

[0037] Figure 8 Schematic flowchart of the process of displaying an application interface provided by an embodiment of the present application;

[0038] Figure 9 Schematic diagram of the cache corresponding to Application A provided by an embodiment of the present application;

[0039] Figure 10 Schematic flowchart of the process of displaying an application interface provided by an embodiment of the present application;

[0040] Figure 11 Schematic diagram of the cache corresponding to Application A provided by an embodiment of the present application;

[0041] Figure 12 Schematic flowchart of the process of displaying an application interface provided by an embodiment of the present application;

[0042] Figure 13 Schematic diagram of the cache corresponding to Application A provided by an embodiment of the present application;

[0043] Figure 14 Schematic flowchart of a cache adjustment method provided by an embodiment of the present application. Detailed implementation manners

[0044] To facilitate a clear description of the technical solutions of the embodiments of the present application, the following briefly introduces some terms and technologies involved in the embodiments of the present application:

[0045] 1. Other terms

[0046] In the embodiments of the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. For example, the first chip and the second chip are only used to distinguish different chips, and do not limit their sequence. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and terms such as "first" and "second" do not necessarily mean different.

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

[0048] In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent the cases of A existing alone, A and B existing simultaneously, and B existing alone, where A and B may be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of single item (s) or multiple items (s). For example, at least one (item) of a, b, or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c may be single or multiple.

[0049] 2. Electronic device

[0050] The electronic device according to the embodiments of the present application may include a handheld device with a display function, a vehicle-mounted device, etc. For example, some electronic devices are: mobile phone, tablet computer, handheld computer, notebook computer, mobile internet device (MID), wearable device (such as smart watch, smart glasses, smart bracelet or smart jewelry, etc.), virtual reality (VR) device, augmented reality (AR) device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, cellular phone, cordless phone, session initiation protocol (SIP) phone, wireless local loop (WLL) station, personal digital assistant (PDA), handheld device with wireless communication function, computing device or other processing devices connected to a wireless modem, vehicle-mounted device, terminal device in a 5G network, or terminal device in a future evolved public land mobile network (PLMN), etc. The embodiments of the present application are not limited thereto.

[0051] In addition, in the embodiments of the present application, the electronic device may also be a terminal device in an Internet of Things (IoT) system. The 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, so as to realize an intelligent network of human-machine interconnection and thing-thing interconnection.

[0052] The electronic device in the embodiments of the present application may also be referred to as: terminal device, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile platform, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, etc.

[0053] 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 a memory (also called main memory). The operating system can be any one or more computer operating systems that implement service processing through processes. For example, Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system, etc. The application layer includes applications such as a browser, an address book, a word processing software, and an instant messaging software.

[0054] The electronic device is installed with one or more applications, such as a camera, a calendar, a phone, a text message, etc.

[0055] However, when the electronic device runs an application with a large number of pictures or large-sized pictures, there may be a situation of display jamming.

[0056] Exemplarily, Figure 1 is a schematic diagram of the interface of an electronic device provided by the embodiments of the present application. As shown in Figure 1 a in, the desktop of the electronic device displays icons of multiple applications. Taking application A as an example, the electronic device detects a click operation on the icon 101 of application A, and the electronic device starts application A and enters the Figure 1 interface shown in b in. This interface displays a picture a of application A. The picture a is used to indicate a part of the functions of application A. For example, the picture a may display "Heart Health Research" to prompt the user that application A can monitor heart health.

[0057] When the electronic device detects that the user swipes right, the electronic device enters the Figure 1 interface shown in c of. This interface displays picture b of application A. Picture b is used to indicate another part of the functions of application A. For example, picture b may display "Sleep Apnea Study" to prompt the user that application A can monitor sleep breathing.

[0058] However, when the electronic device switches from displaying picture a to displaying picture b and then switches back from displaying picture b to displaying picture a, there may be a lag phenomenon.

[0059] Through software analysis of the interface display process of the electronic device, it is found that the resolutions of picture a and picture b are relatively large, while the space of the cache pool corresponding to application A set by the electronic device is relatively small. When the electronic device switches to display picture b, it needs to delete the image data of picture a in the cache pool. In this way, when switching back to display picture a subsequently, it is necessary to re-obtain and store the image data of picture a, increasing the rendering time of picture a and resulting in a lag phenomenon.

[0060] In a possible design, the space of the cache pool corresponding to application A may not be able to store the image data of picture b. The electronic device needs to apply for an additional part of the cache to store the image data of picture b. As a result, the GPU obtains the image data of picture b relatively late, and the rendering, display, etc. times of picture b are relatively late, causing a lag phenomenon in the electronic device.

[0061] In view of this, the embodiments of the present application provide a cache adjustment method and related device. The electronic device can adjust the texture cache size corresponding to the application according to the historical cache situation of the application. In this way, when the historical cache of the application is relatively large, the texture cache corresponding to the application is increased to reduce the lag phenomenon in the application display. When the historical cache of the application is relatively small, the texture cache (cache pool) corresponding to the application is reduced to reduce the memory occupancy of the application and improve the fluency of the electronic device operation. The electronic device can dynamically adjust the size of the texture cache value (the space of the cache pool) according to the needs of the application to reduce the lag phenomenon of the electronic device.

[0062] In order to better understand the embodiments of the present application, the structure of the electronic device in the embodiments of the present application will be introduced below.

[0063] Exemplarily, Figure 2 is a schematic structural diagram of an electronic device provided by the embodiments of the present application. As Figure 2As shown in the figure, the electronic device may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, an indicator 192, a camera 193, and a display screen 194, etc.

[0064] Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc. No specific limitation is made in the embodiments of the present application.

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

[0066] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0067] It can also be understood that the processor 110 is used to implement the steps executed in the cache adjustment method provided in the embodiments of the present application, and to store instructions and data related to the cache adjustment method.

[0068] The external memory interface 120 can be used to connect to an external memory card, such as a Micro SD card, to implement the storage capacity expansion of the electronic device. The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The internal memory 121 can include a program storage area and a data storage area. For example, the internal memory 121 can be used to store the executable program code in the system upgrade method.

[0069] The electronic device realizes the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.

[0070] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. For example, the display screen 194 can implement the display of the interface shown in b in Figure 1 , etc., which is not limited in the embodiments of the present application.

[0071] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture, etc., which will not be elaborated here.

[0072] The following will describe the software architecture of the electronic device in combination with Figure 3 . Exemplarily, Figure 3 is a software structure block diagram of an electronic device provided by an embodiment of the present application.

[0073] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom are the application layer, the application framework layer, the Android runtime and system libraries, the hardware abstraction layer, and the kernel layer.

[0074] The application layer may include a series of application packages. As Figure 3 shown, the application packages may include applications such as the lock screen, desktop, sharing, Bluetooth, gallery, voice interaction, contacts, etc.

[0075] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.

[0076] As Figure 3 shown, the application framework layer may include a view system, animations, a packaging manager, a window manager, a broadcast receiver, a screen manager, an input manager, a power manager, a database, an activity manager, etc.

[0077] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures.

[0078] The window manager (window manager service, WMS) is used to manage window programs. The window manager can display the windows of applications on the screen and handle user input events. The window manager can implement the startup, addition, and deletion of windows, as well as manage the size and hierarchy of windows. Exemplarily, the window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0079] The activity manager (activity manager service, AMS) is responsible for the startup, switching, scheduling of the four major components in the system, and the management and scheduling of application processes, etc. The four major components can be interfaces (such as activities), services, content providers, and broadcast receivers.

[0080] The Android runtime includes a core library and a virtual machine (not shown in the figure). The Android runtime is responsible for the scheduling and management of the Android system.

[0081] The core library consists of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core library of Android.

[0082] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as the management of object life cycles, stack management, thread management, security and exception management, and garbage collection.

[0083] The system library can include multiple functional modules. For example: browser kernel, 3D graphics, 2D graphics, font library, image composition system (surface flinger), interface integration library (libui), etc.

[0084] 3D graphics is used to implement three-dimensional graphics drawing, image rendering, composition, and layer processing, etc.

[0085] 2D graphics are used to implement 2D graphics drawing, image rendering, composition, and layer processing, etc. In the embodiments of this application, 2D graphics include: hardware accelerated rendering engine for UI (HWUI).

[0086] HWUI is used for software drawing using a graphics processing library and configuring a cache pool. HWUI includes: a rendering library (such as OpenGL ES, SGL, vulkan, etc.). In the embodiments of this application, HWUI also stores the correspondence between application identifiers and cache values. HWUI can implement dynamic configuration of the cache pool space according to the foreground-running application and the correspondence. Exemplarily, taking the application A corresponding to the cache value A and the application B corresponding to the cache value B in the correspondence as an example, in response to the operation of running application A in the foreground, HWUI confirms the cache value A and configures the space of the cache pool to the cache value A; in response to the operation of running application B in the foreground, HWUI confirms the cache value B and configures the space of the cache pool to the cache value B. In this way, the space of the cache pool can be adjusted according to the foreground-running application, reducing the jamming phenomenon of application display.

[0087] The image composition system (surface flinger) is used to compose images. The image composition system can receive graphic display data from multiple sources and compose the display data. The composed layer parameters are processed by the hardware composer and transmitted to the display driver for display.

[0088] The hardware abstraction layer provides a unified access interface for different hardware devices. As Figure 3 shown, the hardware abstraction layer may include a touch screen, a display screen, sensors, a camera, audio, Bluetooth, a hardware composer, a memory allocation module, and a graphics processing unit device development kit (GPUDDK).

[0089] The memory allocation module is used for memory allocation in the electronic device. The memory allocation module includes: an allocator and a mapping module. The mapping module is used to save the relationship between the actual memory address and the virtual memory address.

[0090] The hardware composer composes the composed layer parameters transmitted by the image composition system (surface flinger).

[0091] The kernel layer is the layer between hardware and software. The kernel layer includes at least various drivers, such as camera drivers, display drivers, Bluetooth drivers, ultra wide band (UWB) drivers, sensor drivers, touch screen drivers, audio drivers, and memory drivers.

[0092] The following describes the working processes of the software and hardware of the terminal device by taking the scenario of interface switching of the terminal device as an example.

[0093] When the touch sensor in the terminal device receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including information such as touch coordinates, touch force, and timestamp of the touch operation). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event.

[0094] Taking the touch operation as a touch click operation and the control corresponding to the click operation being the control of the note application icon as an example, the note application calls the columnar framework to obtain the layout information of the interface, and through the view system of the application framework layer, calls the image rendering library in the system library to draw and render the image, so as to display the corresponding interface of the note application on the screen (display screen).

[0095] Exemplarily, Figure 4 The following is a schematic diagram of the process for switching foreground running applications provided by the embodiments of the present application. As Figure 4 shown, taking the switching of the foreground running application to application A as an example, the process includes:

[0096] In response to a click operation on the icon of application A, the window manager identifies the control corresponding to the operation as the control of application A, starts application A, and creates a window corresponding to application A.

[0097] S401. The window manager determines that the foreground application is application A and transmits a message indicating that application A is the foreground running application to the view system. The message includes: the package name of application A.

[0098] S402. The view system transmits a message indicating that application A is the foreground running application to HWUI.

[0099] S403. HWUI determines cache value A according to the pre-stored corresponding relationship and the identifier of application A, and transmits a message indicating an application for cache to the memory module (allocate). The message includes: the package name of application A and cache value A. Adaptively, the memory allocation module configures the space of the cache pool as cache value A. This cache is used to store the image data of application A.

[0100] In the embodiments of the present application, HWUI can transmit a message for indicating an application for a cache to the memory allocation module through an interface integration library.

[0101] S404. After allocating the cache, the memory allocation module transmits the address of the cache pool to HWUI.

[0102] S405. After Application A is started, it transmits a message for indicating image processing to HWUI through the window manager and the view system. The message includes: the identifier of the image data downloaded by Application A, and the address of the memory corresponding to each image data. Adaptively, HWUI stores the image data in the cache pool.

[0103] Exemplarily, after Application A is started, it transmits a message for indicating image processing to HWUI through the window manager and the view system.

[0104] S406. After receiving the message for indicating image processing, HWUI saves the corresponding image data to the cache pool and transmits a rendering request to the GPU DDK of the hardware abstraction layer. The request includes: the identifier of each image data, and the address of the corresponding cache pool.

[0105] S407. The GPU DDK transmits the rendering request to the GPU driver.

[0106] S408. The GPU driver obtains the image data according to the address of the cache pool in the rendering request and transmits the image data to the GPU for rendering to obtain a rendered image.

[0107] S409. The GPU driver transmits the rendered image to the GPU DDK.

[0108] S410. The GPU DDK transmits the rendered image to the image composition system.

[0109] S411. The image composition system composes the rendered images and transmits the parameters of the composed layers to the image compositor of the hardware abstraction layer.

[0110] S412. The image compositor composes the parameters of the composed layers to obtain a composed interface and transmits the composed interface to the display driver. Adaptively, the display driver displays the composed image.

[0111] In the above embodiments, the information transmission between different modules can be implemented by calling interface functions. Exemplarily, Figure 5 This is a timing diagram of GPU task execution provided by the embodiments of the present application. As Figure 5 shown, the process includes:

[0112] S501. In response to a user operation, the main thread of the application creates a view and calls the render thread to render an image.

[0113] S502. The render thread of the application calls the OpenGL interface or the Vulkan interface in HWUI to transfer the rendering request to OpenGL or Vulkan.

[0114] S503. HWUI calls the GPU device development interface to transfer the rendering request to the GPU DDK.

[0115] S504. The GPU DDK calls the GPU driver interface to transfer the rendering request to the GPU driver.

[0116] S505. The GPU driver drives the hardware of the GPU to execute GPU tasks to render the image.

[0117] The following describes the cache adjustment method provided in the embodiments of the present application in conjunction with specific embodiments. Exemplarily, Figure 6 is a schematic flowchart of a cache adjustment method provided in the embodiments of the present application. As Figure 6 shown, the method includes:

[0118] S601. In response to the startup operation of Application A, the electronic device starts Application A and configures the space of the cache pool to a preset cache value.

[0119] The cache pool is used to store the image data of Application A. In this way, the repeated acquisition of the image data of Application A can be reduced, and the rendering time can be shortened.

[0120] S602. After Application A is started, the electronic device stores the image data of the interface of Application A in the cache pool for rendering.

[0121] S603. When a sliding operation is detected, continue to store the image data of the interface of Application A in the cache pool for rendering.

[0122] The sliding operation is one of the operations used to indicate switching the interface, and can also be replaced by other types of operations used to indicate switching the interface, such as a click operation, a voice control switching operation, etc. Specific limitations are not made here.

[0123] S604. When the space of the cache pool is not enough to store the image data of Application A, delete some or all of the previously stored image data in the cache pool and record the cache value corresponding to the deleted image data.

[0124] Specifically, when the remaining cache value in the cache pool is less than the cache value corresponding to the image data to be stored, delete some or all of the image data in the cache pool and store the image data to be stored.

[0125] Exemplarily, taking the space of the cache pool as 10M as an example, the cache value corresponding to the image data of interface A is 6M, and the cache value corresponding to the image data of interface B is 5M. When the electronic device stores the image data of interface B, it needs to delete 1M of the image data of interface A and then store the image data of interface B. At this time, the electronic device records the deleted cache value as 1M.

[0126] S605. In response to an operation for indicating to switch the application, the electronic device closes application A or runs application A in the background.

[0127] S606. The electronic device writes the package name of application A and the adjusted cache value into the whitelist. The adjusted cache value is related to the cache value of the deleted image data.

[0128] The whitelist can be stored in HWUI, and no specific limitation is made here. The whitelist can be in the form of a table or any other form, and no specific limitation is made here.

[0129] In some embodiments, during the foreground running of application A, when there is insufficient cache (that is, the image data of application A is deleted from the cache pool), the electronic device records the cache value corresponding to the deleted image data. If there are multiple cases of insufficient cache, the electronic device superimposes the cache values recorded in multiple cases of insufficient cache and writes the superimposed value and the preset cache value into the whitelist.

[0130] Exemplarily, during the foreground running of application A, there are two cases of insufficient cache. If the cache value of the image data deleted for the first time is cache value 1 and the cache value of the image data deleted for the second time is cache value 2. The electronic device writes the package name of application A, and the sum of the preset cache value, cache value 1, and cache value 2 into the whitelist.

[0131] In this way, the cache value exceeding the cache pool during one foreground running of application A is statistically counted to facilitate reducing the lag phenomenon when application A runs in the foreground subsequently.

[0132] In other embodiments, during the foreground running of application A, when there is insufficient cache (that is, the image data of application A is deleted from the cache pool), the electronic device records the cache value corresponding to the deleted image data. If there are multiple cases of insufficient cache, the electronic device selects the maximum value from the cache values recorded in multiple cases of insufficient cache and writes it into the whitelist together with the preset cache value.

[0133] Exemplarily, taking the cache value corresponding to interface A as cache value 1 and the cache value corresponding to interface B as cache value 2; both cache value A and cache value B are greater than the preset cache value. If cache value 1 is greater than cache value 2, the electronic device writes the package name of application A, and the sum of cache value 1 and the preset cache value into the whitelist.

[0134] In this way, it is possible to reduce the repeated recording of the application interface backtracking, reduce the situation where the adjusted cache value is too large, and reduce the situation where the space of the cache pool is adjusted too much.

[0135] The above calculation method for adjusting the cache value is only used as an example, and it can also be confirmed by other means, which is not specifically limited here. Exemplarily, the adjusted cache value can also be the sum of the cache value of the image data that the electronic device deletes from the cache pool for the first time during a foreground operation of Application A and a preset cache value. Or, the adjusted cache value can also be the average value of the cache values of the image data deleted from the cache pool during multiple foreground operations of Application A within a preset time period. In this way, randomness can be reduced.

[0136] S607. In response to the startup operation of Application A, the electronic device queries the whitelist.

[0137] S608. When the whitelist stores the package name of Application A, the electronic device configures the cache value of the cache pool according to the corresponding relationship stored in the whitelist.

[0138] Exemplarily, if the package name of Application A in the whitelist corresponds to cache value A, the cache pool is configured to cache value A.

[0139] It can be understood that when the whitelist does not store the package name of Application A, the cache pool is configured to a preset cache value.

[0140] In this way, when the electronic device detects insufficient cache, it records the cache corresponding to the application; subsequently, when running Application A, the cache pool is configured according to the recorded cache corresponding to the application, which can reduce the rendering delay caused by insufficient cache and reduce the stuttering of the application display.

[0141] Based on the above embodiments, when the cache value is greater than the threshold, the electronic device configures the cache value to the threshold when Application A starts. The threshold is greater than the preset cache value.

[0142] In this way, it is possible to reduce the situation where the cache value is too large, resulting in the electronic device running stutteringly due to excessive memory occupation of the electronic device, and improve the user experience.

[0143] The threshold can be a multiple of the preset cache value, 30M, or any value, which is not specifically limited here. Exemplarily, the threshold is three times the preset cache value.

[0144] Exemplarily, Figure 7 is a schematic diagram of the adjustment process of the cache pool corresponding to Application A provided by the embodiments of the present application. As Figure 7 shown,

[0145] When Application A is launched for the first time, the electronic device adjusts the space of the cache pool to a preset cache value. During the foreground operation of Application A, when the electronic device encounters a cache shortage, it records the cache value corresponding to the deleted image data. When Application A switches to the background or ends its operation, it updates and adjusts the cache value.

[0146] When Application A is launched for the second time, the electronic device adjusts the space of the cache pool to the adjusted cache value determined at the end of the first run. During the operation of Application A, when the electronic device encounters a cache shortage, it records the cache value corresponding to the deleted image data. When Application A switches to the background or ends its operation, it updates and adjusts the cache value.

[0147] When Application A is launched for the third time, the electronic device adjusts the space of the cache pool to the adjusted cache value determined at the end of the second run. During the operation of Application A, the electronic device does not encounter a cache shortage. When Application A switches to the background or ends its operation, it does not update and adjust the cache value.

[0148] When Application A is launched for the fourth to Nth times, the electronic device adjusts the space of the cache pool to the adjusted cache value determined at the end of the second run. If the electronic device does not encounter a cache shortage during the subsequent operation of Application A, the adjusted cache value determined at the end of the second run is used.

[0149] In this way, when it is detected during the first launch that the cache corresponding to the image data of the application exceeds the space of the cache pool, the space of the cache pool is increased to the adjusted cache value during the second launch, and the adjusted cache value is used during the third and subsequent launches, and the previous exceeding problem will no longer be cleared. The application does not need to repeatedly download the image data of the interface during operation, reducing the time-consuming for downloading image data and reducing the display lag phenomenon of the electronic device.

[0150] Based on the above embodiments, after the electronic device records and adjusts the cache value, it records the adjustment time. After a preset duration of this adjustment time, if the adjusted cache value is not updated, the electronic device reduces the adjusted cache value by a certain proportion.

[0151] The preset duration can be 7 days or 15 days, and no specific limitation is made here. The certain proportion can be 0.1 or 0.2, and no specific limitation is made here.

[0152] Exemplarily, taking the adjusted cache value as 20M and the certain proportion as 0.1 as an example, the reduced adjusted cache value is 18M.

[0153] In this way, after a period of time, the space of the cache pool is lowered, reducing the memory occupation during the application operation.

[0154] The following is combined with Figures 8 to 11Describe the caching process of the cache pool when Application A runs.

[0155] Exemplarily, Figure 8 This is a schematic flowchart of an application interface display provided by an embodiment of the present application. As Figure 8 shown, the process includes: The process of Application A includes: the main thread and the rendering thread of Application A.

[0156] S801. In response to the startup operation of Application A, the window manager calls the process of Application A to start Application A.

[0157] S802. The window manager transmits a message indicating that the foreground running application is Application A to HWUI. This message includes: the package name of Application A.

[0158] The package name of Application A is one of the identifiers of Application A. The package name of Application A can also be replaced with other identifiers of Application A. For example, the name of Application A, the index value of Application A, etc. are not specifically limited here.

[0159] S803. After receiving the message in S602, HWUI transmits a message indicating cache adjustment to the memory allocation module. This message includes: a preset cache value and the package name of Application A.

[0160] S804. The memory allocation module configures the space of the cache pool to the preset cache value and transmits the address of the cache pool to HWUI. The cache pool is used to cache the image data of Application A.

[0161] The preset cache value can be 5M, or it can be 10M or any value, which is not specifically limited here.

[0162] S805. Application A downloads the image data of Interface 1 and transmits a message indicating the rendering of Interface 1 to HWUI. This message includes: the location information where the image data of Interface 1 is stored, and the cache value 1 of the image data in Interface 1.

[0163] In some embodiments, this message further includes: the identifier of Interface 1, which is convenient for subsequent differentiation of the image data of the interface and selection of the deleted image data. The identifier of Interface 1 can be the name of Interface 1, the index value of Interface 1, etc., which is not specifically limited here.

[0164] In some embodiments, Application A can transmit a message indicating the rendering of Interface 1 to HWUI after all the image data of Interface 1 is downloaded; Application A can also download the image data of Interface 1 in multiple times and transmit messages indicating the rendering of Interface 1 to HWUI in multiple times, which is not specifically limited here.

[0165] Application A can also transmit a message indicating the rendering of Interface 1 to HWUI through the window manager.

[0166] When the cached value 1 of S806 and HWUI is less than the preset cached value, the image data of Interface 1 is stored in the cache pool.

[0167] S807, HWUI calls the GPU DDK to render Interface 1.

[0168] After being called, the GPU DDK obtains the image data of Interface 1 from the cache pool for rendering.

[0169] The specific process can refer to the process Figure 5 shown above and will not be elaborated here.

[0170] S808, in response to the interface switching operation, Application A downloads the image data in Interface 2 and transmits a message to HWUI for indicating to render Interface 2.

[0171] This message includes: the location information where the image data in Interface 2 is stored, and the cached value 2 of the image data in Interface 2. The location information can be the stored address and is not specifically limited here.

[0172] In some embodiments, this message further includes: the identifier of Interface 2, which is convenient for subsequent differentiation of the image data of the interface and selection of the image data to be deleted. The identifier of Interface 2 can be the name of Interface 2, the index value of Interface 2, etc., and is not specifically limited here.

[0173] In some embodiments, Application A can transmit a message to HWUI for indicating to render Interface 2 after all the image data of Interface 2 is downloaded; Application A can also download the image data of Interface 2 in multiple times and transmit messages to HWUI for indicating to render Interface 2 in multiple times, which is not specifically limited here.

[0174] S809, HWUI determines whether the remaining cached value is less than the cached value 2. The remaining cached value refers to the cached value corresponding to the unoccupied space in the cache pool.

[0175] In the case where the remaining cached value is less than the cached value 2, the electronic device executes S810 and S811. Specifically, the image data of Interface 1 is deleted and the image data of Interface 2 is stored in the cache pool; in the case where the remaining cached value is greater than the cached value 2 of Interface 2, the electronic device executes S811 and stores the image data of Interface 2 in the cache pool.

[0176] S810, in the case where the remaining cached value is less than the cached value 2, HWUI deletes the image data of Interface 1 stored in the cache pool and records the cached value a, where the cached value a is the cached value of the space occupied by the deleted image data of Interface 1.

[0177] In the embodiments of the present application, the cache can be understood as a first-in, first-out queue. When the space in the cache pool is insufficient, the cache pool can delete the earliest stored image data to store subsequent image data.

[0178] S811. HWUI stores the image data of interface 2 in the cache pool.

[0179] S812. HWUI calls the GPU DDK to render interface 2.

[0180] After being called, the GPU DDK obtains the image data of interface 1 from the cache pool for rendering.

[0181] The specific process can refer to the process shown above Figure 5 and will not be elaborated here.

[0182] S813. In response to the interface rollback operation, application A transmits a message to HWUI for instructing to roll back interface 1.

[0183] S814. HWUI transmits a message to application A for instructing retransmission.

[0184] S815. Application A redownloads the image data of interface 1 and transmits a message to HWUI for instructing to obtain the image data in interface 1. This message includes: the location information where the image data in interface 1 is stored, and the cache value 1 of the image data in interface 1.

[0185] Specifically, it can refer to the corresponding description above and will not be elaborated here.

[0186] S816. HWUI stores the image data of interface 1 in the cache pool.

[0187] S817. HWUI calls the GPU DDK to render interface 1.

[0188] After being called, the GPU DDK obtains the image data of interface 1 from the cache pool for rendering.

[0189] The specific process can refer to the process shown above Figure 5 and will not be elaborated here.

[0190] S818. In response to the operation of running application B in the foreground while application A is running in the background, the window manager transmits a message to HWUI for instructing that the foreground running application is application B. This message includes: the package name of application B.

[0191] S819. HWUI stores the package name of application A and cache value A. Cache value A is the sum of the preset cache value and the cache value occupied by the deleted image data.

[0192] In this way, when the electronic device runs application A in the foreground, the cache pool can be configured to cache value A. When it subsequently returns from interface 2 to interface 1, there is no need to re-download the image data corresponding to interface 1, which shortens the data retransmission time, reduces rendering time, and reduces display jams.

[0193] For example, Figure 9 A method provided in the embodiment of the present application Figure 8 The cache diagram corresponding to application A is shown in FIG. Figure 9 As shown, after application A is started, the electronic device adjusts the size of the cache pool 901 to a preset cache value.

[0194] After application A downloads the image data of interface 1, HWUI determines that the image data of interface 1 does not exceed the preset cache value, and stores the image data of interface 1 in the cache pool.

[0195] After application A downloads the image data of interface 2, HWUI determines that the image data of interface 2 exceeds the remaining space in the cache pool, HWUI deletes the image data of interface 1 in the cache pool, releases part of the memory, and stores the image data of interface 2 in the cache pool.

[0196] In response to the rollback operation, the HWUI determines that the cache pool does not include the image data of the interface 1. The HWUI transmits a message for instructing the application A to download the image data of the interface 1. The application A downloads the image data of the interface 1.

[0197] HWUI determines that the image data of interface 1 does not exceed the remaining space of the buffer pool, and stores the image data of interface 1 in the buffer pool.

[0198] For example, Figure 10 A schematic diagram of a flow chart of an application interface display provided in an embodiment of the present application. Figure 10 As shown, the process includes: the process of application A includes: the main thread and rendering thread of application A.

[0199] S1001. In response to a start operation of application A, the window manager calls the process of application A to start application A.

[0200] S1002: The window manager transmits a message to the HWUI indicating that the foreground application is application A. The message includes: the package name of application A.

[0201] The package name of application A is one of the identifiers of application A. The package name of application A may also be replaced by other identifiers of application A, such as the name of application A, the index value of application A, etc., which is not specifically limited here.

[0202] S1003. After receiving the message in S602, HWUI transmits a message for instructing cache adjustment to the memory module. The message includes: cache value A and the package name of Application A.

[0203] S1004. The memory allocation module configures the space of the cache pool to cache value A and transmits the address of the cache pool to HWUI. The cache pool is used to cache the image data of Application A.

[0204] The preset cache value can be 5M, or 10M, or any value, and no specific limitation is made here.

[0205] S1005. Application A downloads the image data of Interface 1 and transmits a message for instructing to render Interface 1 to HWUI.

[0206] The message includes: the location information where the image data in Interface 1 is stored, and cache value 1 of the image data in Interface 1.

[0207] Specifically, it can refer to the corresponding description above, and details are not repeated here.

[0208] S1006. When cache value 1 is less than the preset cache value, HWUI stores the image data of Interface 1 into the cache pool.

[0209] S1007. HWUI calls GPU DDK to render Interface 1.

[0210] After being called, GPU DDK obtains the image data of Interface 1 from the cache pool for rendering.

[0211] The specific process can refer to the Figure 5 process shown above, and details are not repeated here.

[0212] S1008. In response to the interface switching operation, Application A downloads the image data of Interface 2 and transmits a message for instructing to render Interface 2 to HWUI.

[0213] The message includes: the location information where the image data in Interface 2 is stored, and cache value 2 of the image data in Interface 2.

[0214] S1009. HWUI determines whether the remaining cache value is less than cache value 2. The remaining cache value refers to the cache value corresponding to the unoccupied space in the cache pool.

[0215] S1010. When the remaining cache value is greater than or equal to cache value 2, HWUI stores the image data of Interface 2 into the cache pool.

[0216] In the embodiments of the present application, the cache can be understood as a first-in, first-out queue. When the space of the cache pool is insufficient, the cache pool can delete the earliest stored image data to store subsequent image data.

[0217] S1011. The HWUI calls the GPU DDK to render Interface 2.

[0218] After being called, the GPU DDK obtains the image data of Interface 2 from the cache pool and performs rendering.

[0219] The specific process can refer to the process Figure 5 shown above and will not be elaborated here.

[0220] S1012. In response to the interface rollback operation, Application A transmits a message for instructing to roll back Interface 1 to the HWUI.

[0221] S1013. The HWUI calls the GPU DDK to render Interface 1.

[0222] After being called, the GPU DDK obtains the image data of Interface 1 from the cache pool and performs rendering.

[0223] The specific process can refer to the process Figure 5 shown above and will not be elaborated here.

[0224] S1013. In response to the operation of running Application B in the foreground while Application A is running in the background, the window manager transmits a message for instructing that the foreground running application is Application B to the HWUI. This message includes: the package name of Application B.

[0225] When the electronic device runs Application A in the foreground, the cache pool is configured as cache value A. Compared with the process Figure 6 shown above, when the electronic device rolls back from Interface 2 to Interface 1, there is no need to redownload the image data corresponding to Interface 1, shortening the data retransmission time, reducing the rendering time, and reducing the display stuttering.

[0226] Exemplarily, Figure 11 is a cache schematic diagram corresponding to Application A provided by the embodiments of the present application. As Figure 10 shown, after Application A is started, the electronic device adjusts the size of the cache pool to the preset cache value. Figure 11 shown, after Application A downloads the image data of Interface 1, the HWUI determines that the image data of Interface 1 does not exceed cache value A and stores the image data of Interface 1 in the cache pool.

[0227] After Application A downloads the image data of Interface 1, the HWUI determines that the image data of Interface 1 does not exceed cache value A and stores the image data of Interface 1 in the cache pool.

[0228] After downloading the image data of interface 2 in Application A, HWUI determines that the image data of interface 2 does not exceed the remaining space of the cache pool, and HWUI stores the image data of interface 2 into the cache pool.

[0229] In response to a back operation, HWUI determines that the image data of interface 1 is stored in the cache pool, and calls the GPU for rendering.

[0230] In this way, there is no need to retransmit the image data of downloading interface 1, shortening the retransmission time and reducing the jamming phenomenon.

[0231] The above embodiments are described by taking the example of increasing the cache value corresponding to the deleted image data in the cache pool. In some embodiments, the cache pool also adds a cache value corresponding to the extended cache.

[0232] Exemplarily, Figure 12 is a schematic flow diagram of an application interface display provided by an embodiment of the present application. As Figure 12 shown, the flow includes: The process of Application A includes: the main thread and the rendering thread of Application A.

[0233] S1201. In response to the start operation of Application A, the window manager calls the process of Application A to start Application A.

[0234] S1202. The window manager transmits a message indicating that the foreground running application is Application A to HWUI. This message includes: the package name of Application A.

[0235] The package name of Application A is one of the identifiers of Application A. The package name of Application A can also be replaced with other identifiers of Application A, for example, the name of Application A, the index value of Application A, etc., which are not specifically limited here.

[0236] S1203. After receiving the message in S602, HWUI transmits a message indicating cache adjustment to the memory allocation module. This message includes: a preset cache value and the package name of Application A.

[0237] S1204. The memory allocation module configures the space of the cache pool to the preset cache value and transmits the address of the cache pool to HWUI. The cache pool is used to cache the image data of Application A.

[0238] The preset cache value can be 5M, can also be 10M or any value, which is not specifically limited here.

[0239] S1205. Application A downloads the image data of interface 1 and transmits a message indicating rendering interface 1 to HWUI.

[0240] Specifically, reference can be made to the corresponding description above, which will not be elaborated here.

[0241] When the cache corresponding to the image data of the interface 1 in HWUI is greater than the preset cache value, HWUI transmits a message for indicating cache expansion to the memory allocation module. The message includes: cache expansion value 1.

[0242] S1207. The memory allocation module allocates an expanded cache and transmits the address of the expanded cache to HWUI. The space of the expanded cache is cache expansion value 1. The expanded cache is used to cache the image data of application A.

[0243] S1208. HWUI stores the image data of interface 1 into the cache pool and the expanded cache 1.

[0244] S1209. HWUI calls GPU DDK to render interface 1.

[0245] After being called, GPU DDK obtains the image data of interface 1 from the memory module for rendering. It can be understood that the expanded cache 1 is a temporary cache and is deleted after GPU DDK module obtains the image data of interface 1.

[0246] The specific process can refer to the Figure 5 process shown above and will not be elaborated here.

[0247] S1210. In response to the user's swipe operation, application A downloads the image data in interface 2 and transmits a message for indicating the rendering of interface 2 to HWUI.

[0248] Specifically, it can refer to the corresponding description above and will not be elaborated here.

[0249] The message includes: the location information where the image data in interface 2 is stored, and cache value 2 of the image data in interface 2.

[0250] S1211. HWUI determines whether the remaining cache value is less than cache value 2. The remaining cache value refers to the cache value corresponding to the unoccupied space in the cache pool.

[0251] S1212. In the case where the remaining cache value is less than cache value 2, HWUI deletes the image data of interface 1 stored in the cache pool and records cache value a. Cache value a is the cache value of the space occupied by the deleted image data of interface 1. S1213. HWUI saves the image data of interface 2 in the cache pool.

[0252] S1214. HWUI calls GPU DDK to render interface 2.

[0253] After being called, GPU DDK obtains the image data of interface 2 from the memory module for rendering.

[0254] The HWUI determines that the cache exceeds the range and transmits a message requesting to expand cache B to the memory allocation module.

[0255] S1215. In response to the operation of running application B in the foreground while application A is running in the background, the window manager transmits a message to the HWUI indicating that the foreground running application is application B. The message includes: the package name of application B.

[0256] S1216. The HWUI stores the package name of application A and cache value A. Cache value A is the sum of the preset cache value, the cache value occupied by the deleted image data, and the expanded cache value.

[0257] In this way, when the subsequent electronic device runs application A in the foreground, the cache pool can be configured as cache value A. Subsequently, when backing off from interface 2 to interface 1, there is no need to re-download the image data corresponding to interface 1, shortening the data retransmission time, reducing the rendering time, and reducing display stuttering. Exemplarily, Figure 13 is a storage schematic diagram of the cache pool during the use of an application in a possible design. As Figure 12 shown, after application A is started, the electronic device adjusts the size of cache pool 1301 to the preset cache value.

[0258] After the HWUI receives the image data of interface 1 and the image data of interface 1 exceeds the preset cache value, the HWUI applies for an expanded cache, and the electronic device allocates an expanded cache 1302. The cache pool 701 and the expanded cache 1302 store the image data of interface 1. After the rendering of interface 1 is completed, the electronic device deletes the expanded cache 1302.

[0259] After the HWUI receives the image data of interface 2 and the image data of interface 2 does not exceed the preset cache value, the electronic device deletes the image data of interface 1, releases a part of the memory, and stores the image data of interface 2. The cache pool 1301 stores the image data of interface 2.

[0260] After application A is closed, the electronic device adjusts the size of cache pool 1301 to the preset cache value. The cache pool 1301 is used for the image data of the desktop application.

[0261] Exemplarily, Figure 13 is a cache schematic diagram corresponding to application A provided by an embodiment of the present application. As Figure 12 shown, after application A is started, the electronic device adjusts the size of cache pool 1301 to the preset cache value. Figure 13 shown, after application A is started, the electronic device adjusts the size of cache pool 1301 to the preset cache value.

[0262] After the HWUI receives the image data of Interface 1 and the image data of Interface 1 exceeds the preset cache value, the HWUI applies for cache expansion, and the electronic device allocates the expanded cache 1302. The cache pool 1301 and the expanded cache 1302 store the image data of Interface 1. After the rendering of Interface 1 is completed, the electronic device deletes the expanded cache 1302.

[0263] After the HWUI receives the image data of Interface 2 and the image data of Interface 2 exceeds the remaining cache value, the electronic device deletes the image data of Interface 1, releases a part of the memory, and stores the image data of Interface 2. The cache pool 1301 stores the image data of Interface 2.

[0264] After Application A is closed, the electronic device adjusts the size of the cache pool 1301 to the preset cache value. The cache pool 1301 is used for the image data of the desktop application.

[0265] It can be understood that in the above embodiments, one interface can correspond to one or more graphs. In some embodiments, one frame of image includes one graph, and the cache occupied by the image data corresponding to one graph exceeds the preset cache value. In other embodiments, one frame of image includes: multiple graphs. The cache occupied by the image data corresponding to multiple graphs exceeds the preset cache value. The embodiments of the present application do not make specific limitations on the number, size, etc. of the graphs in the interface.

[0266] The above embodiments are described by taking one startup of Application A as an example. In some embodiments, the electronic device can monitor the cache usage of Application A within a period of time to adjust the size of the cache pool corresponding to Application A.

[0267] Exemplarily, Figure 14 is a schematic flow chart of a cache adjustment method provided by an embodiment of the present application. As Figure 14 shown, the method includes:

[0268] S1401. In response to an operation of starting a first application, set the cache to a first value, and run the first application in the foreground based on the space of the cache.

[0269] The first operation can be an operation of the user clicking on the icon of the first application, or an operation of starting the first application through a shortcut (for example, a left swipe operation, etc.), or any operation, which is not specifically limited here. The first application can be any type of application such as a video application, a gallery application, etc., which is not specifically limited here. The first application can correspond to Application A in the above text.

[0270] The first value can be 20M, 10M, or any value, and no specific limitation is made here. Running the first application in the foreground based on the cache space can be understood as storing the image data downloaded by the first application in the cache control to render the corresponding interface for display. The cache space is used to store the image data of the interface displayed by the first application. The cache space can correspond to the above-mentioned cache pool.

[0271] S1402. In response to exiting the foreground operation of the first application and starting the second operation of the second application, set the cache space to the second value, run the second application in the foreground, and run the first application in the background; the first value is different from the second value.

[0272] The second operation can be any operation such as the operation of the user clicking the icon of the second application or the operation of starting the second application through a shortcut (such as a left-swipe operation, etc.), and no specific limitation is made here. The second application can be any type of application such as a video application, a gallery application, etc., and no specific limitation is made here. The second value can be 5M, 8M, or any value, and no specific limitation is made here.

[0273] S1403. In response to exiting the foreground operation of the second application and the third operation of running the first application in the foreground, set the cache space to the first value.

[0274] The third operation can be any operation such as the operation of the user clicking the icon of the first application or the operation of starting the first application through a shortcut (such as a left-swipe operation, etc.), and no specific limitation is made here.

[0275] In this way, the electronic device can dynamically adjust the cache size according to the application running in the foreground. When the cache usage of the application is large within a preset time period, increase the cache value to reduce the lag in application display; when the cache usage of the application is small within a preset time period, lower the cache value to reduce the memory occupation of the application.

[0276] In a possible implementation manner, setting the cache space to the first value in response to the first operation of starting the first application includes: in response to the first operation, confirm the first value according to the identifier of the first application and the corresponding relationship between the identifier of the application and the cache value; set the cache space to the first value through the hardware acceleration rendering module.

[0277] The identifier of the first application is used to distinguish the first application. The identifier can be the package name of the first application, the name of the first application, etc., and no specific limitation is made here. The cache value can correspond to the adjusted cache value in the above text, and no specific limitation is made here. The hardware acceleration rendering module corresponds to the HWUI in the above text.

[0278] In this way, the electronic device stores the corresponding relationship, which is convenient for obtaining the first value. The method is simple and easy to implement. In addition, the first value can be obtained through HWUI and configured.

[0279] In a possible implementation, in response to a first operation, according to the identifier of a first application and the correspondence between the identifier of the application and the cache value, a first value is confirmed, including: in response to the first operation, the window manager transmits a first message to the hardware-accelerated rendering module, the first message being used to indicate that the first application is running in the foreground, and the first message includes: the identifier of the first application; in response to the first message, the hardware-accelerated rendering module confirms the first value according to the identifier of the first application and the correspondence between the identifier of the application and the cache value.

[0280] The correspondence can be stored in a table, list or any form. No specific limitation is made here.

[0281] In this way, the first value can be obtained through HWUI and the first value can be configured.

[0282] In a possible implementation, the hardware-accelerated rendering module sets the cache space to the first value, including: the hardware-accelerated rendering module transmits a first message to the memory allocation module, the first message being used to indicate that the cache space is configured to the first value, and the first message includes: the identifier of the first application and the first value; the memory allocation module transmits a second message to the hardware-accelerated rendering module, and the second message includes the cache address; the cache address is used to confirm the location of the cache space.

[0283] In a possible implementation, the first value is related to the cache value corresponding to the image data deleted from the cache space before the first operation.

[0284] In a possible implementation, before the first operation, the method further includes: in response to a sixth operation of starting the first application, setting the cache space to a third value and running the first application in the foreground; during the period when the first application is running in the foreground, storing the image data of the interface of the first application in the cache space to render the interface of the first application, the third value being less than the first value; when the cache space is less than the image data of the interface of the first application, deleting all or part of the image data of the first application and recording the cache value corresponding to the deleted image data; in response to a seventh operation of exiting the foreground running of the first application, running the first application in the background and saving the first value.

[0285] The first value is the sum of the third value and the fourth value; or, the first value is a preset value, the preset value being less than the sum of the third value and the fourth value, the fourth value being the sum of the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation; or, the first value is the sum of the third value and the fifth value; or, the first value is a preset value, the preset value being less than the sum of the third value and the fifth value; the fifth value is the maximum value among the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation.

[0286] The sixth operation can be an operation where the user clicks on the icon of the first application, or an operation to launch the first application via a shortcut (e.g., a left - swipe operation, etc.), or any operation, which is not specifically limited here. The third value can be 5M, 8M, or any value, which is not specifically limited here.

[0287] The seventh operation can be an operation where the user clicks to return and exit the first application, an operation where the user clicks on the icon of the second application, or an operation to launch the second application via a shortcut (e.g., a left - swipe operation, etc.), or any operation, which is not specifically limited here.

[0288] The cache space being less than the image data of the interface of the first application means that the remaining space of the cache (the unoccupied space) is less than the image data of the interface of the first application, or it can be understood that the cache value corresponding to the remaining space of the cache is less than the cache value corresponding to the image data of the interface of the first application that needs to be stored (the image data of the interface downloaded by the first application).

[0289] The preset value can be 30M, 60M, or any value, which is not specifically limited here. In this way, it is possible to reduce the situation where the cache space corresponding to an application occupies too much memory, and reduce the insufficient running memory and decreased fluency of the electronic device.

[0290] In this way, when the cache is insufficient, the deleted image data is recorded to facilitate subsequent adjustment of the cache space corresponding to the application.

[0291] In a possible implementation, during the foreground running of the first application, the method includes: in response to the sixth operation, storing the image data of the first interface in the cache space to render the first interface; in response to the eighth operation, when the cache space is less than the image data of the second interface, deleting all or part of the image data of the first interface from the cache space and recording the sixth value, where the sixth value is the image data of the first interface deleted from the cache space; after deleting all or part of the image data of the first interface, storing the image data of the second interface in the cache space to render the second interface; the first value is the sum of the third value and the sixth value.

[0292] The eighth operation can be a right - swipe operation by the user, an operation where the user clicks on any control in the first interface, or any type of operation, which is not specifically limited here. The first interface can correspond to interface 1 in the above text; the second interface can correspond to interface 2 in the above text. The eighth operation can correspond to the switching operation, sliding operation, etc. in the above text.

[0293] In this way, it can be applied to the situation where the image data of two interfaces in an application exceeds the cache.

[0294] In a possible implementation, during the foreground running of the first application, the method includes: in response to a sixth operation, storing the image data of the first interface in the cache space to render the first interface; in response to an eighth operation, when the cache space is smaller than the image data of the second interface, deleting all the caches of the first interface, configuring the expanded cache space to a seventh value, and recording an eighth value, where the eighth value is the sum of the image data of the first interface deleted from the cache space and the seventh value; storing the image data of the second interface in the cache space and the expanded cache space to render the second interface; the first value is the sum of the third value and the eighth value, or the first value is a preset value, and the preset value is smaller than the sum of the third value and the eighth value.

[0295] The expanded cache space may correspond to the expanded cache in the above text. The eighth operation may refer to the corresponding description above and will not be elaborated here.

[0296] In this way, it can be applied to the situation where the image data of an interface exceeds the cache.

[0297] The above embodiments illustrate the process of increasing the cache space. In some embodiments, the electronic device can also reduce the cache space.

[0298] Based on the above embodiments, the electronic device records the adjustment time each time it adjusts the cache value corresponding to the first application. During a preset duration of this adjustment time, if the electronic device does not update the adjustment time. After the preset duration of this adjustment time, the electronic device reduces the cache value corresponding to the first application by a certain proportion.

[0299] The preset duration can be 7 days or 15 days, and no specific limitation is made here. The certain proportion can be 0.1 or 0.2, and no specific limitation is made here.

[0300] Exemplarily, taking the cache value corresponding to the first application as 20M and the certain proportion as 0.1 as an example, the cache value corresponding to the first application after reduction after the preset duration is 18M.

[0301] It should be noted that the module names involved in the embodiments of the present application can all be defined as other names, as long as the functions of each module can be realized, and no specific limitation is made on the module names.

[0302] 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 for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for the user to choose to authorize or refuse.

[0303] The cache adjustment method of the embodiments of the present application has been described above. Next, the apparatus for executing the above method provided by the embodiments of the present application will be described. Those skilled in the art can understand that the method and the apparatus can be combined and cited with each other, and the relevant apparatus provided by the embodiments of the present application can execute the steps in the above method.

[0304] The cache adjustment method provided by the embodiments of the present application can be applied to an electronic device with communication functions. The electronic device includes a terminal device. The specific device form of the terminal device and the like can refer to the above relevant description, which will not be elaborated here.

[0305] The embodiments of the present application provide an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code. The computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the above method.

[0306] The embodiments of the present application provide a chip. The chip includes a processor, and the processor is used to call the computer program in the memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those of the above relevant embodiments, which will not be elaborated here.

[0307] The present application provides a chip or a chip system, which includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the above method. Among them, the communication interface in the chip can be an input / output interface, a pin, a circuit, etc.

[0308] 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 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. The computer-readable medium can include a computer storage medium and a communication medium, 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 accessible by a computer.

[0309] In one possible implementation, the computer-readable medium may include RAM, ROM, a compact disc read-only memory (CD-ROM), or other optical disc storage, magnetic disk storage, or any other medium targeted to carry or store the required program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is properly termed a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. As used herein, disk and optical disc include optical disc, laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, and Blu-ray disc, where disks typically reproduce data magnetically, while optical discs utilize lasers to optically reproduce data. Combinations of the above should also be included within the scope of computer-readable media.

[0310] An embodiment of the present application provides a computer program product. The computer program product includes a computer program that, when run, causes a computer to execute the above method.

[0311] Embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to generate a machine such that the instructions executed by the processing unit of the computer or other programmable data processing device generate means for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0312] The above specific implementation manners further elaborate the purpose, technical solutions, and beneficial effects of the present invention. It should be understood that the above are only specific implementation manners of the present invention and are not used to limit the protection scope 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 within the protection scope of the present invention.

Claims

1. A cache adjustment method, characterized in that, Including: In response to a first operation to start a first application, setting the cache space to a first value, and running the first application in the foreground based on the cache space; In response to exiting the foreground running of the first application and a second operation to start a second application, setting the cache space to a second value, running the second application in the foreground, and running the first application in the background; the first value is different from the second value; In response to exiting the foreground running of the second application and a third operation to run the first application in the foreground, setting the cache space to the first value.

2. The method according to claim 1, wherein The step of, in response to a first operation to start a first application, setting the cache space to a first value, includes: In response to the first operation, based on the identifier of the first application and the correspondence between the application identifier and the cache value, determining the first value; Setting the cache space to the first value through a hardware acceleration rendering module.

3. The method according to claim 2, wherein The step of, in response to the first operation, based on the identifier of the first application and the correspondence between the application identifier and the cache value, determining the first value, includes: In response to the first operation, a window manager transmits a first message to the hardware acceleration rendering module, the first message being used to indicate that the first application is running in the foreground, and the first message includes: the identifier of the first application; In response to the first message, the hardware acceleration rendering module determines the first value based on the identifier of the first application and the correspondence between the application identifier and the cache value.

4. The method according to claim 2 or 3, characterized in that, The step of setting the cache space to the first value through a hardware acceleration rendering module includes: The hardware acceleration rendering module transmits a first message to a memory allocation module, the first message being used to indicate configuring the cache space to the first value, and the first message includes: the identifier of the first application and the first value; The memory allocation module transmits a second message to the hardware acceleration rendering module, and the second message includes the address of the cache; the address of the cache is used to determine the location of the cache space.

5. The method according to any one of claims 1-4, characterized in that, The first value is related to the cache value corresponding to the image data deleted from the cache space before the first operation.

6. The method according to claim 5, wherein Before the first operation, the method further includes: In response to a sixth operation to start the first application, setting the cache space to a third value and running the first application in the foreground; During the foreground running of the first application, storing the image data of the interface of the first application in the cache space to render the interface of the first application, and the third value is less than the first value; When the cache space is less than the image data of the interface of the first application, deleting all or part of the image data of the first application and recording the cache value corresponding to the deleted image data; In response to a seventh operation to exit the foreground running of the first application, running the first application in the background and saving the first value. The first value is the sum of the third value and the fourth value; alternatively, the first value is a preset value, the preset value is less than the sum of the third value and the fourth value, and the fourth value is the sum of the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation; Alternatively, the first value is the sum of the third value and the fifth value; alternatively, the first value is a preset value, the preset value is less than the sum of the third value and the fifth value; the fifth value is the maximum value among the cache values of the image data deleted from the cache space by the first application during the sixth operation to the seventh operation.

7. The method according to claim 6, wherein During the foreground operation of the first application, the method includes: In response to the sixth operation, storing the image data of the first interface in the cache space to render the first interface; In response to the eighth operation, when the cache space is less than the image data of the second interface, deleting all or part of the image data of the first interface from the cache space, and recording the sixth value, where the sixth value is the image data of the first interface deleted from the cache space; After deleting all or part of the image data of the first interface, storing the image data of the second interface in the cache space to render the second interface; The first value is the sum of the third value and the sixth value.

8. The method according to claim 6, wherein During the foreground operation of the first application, the method includes: In response to the sixth operation, storing the image data of the first interface in the cache space to render the first interface; In response to the eighth operation, when the cache space is less than the image data of the second interface, deleting all the caches of the first interface, configuring the expanded cache space as the seventh value, and recording the eighth value, where the eighth value is the sum of the image data of the first interface deleted from the cache space and the seventh value; storing the image data of the second interface in the cache space and the expanded cache space to render the second interface; The first value is the sum of the third value and the eighth value, or the first value is a preset value, the preset value is less than the sum of the third value and the eighth value.

9. An electronic device, characterized in that, Comprising: A processor and a memory; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory, so that the electronic device executes the method described in any one of claims 1-8.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method described in any one of claims 1-8.

11. A chip system, characterized in that, Comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in any one of claims 1-8.

12. A computer program product, characterized in that, Comprising a computer program, when the computer program is run, it causes the computer to execute the method described in any one of claims 1-8.