Frozen screen processing method and electronic device
By detecting and redrawing transparent or abnormal components of electronic devices, the screen freezing problem can be resolved, component responsiveness can be quickly restored, and waiting time and resource waste can be reduced.
Patent Information
- Application Number
- PCT/CN2025/088071
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-17
- Filing Date
- 2025-04-09
- Publication Date
- 2025-12-26
AI Technical Summary
Electronic devices may experience screen freezing issues during interface loading, causing components to become unresponsive to user actions and affecting the user experience.
By detecting whether a component responds to user actions, if there is no response, the electronic device partially redraws transparent or abnormal components to restore their responsiveness and reduce waiting time.
Quickly resolve screen freezing issues, reduce user waiting time, save resources, and improve user experience.
Smart Images

Figure CN2025088071_26122025_PF_FP_ABST
Abstract
Description
Freezing screen processing method and electronic device
[0001] The present application claims priority to the Chinese patent application No. 202410783384.2, filed on June 17, 2024, entitled "Freezing screen processing method and electronic device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the technical field of terminal, and in particular to a freezing screen processing method and an electronic device. BACKGROUND
[0003] When the electronic device is loading an interface, it may appear abnormal or error, resulting in that the component does not respond to the user operation, that is, the freezing screen problem. The freezing screen problem will affect the user experience of using the electronic device. SUMMARY
[0004] The present application provides a freezing screen processing method and an electronic device. When the component does not respond to the user operation acting on the component, the electronic device can redraw the component locally, so that the component quickly recovers the response, thereby solving the freezing screen problem and reducing the waiting time of the user.
[0005] In a first aspect, the present application provides a freezing screen processing method. The electronic device displays a first interface, and the first interface includes a first component. The electronic device detects a first operation acting on the first component. When the first component does not respond to the first operation, the electronic device redraws the first component. When the first component responds to the first operation, the electronic device displays the response result of the first component to the first operation.
[0006] The first operation can include but is not limited to a click operation, a touch operation, a long press operation, a double-click operation, a knuckle gesture operation, etc.
[0007] It can be seen that the above method can detect whether the electronic device freezes according to whether the component displayed on the screen responds to the user operation, and when the electronic device freezes, the component used by the user quickly recovers the response by redrawing the component, so as to quickly solve the freezing screen problem and reduce the waiting time of the user. In this way, the situation that the electronic device restarts the related application to solve the freezing screen problem can be reduced, and the resources of the electronic device are saved.
[0008] In some embodiments, the first component has the ability to respond to the first operation.
[0009] It can be understood that the first component does not respond to the first operation in the case of having the ability to respond to the first operation, which can be caused by an abnormality in the electronic device when drawing the first component. The above-mentioned abnormality in the drawing process is usually single. The electronic device can no longer have the abnormality when redrawing the first component. Then, the first component after redrawing can respond to the user operation acting on the first component in time.
[0010] In combination with the first aspect, in some embodiments, before the electronic device redraws the first component, the first component is a transparent component displayed in the foreground; after the electronic device redraws the first component, the first component is a non-transparent component displayed in the foreground.
[0011] When the first component is a transparent component displayed in the foreground and has the ability to respond to the first operation, the electronic device can redraw the first component. If the first component has the ability to respond to the first operation, the first component should be visible to the user under the condition of normal loading of the first interface, so that the user can operate the first component. However, if the first component is a transparent component displayed in the foreground and the first component has the ability to respond to the first operation, the first component can be abnormal during drawing, resulting in that the first component is not visible to the user. And although the first component has the ability to respond to the first operation, the first component often has no response to the first operation in the transparent display state.
[0012] Since the above-mentioned interface loading abnormality that causes the first component to be drawn as a transparent component is usually single, the electronic device can no longer have the abnormality when redrawing the first component. Then, the electronic device redraws the first component with a high probability to display the first component as a non-transparent component, so that the first component quickly recovers the response to the first operation.
[0013] In combination with the first aspect, in some embodiments, the first component is a non-transparent component displayed in the foreground. Wherein the first operation includes k times of second operations, and k is a positive integer greater than 1. When the first component is a non-transparent component displayed in the foreground and does not respond to the second operation for k times, the electronic device can redraw the first component.
[0014] It can be understood that one or more components displayed on the screen may need a certain time to respond to user operations. If k is 1, the electronic device redraws the first component when it detects that the first component does not respond to the second operation within a preset time for only once. However, the above-mentioned first component can actually respond to the user operation, but the response speed is slow. Then, the above-mentioned redrawing of the component leads to the waste of resources of the electronic device. Therefore, the electronic device redraws the first component when the first component does not respond to the second operation for multiple times in succession, which can reduce the case of redrawing non-abnormal components by the electronic device and reduce the waste of resources of the electronic device.
[0015] In addition, the first component is displayed in the foreground and is visible to the user. If the user urgently needs to use the first component, the user usually performs user operations on the first component multiple times in a short time. For example, after the user clicks the first component once and does not obtain corresponding user interaction feedback, the user may click the first component multiple times to obtain corresponding user interaction feedback. Considering the urgency of the user to use the first component, the electronic device can first handle the freeze problem by redrawing the first component. If the redrawn first component can respond to the user operation on the first component in time, the electronic device can provide a response result of the first component to the user operation (for example, execute a function corresponding to the first component or open an interface corresponding to the first component), so that it is not necessary to restart the application associated with the first component. In this way, the electronic device can solve the freeze problem at the smallest possible cost, quickly restore the response of the component that the user needs to use, and reduce the waiting time of the user.
[0016] As can be known from the above embodiments, the electronic device can determine whether the electronic device freezes by detecting one or more of the following for a component that is acted on by a user operation: whether the component is displayed in the foreground, whether the component is displayed as a transparent component, whether the component has the ability to respond to the operation on the component, and whether the component responds to the operation on the component. The component that is a transparent component displayed in the foreground and has the ability to respond to the operation, or the component that is a non-transparent component displayed in the foreground and does not respond to the user operation on the component k times, can indicate that the electronic device freezes. Then, the electronic device can redraw the above-mentioned component that is acted on by the user operation, so as to quickly restore the response of the component to the user operation, thereby solving the freeze problem.
[0017] In combination with the first aspect, in some embodiments, the first component includes one or more sub-components, and the electronic device redraws the first component and the one or more sub-components.
[0018] In combination with the first aspect, in some embodiments, before the electronic device redraws the first component, the component ID of the first component is a first component ID; and after the electronic device redraws the first component, the component ID of the first component is a second component ID.
[0019] In combination with the first aspect, in some embodiments, in the case of redrawing the first component, other components in the first interface remain in a state of not being redrawn.
[0020] It can be seen that the first component is the component that the user needs to use because the first operation is performed on the first component. The other components in the first interface do not have the user operation performed thereon, which can indicate that the user does not need to use the other components temporarily. The electronic device can redraw the components partially, i.e., only redraw the component (e.g., the first component) that the user needs to use, without redrawing the other components in the first interface. This not only can save the resources of the electronic device, but also can reduce the time required for redrawing the components.
[0021] With reference to the first aspect, in some embodiments, after the electronic device redraws the first component, the electronic device detects a third operation performed on the first component, the third operation being of the same operation type as the first operation; and in response to the third operation, the electronic device performs a function corresponding to the first component or opens an interface corresponding to the first component.
[0022] It can be seen that, after the electronic device redraws the first component, the first component can resume responding to the user operation. In this way, the electronic device can not need to restart the process associated with the first component. The electronic device can solve the freeze problem at the least cost possible, so that the component that the user needs to use can quickly resume responding, and the waiting time of the user can be reduced.
[0023] With reference to the first aspect, in some embodiments, after the electronic device redraws the first component, the electronic device detects a fourth operation performed on the first component, the first component having the ability to respond to the fourth operation; and when the first component does not respond to the fourth operation, the electronic device restarts the process associated with the first component.
[0024] It can be seen that, if the first component still does not respond to the operation performed on the first component after the electronic device redraws the first component, the electronic device can restart the process associated with the first component to solve the freeze problem.
[0025] With reference to the first aspect, in some embodiments, the first interface includes a second component and a third component, the second component being a transparent component displayed in the foreground, and the third component being a non-transparent component displayed under the second component, the electronic device detects a fifth operation performed on a position where the second component and the third component are located, the second component not having the ability to respond to the fifth operation, and the third component having the ability to respond to the fifth operation; and in response to the fifth operation, the electronic device performs a function corresponding to the third component or opens an interface corresponding to the third component.
[0026] It can be seen that when the second component is displayed in the foreground in a transparent state, the user cannot see the second component but can see the component displayed under the second component, for example, the third component. Since the second component does not have the ability to respond to the fifth operation, the electronic device can determine that the fifth operation of the user on the position of the second component and the third component is a user operation on the third component. That is, even if the third component is covered by a transparent component (for example, the second component), the third component can still respond to the user operation when the transparent component does not have the ability to respond to the user operation. This can improve the user's use experience.
[0027] In combination with the first aspect, in some embodiments, the process running on the electronic device includes a first process, and if the memory leakage amount of the first process is less than or equal to a first threshold, the electronic device takes a first strategy on the first process, and the first strategy includes one or more of the following: prohibiting the process from creating a new thread in the background, prohibiting the process from associating or binding a service in the background, no longer allocating new memory to the process, and periodically detecting memory leakage of the process.
[0028] The first strategy can be a leakage prevention strategy in the embodiments of the present application.
[0029] It can be seen that the memory leakage amount of the first process is less than or equal to the first threshold, which can indicate that the current memory leakage amount of the first process is small and has little impact and harm in the electronic device. Therefore, the electronic device can take a leakage prevention strategy on the first process. The above leakage prevention strategy is mainly used to prevent the memory leakage amount of the process from further increasing while trying not to affect the running of the process. This can not only reduce the impact on the running of the first process to avoid affecting the user's use of the application corresponding to the first process, but also prevent the memory leakage amount of the first process from increasing and reduce the occurrence of the electronic device freezing due to memory leakage.
[0030] In the case where the memory leakage amount of the first process is greater than the first threshold, if the available memory amount of the electronic device is less than or equal to a second threshold, the electronic device takes a second strategy on the first process, and the second strategy includes one or more of the following: garbage collection, clearing thread local cache, memory compression, and memory recovery.
[0031] The second strategy can be a leakage containment strategy in the embodiments of the present application.
[0032] It can be seen that the memory leakage amount of the first process is greater than the first threshold value, which can indicate that the current memory leakage amount of the first process is large. The currently available memory of the electronic device is greater than the second threshold value, which can indicate that the currently available memory of the electronic device is still sufficient. In the case that the memory leakage amount of the first process is large, but the currently available memory of the electronic device is sufficient, the electronic device can basically withstand the influence caused by the memory leakage of the first process. Therefore, the electronic device can take a leakage containment strategy for the first process. This can reduce the memory leakage of the first process while minimizing the impact on the running of the first process, thereby reducing the impact on the user's use of the application corresponding to the first process.
[0033] In the case that the memory leakage amount of the first process is greater than the first threshold value, if the available memory amount of the electronic device is greater than the second threshold value, the electronic device takes a third strategy for the first process, and the third strategy includes one or more of the following: cleaning foreground processes and providing a process cleaning prompt, cleaning foreground associated processes when the electronic device is turned off, prioritizing cleaning of non-resident processes and non-foreground dependent processes, and killing and recovering background processes.
[0034] The third strategy can be a leakage removal strategy in the embodiments of the present application.
[0035] It can be seen that the memory leakage amount of the first process is greater than the first threshold value, which can indicate that the current memory leakage amount of the first process is large. The currently available memory of the electronic device is less than or equal to the second threshold value, which can indicate that the currently available memory of the electronic device is insufficient. At this time, if there is a process in the electronic device that needs to apply new memory, the electronic device can overflow. The electronic device running program can be stuck, and thus the electronic device can be frozen. Therefore, the electronic device can take a leakage removal strategy for the first process. This can eliminate the memory leakage of the first process and reduce the situation of freezing of the electronic device due to memory leakage. Moreover, if the electronic device freezes due to memory leakage, the electronic device can eliminate the memory leakage of one or more processes by the above-mentioned leakage removal strategy, so as to increase the available memory of the electronic device. The freezing problem can be solved as the available memory of the electronic device increases.
[0036] In combination with the first aspect, in some embodiments, the electronic device stores a first memory usage threshold value, and the memory leakage amount of the first process is determined according to the first memory usage threshold value and the memory amount occupied by the first process. The first memory usage threshold value can reflect the peak value of the memory occupied by the first process in the case that there is no memory leakage or only a small amount of memory leakage. The memory leakage amount of the first process can be a value obtained by subtracting the first memory usage threshold value from the memory occupied by the first process.
[0037] After the second or third strategy is adopted for the first process, the electronic device detects the memory reclamation benefit of the electronic device, which is determined based on the estimated memory reclamation amount and the actual memory reclamation amount of the first process; the electronic device adjusts the first memory usage threshold based on the memory reclamation benefit.
[0038] The estimated memory reclamation amount for the first process can be determined based on the current first memory usage threshold and the amount of memory occupied by the first process. Alternatively, the estimated memory reclamation amount for the first process can be determined based on the current first memory usage threshold, the amount of memory occupied by the first process, and the first threshold. The actual memory reclamation amount for the first process can be the actual amount of memory reclaimed from the memory occupied by the first process, that is, the increase in the total available memory of the entire machine after reclaiming the memory of the first process.
[0039] It can be seen that when a memory leak occurs in the first process, the electronic device can dynamically adjust the memory usage threshold (i.e., the first memory usage threshold) corresponding to the first process based on the result of memory reclamation of the first process. This allows the first memory usage threshold to more accurately reflect the peak memory usage of the first process when there is no memory leak or only a small amount of memory leak, thereby improving the accuracy of memory leak detection.
[0040] Secondly, this application provides an electronic device. The electronic device may include a memory and a processor. The memory may be used to store a computer program. The processor may be used to invoke the computer program to execute any of the possible implementation methods described in the first aspect.
[0041] Thirdly, this application provides a computer-readable storage medium storing instructions that, when executed by a processor, can implement any of the possible implementations described in the first aspect.
[0042] Fourthly, this application provides a computer program product that may contain computer instructions that, when executed on a processor, can implement any of the possible implementation methods described in the first aspect.
[0043] Fifthly, this application provides a chip for use in an electronic device, the chip including one or more processors for invoking computer instructions to cause the electronic device to perform any of the possible implementation methods in the first aspect.
[0044] It is understood that the electronic device provided in the second aspect, the computer-readable storage medium provided in the third aspect, the computer program product provided in the fourth aspect, and the chip provided in the fifth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description
[0045] FIG. 1A is a schematic diagram of a hardware structure of an electronic device 100 according to an embodiment of the present application;
[0046] FIG. 1B is a schematic diagram of a software structure of the electronic device 100 according to an embodiment of the present application;
[0047] FIG. 2 is a schematic diagram of a structure of the electronic device 100 according to an embodiment of the present application;
[0048] FIG. 3 is a flowchart of a method for handling a frozen screen according to an embodiment of the present application;
[0049] FIG. 4 is a flowchart of a method for handling a frozen screen according to an embodiment of the present application;
[0050] FIG. 5 is a schematic diagram of a redraw component according to an embodiment of the present application;
[0051] FIGS. 6A and 6B are schematic diagrams of other redraw components according to embodiments of the present application;
[0052] FIG. 7 is a flowchart of a method for handling a memory leak according to an embodiment of the present application;
[0053] FIG. 8 is a flowchart of a method for adjusting a memory usage threshold according to an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings. In the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing the specific embodiments and are not intended to be limiting of the present application. As used in the specification and the appended claims of the present application, the singular forms “a,” “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that “at least one” and “one or more” as used in the following embodiments means one or two or more (including two). The term “and / or” is used to describe the association relationship of the associated objects, which means that there can be three relationships; for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The character “ / ” generally represents an “or” relationship between the associated objects.
[0055] Reference in the specification to "one embodiment" or "some embodiments" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. The appearances of the phrase "in one embodiment" or "in some embodiments" in various places in the specification are not necessarily all referring to the same embodiment, although it can. The terms "including," "comprising," "having" and variations thereof are meant to encompass the items listed thereafter and equivalents thereof as well as additional items. The terms "connected" and "coupled" are not restricted to direct connections or couplings but include indirect connections or couplings through another component or components. The terms "first," "second," and "third" are used to describe various elements, but can not be understood as indicating or implying relative importance or a number of indications of the elements.
[0056] In the present application, the word "exemplary" or "for example" is used to mean serving as an example, instance, or illustration. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the exemplary or example embodiments are described as being exemplary of functional or structural elements that can be utilized in implementing the application.
[0057] In some embodiments, when rendering a user interface, due to a single interface loading exception (e.g., interface loading timing disorder), the components displayed on the screen by the electronic device, although having the ability to respond to user operations, are not responsive to user operations. In addition, the electronic device can also render transparent components on the screen. The transparent components are components that can be seen on the screen under normal interface loading conditions, but cannot be seen by the user under interface loading exception conditions due to transparent display. One or more of the transparent components, although having the ability to respond to user operations, are not responsive to user operations.
[0058] The components described above, which have the ability to respond to user operations but are not responsive to user operations, can be referred to as abnormal components. The user operations described above can include, but are not limited to, click operations, touch operations, long press operations, double-click operations, knuckle gesture operations, and the like. The ability to respond to user operations described above can mean that the electronic device can generate corresponding user operation events (e.g., click events, long press events, double-click events, and the like) according to user operations on the components (e.g., user operations acting on the display position of the components), and provide user interaction feedback (e.g., interface jumping, interface display content change, and the like) of the components on the screen.
[0059] The existence of the abnormal components described above can cause the user to perform user operations multiple times without receiving corresponding user interaction feedback, which can seriously affect the user's experience of using the electronic device.
[0060] To facilitate understanding of the freeze screen processing method provided in the present application, some concepts involved in the present application are introduced first.
[0061] 1. Freeze screen.
[0062] The freeze screen can refer to a case where an abnormal component is displayed on the screen of an electronic device. That is to say, if the electronic device receives one or more user operations on a component on the screen that has the ability to respond to user operations, but does not give corresponding user interaction feedback, the electronic device freezes.
[0063] In some embodiments, the freeze screen can be caused by a transparent component. Some components have the ability to respond to user operations and should be visible on the screen, but are transparentized due to interface loading abnormalities when drawing and become transparent components. One or more components do not respond to user operations in the transparent display state. In addition, the lower layer of one or more transparent components displays other visible components that can be seen by the user. Since the transparent component is overlaid on the upper layer of the visible component, the visible component cannot perceive the user operation and thus cannot respond normally to the user operation.
[0064] In some embodiments, the freeze screen can also be caused by memory leakage. Memory leakage can cause waste of memory of the electronic device, making the available memory of the electronic device scarce, resulting in slow program running speed or even system crash. In the case of tight available memory resources, the electronic device running program is stuck, and the component responds slowly or is stuck to the user operation. This results in the user possibly performing user operations on the component for multiple times, while the electronic device does not provide corresponding user interaction feedback in a timely manner.
[0065] 2. Component.
[0066] The component can refer to a card, an icon, a button, a menu, a tab, a text box, a dialog box, a navigation bar, and the like interface elements displayed on the screen. In some embodiments, the components can have a hierarchical relationship between components. For example, a component (i.e., a parent component) can include one or more child components. The child component can also be referred to as an affiliated component of the parent component.
[0067] In some embodiments, one or more components displayed on the screen have the ability to respond to user operations. For example, an APP icon is displayed on the screen. The APP icon can be used to provide a shortcut entry to open the corresponding APP. In response to the user operation on the APP icon, the electronic device can display the user interface of the APP corresponding to the APP icon on the screen. In some embodiments, one or more components that do not have the ability to respond to user operations can also exist on the screen. For example, a time component is displayed on the screen. The time component can be used to indicate the current time information. The time component does not have the ability to respond to user operations.
[0068] For example, a sports health card is displayed on the screen. The sports health card can include one or more sub-components, such as a heart rate component, a step component, and the like. The heart rate component can be used to indicate the current heart rate of the user. The step component can be used to indicate the number of steps the user has walked. The sports health card can be used to call up the user interface of the sports health application. In which, the user interface displayed by the electronic device in response to a click operation on the position of the heart rate component of the sports health card can be the same as the user interface displayed by the electronic device in response to a click operation on the position of the step component of the sports health card. That is, the sports health card has the ability to respond to user operations. However, the sub-components in the sports health card do not have the ability to respond to corresponding user operations.
[0069] It can be understood that the component responding to the user operation can mean that the electronic device provides corresponding user interaction feedback in response to the user operation on the component.
[0070] In some embodiments, the electronic device can transparently display one or more components on the screen. The component transparently displayed can be referred to as a transparent component. In which, one or more components on the screen can be set to transparent display, that is, the one or more components are not visible to the user after being drawn. There can also be one or more components on the screen that are transparently displayed due to abnormal conditions, that is, the one or more components should have been visible to the user after being drawn, but became transparent components due to abnormal conditions.
[0071] 3. Window, transparent component.
[0072] The window can refer to a user interface that displays computer operations in the form of a window. The window can be a basic unit set by an application program in a graphical user interface for using data. The window can contain one or more components. The window can be used for user interaction with the operating system or application program of the electronic device.
[0073] In some embodiments, part or all of the area in a window can be transparently displayed. For example, there is a transparently displayed area in window 1. The lower layer of window 1 also displays other windows. The user can view the content displayed on the lower layer of window 1 through the transparently displayed area in window 1.
[0074] A transparent component can refer to a component that is transparently displayed and is not visible to a user. One or more transparent components can be included in a window. In some embodiments, if a transparent component includes sub-components, the sub-components in the transparent component are also transparently displayed. In contrast to a transparent component, a component that is visible to a user on a screen can be referred to as a non-transparent component. In this case, a component can be set as a transparent component, i.e., the component is not visible to a user in a normal display of an interface. Alternatively, a component can exist on a screen and be transparently displayed due to an abnormal situation, i.e., the component is supposed to be visible to a user after being drawn, but becomes a transparent component due to an abnormal situation.
[0075] In some embodiments, the transparency of a transparent component can be 0 or within a preset range close to 0. In this case, the range of values of the transparency can be [0, 1]. 0 can represent complete transparency. 1 can represent complete visibility.
[0076] 4. Instrumentation.
[0077] Instrumentation can refer to inserting custom code at one or more locations in code. Since the inserted custom code can run together with the original code, instrumentation can be used to obtain information about the operation of an operating system and an application, so as to debug, analyze performance, and evaluate security of the operating system and the application, etc. For example, an electronic device can obtain information about components displayed on a screen (such as display positions of the components, transparencies of the components, hierarchical relationships between the components, etc.) and whether the components respond to user operations, etc. by means of instrumentation. The information obtained by means of the above-mentioned instrumentation can include, but is not limited to, indicators, logs, tracking records, etc. In some embodiments, instrumentation can also be used to modify code to implement new functions or fix known errors.
[0078] 5. Memory leak.
[0079] Memory leak can refer to that an application cannot release the memory space after applying for the memory space, thereby causing waste of the memory space. For example, an object or a variable in an application that is no longer used continues to occupy the memory, so that the occupied memory cannot be released. The application that occupies the above-mentioned memory no longer uses the above-mentioned memory, and since the above-mentioned memory is not released, the above-mentioned memory cannot be used by other applications. Accumulation of memory leaks can cause memory overflow. Memory overflow can refer to that an application cannot apply for memory when the electronic device does not have enough memory space for the application to use.
[0080] 6. Process.
[0081] A process can represent a program that is running in a system, and is an abstraction of a program that is running. Each running program can constitute a process. A process is a basic unit for which an operating system allocates resources and schedules. Each process has its own independent address space and execution state.
[0082] For an operating system supporting multiple processes, the CPU can run multiple processes alternately. Among them, the CPU can quickly switch from one process to another, and each process runs for tens or hundreds of milliseconds. Although a single-core CPU only runs one process at a moment, over a period of time (e.g., 1 second), the CPU can run multiple processes alternately. Since the switching speed between processes is fast, in the user's perception, the electronic device 100 can run multiple applications simultaneously. For example, the user can use the electronic device 100 to listen to music while editing a document.
[0083] In some embodiments, processes are divided according to priorities, and the priorities of processes from high to low can be: foreground processes, visible processes, service processes, cache processes, and empty processes. Among them, the operating system can try to ensure that the existence time of a process with high priority is as long as possible. If resources (such as memory resources, etc.) are insufficient, in order to create new processes and ensure the running of important processes, the operating system can end some low-priority processes and recycle the memory occupied by the processes.
[0084] The foreground process can include a process currently displayed on the screen and some system processes. The foreground process can be a process interacting with the user. For example, the screen of the electronic device 100 displays a window 1. The window 1 obtains the focus. The user can interact with the process corresponding to the window 1 by operating the window 1 (such as clicking the components in the window 1, inputting text in the window 1, etc.). The process corresponding to the window 1 is the foreground process. For another example, the screen of the electronic device 100 also displays a status bar containing one or more elements such as a signal strength indicator, a power indicator, and a time. The status bar can be displayed by the system process running by the electronic device 100. The system process corresponding to the status bar is also a foreground process.
[0085] The visible process can include a process that can be seen by the user interface, but not in the foreground and interacting with the user. For example, the screen of the electronic device 100 displays a window 1, and part or all of the area of the window 1 is transparently displayed. The electronic device 100 also displays a window 2 under the window 1. The window 1 is displayed at the top layer of all windows in the screen. That is, the window 1 is displayed in the foreground, and the components in the window 1 are also displayed in the foreground. The process corresponding to the window 1 is a foreground process. Since part or all of the area of the window 1 is transparently displayed, although the window 2 is covered by the window 1, the window 2 is still a visible window. The process corresponding to the window 2 is a visible process.
[0086] For another example, when a window 1 is displayed on the screen of the electronic device 100 and the window 1 has focus, the electronic device 100 newly displays a chat window on the screen. The chat window is displayed above the window 1 and partially covers the window 1. At this time, the chat window has focus and the window 1 loses focus. Although the user can still see the window 1 on the screen, the user interacts with the chat window and not the window 1. The process corresponding to the window 1 is changed from the foreground process to the visible process. The process corresponding to the chat window is the foreground process. If the electronic device 100 receives an operation on the window 1, the electronic device 100 can display the window 1 above the chat window. The window 1 regains focus. The process corresponding to the window 1 is also changed to the foreground process again.
[0087] A service process can include a process that does not have a user interface, does not directly interact with a user, but can run in the background. In some embodiments, a service process can refer to a process that is started by a startService() method. For example, a process that plays music in the background and a process that is downloaded in the background are service processes.
[0088] A background process can include a process that is not currently visible to a user. In some embodiments, a background process can refer to a process corresponding to an Activity component that calls an onStop() method to enter a stopped state but does not call an onDestroy() method to be destroyed. For example, when a window 1 is displayed on the screen of the electronic device 100 and the window 1 has focus, the electronic device 100 opens a new window 2. The window 1 is not closed. The window 2 is displayed above the window 1 and completely covers the window 1. That is, after the electronic device 100 displays the window 2, the window 1 is not visible to the user. At this time, the window 2 has focus and the window 1 loses focus. The process corresponding to the window 1 is changed from the foreground process to the background process. The process corresponding to the window 2 is the foreground process. For another example, when a window 1 is displayed on the screen of the electronic device 100 and the window 1 has focus, the electronic device 100 receives an operation to return to a home screen (e.g., an operation to press a Home key). The electronic device 100 can display the home screen. At this time, the process corresponding to the window 1 is changed from the foreground process to the background process.
[0089] An empty process can refer to a process in which no program is running inside the process. An empty process can generally be used to cache data to shorten the start-up time required for an application to which the empty process belongs to run a program in the empty process next time.
[0090] The present application provides a method for solving the frozen screen problem. In the method, a component 1 is displayed on a screen of an electronic device. The component 1 is capable of responding to a user operation. When a user operation on the component 1 is detected, the electronic device can detect whether the component 1 responds to the user operation. If the component 1 does not respond to the user operation, the electronic device can redraw the component 1 on the screen. In the case of redrawing the component 1, other components on the screen can not need to be redrawn.
[0091] In some embodiments, the component 1 can be displayed in a transparent manner due to an abnormal situation. In order to compensate for the error of drawing the component 1, the electronic device can redraw the component 1. After the component 1 is redrawn, the component 1 can be normally displayed and visible to the user. The component 1 can respond to the user operation when it is visible. In response to the user operation on the redrawn component 1, the electronic device 100 can provide corresponding user interaction feedback. That is, the component 1 can be a transparent component before it is redrawn. The component 1 can be a non-transparent component and visible to the user after it is redrawn.
[0092] It can be seen that when a component (e.g., the component 1) that needs to be used by the user does not respond to the user operation, the electronic device can redraw the component that needs to be used by the user to solve the frozen screen problem, so that the component that needs to be used by the user can quickly respond to the user operation. For other components in the window in which the component that needs to be used by the user is located, the electronic device can not need to waste resources to redraw all the components because the user does not need to use them temporarily. The above method can detect whether the electronic device has a frozen screen according to whether the components displayed on the screen respond to the user operation, and make the component that needs to be used by the user quickly respond when the electronic device has a frozen screen, so as to quickly solve the frozen screen problem and reduce the waiting time of the user. In this way, the electronic device can reduce the situation of restarting the related application program and save the resources of the electronic device.
[0093] The structure of the electronic device 100 related to the present application will be introduced below.
[0094] FIG. 1A exemplarily shows a schematic diagram of the hardware structure of the electronic device 100.
[0095] As shown in FIG. 1A, the electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0096] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0097] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors.
[0098] Among them, the controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.
[0099] The processor 110 can also be provided with a memory for storing instructions and data. In some examples, the memory in the processor 110 is a cache memory. The memory can hold instructions or data that the processor 110 has just used or is cycling through. If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0100] In the present application, the memory can store a computer program for enabling the controller or the processor to implement the screen reading method of the present application through an interface or a protocol. Exemplarily, the computer program stored in the memory can be used to draw a window and components in the window on the screen, instrument the components, detect whether the components have the ability to respond to user operations, detect whether the components are transparent components, detect whether the components are displayed in the foreground, detect whether there is a user operation acting on the components, detect whether the components respond to the user operation, perform memory leakage detection on the processes in the electronic device 100, and take corresponding process management strategies according to the memory leakage situation, and the like.
[0101] The USB interface 130 is an interface conforming to the USB standard specification. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and a peripheral device. It can also be used to connect a headset to play audio through the headset.
[0102] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. The charging management module 140 can charge the battery 142 while also providing power to the electronic device through the power management module 141.
[0103] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to provide power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160, etc.
[0104] The wireless communication function of the electronic device 100 can be realized through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0105] Antenna 1 and antenna 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of antennas. For example: antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, antennas can be used in combination with a tuning switch.
[0106] Mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied on electronic device 100. Mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. Mobile communication module 150 can receive electromagnetic waves by antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transmit the processed signals to a modem processor for demodulation. Mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert the signals into electromagnetic waves radiated by antenna 1.
[0107] Wireless communication module 160 can provide a solution for wireless communication including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. applied on electronic device 100. Wireless communication module 160 can be one or more devices integrated with at least one communication processing module. Wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and transmits the processed signals to processor 110. Wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification on the signals, and convert the signals into electromagnetic waves radiated by antenna 2.
[0108] Electronic device 100 realizes display functions through a GPU, display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, connected to display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering.
[0109] Display screen 194 is used to display images, videos, etc. In some embodiments, electronic device 100 can include 1 or N display screens 194, N being a positive integer greater than 1.
[0110] The electronic device 100 can implement a photographing function through an ISP, a camera 193, a video codec, a GPU, a display 194, and an application processor, etc.
[0111] The ISP is used to process data fed back by the camera 193. For example, when taking a photo, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye.
[0112] The camera 193 is used to capture a still image or a video. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1.
[0113] The digital signal processor is used to process digital signals, in addition to being able to process digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0114] The NPU is a neural-network (NN) calculation processor, which is based on the structure of a biological neural network, for example, by imitating the transmission mode between human brain neurons to quickly process input information, and can also continuously self-learn. Through the NPU, the electronic device 100 can implement intelligent cognition applications such as image recognition, face recognition, voice recognition, and text understanding, etc.
[0115] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are saved in the external memory card.
[0116] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc. The data storage area can store data created during use of the electronic device 100 (such as audio data, a phonebook, etc.), etc. In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0117] The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor, etc. For example, music playing, recording, etc.
[0118] The audio module 170 is configured to convert digital audio information into an analog audio signal output, and to convert an analog audio input into a digital audio signal. The audio module 170 can also be configured to encode and decode audio signals. In some examples, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110. The speaker 170A, also referred to as a “loudspeaker”, is configured to convert an audio electrical signal into a sound signal. The receiver 170B, also referred to as a “earpiece”, is configured to convert an audio electrical signal into a sound signal. The microphone 170C, also referred to as a “microphone”, “transducer”, is configured to convert a sound signal into an electrical signal. The earphone interface 170D is configured to connect a wired earphone.
[0119] The sensor module 180 can include a pressure sensor, a gyro sensor, a barometric sensor, a magnetic sensor, an acceleration sensor, a gravity sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
[0120] The keys 190 include a power key, a volume key, etc. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light, which can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, etc.
[0121] The SIM card interface 195 is configured to connect a SIM card. The SIM card can be inserted into or pulled out of the SIM card interface 195 to realize contact and separation with the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The electronic device 100 interacts with a network through the SIM card to realize functions such as calling and data communication. In some examples, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0122] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take a layered architecture as an example to exemplarily illustrate the software structure of the electronic device 100. The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take a layered architecture as an example to exemplarily illustrate the software structure of the electronic device 100.
[0123] FIG. 1B exemplarily shows a software structure block diagram of the electronic device 100.
[0124] A layered architecture divides software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android Runtime and system libraries, and the kernel layer. The system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android Runtime and system libraries, and the kernel layer.
[0125] The application layer can include a series of application packages.
[0126] As shown in FIG. IB, the application packages can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, short message, desktop service, and the like. Among them, the desktop service can be used to manage interface elements on the screen (for example, interface elements provided by the operating system, interface elements provided by the application). In some embodiments, when a component on the screen that has the ability to respond to user operations (for example, a component in the window of an APP icon, a service card, a desktop folder, an application, and the like) does not respond to user operations, the electronic device can redraw the component through the desktop service.
[0127] The application framework layer provides APIs and programming frameworks for the applications of the application layer. The application framework layer includes some pre-defined functions.
[0128] As shown in FIG. IB, the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, an activity manager, a user interface (UI) framework, a memory management module, a process management module, and the like.
[0129] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, and the like.
[0130] The content provider is used to store and obtain data, and make the data accessible to the application. The data can include video, image, audio, dialed and received calls, browsing history and bookmarks, phonebook, and the like.
[0131] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and the like. The view system can be used to build an application. A 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.
[0132] The phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call state (including call connection, call hangup, and the like).
[0133] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, and so on.
[0134] The notification manager enables an application to display notification information in the status bar (a pull-down notification bar), which can be used to convey a message of the notification type and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify that a download is complete, a message reminder, and so on. The notification manager can also be a notification in the form of a chart or a scroll bar text appearing in the top status bar of the system, such as a notification of an application running in the background, and can also be a notification in the form of a dialog window appearing on the screen. For example, a text message is prompted in the status bar, a prompt sound is emitted, the electronic device vibrates, an indicator light flashes, and so on.
[0135] The activity manager is used to manage activities (activities) and is responsible for the startup, switching, scheduling of components in the system, and the management and scheduling of applications. The activity manager can be called by an upper-layer application to open a corresponding activity.
[0136] The UI framework can be used to provide the framework capabilities required for developing and running a UI interface. For example, the UI framework can provide the infrastructure for developing a UI, including UI controls (buttons / lists, etc.), view layouts (placing / arranging corresponding UI controls), animation mechanisms (animation design and effect rendering), interaction event processing (clicking / sliding, etc.), and corresponding programming languages and programming models, and so on. From the perspective of system running, the UI framework can also include a runtime responsible for resource loading, UI rendering, and event response required when an application is executed in the system. In some embodiments, the UI framework can combine a rendering engine to run the developer's program on a specific system platform.
[0137] The memory management module can be used to manage the memory of the electronic device 100. The memory management module can allocate corresponding memory for each process according to the memory allocation request of each process in the electronic device 100. The memory management module can also perform memory recycling, memory compression, and the like.
[0138] The process management module can be used to manage the processes in the electronic device 100. The process management module can create a process, allocate CPU time slices and other resources to the process, manage the state of the process, manage the newly created threads of the process, clean up the process, and the like.
[0139] The Android Runtime includes a core library and a virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.
[0140] The core library includes two parts: one part is the function function called by the java language, and the other part is the core library of Android.
[0141] 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 into binary files. The virtual machine is used to perform the functions of object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0142] The system library can include a plurality of functional modules. For example: surface manager, media library, three-dimensional graphics processing library (such as: OpenGL ES), 2D graphics engine (such as: SGL) and the like.
[0143] The surface manager is used to manage the display subsystem, and provides a plurality of applications with the fusion of 2D and 3D layers.
[0144] The media library supports a plurality of commonly used audio, video format playback and recording, and static image files and the like. The media library can support a plurality of audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG and the like.
[0145] The three-dimensional graphics processing library is used to realize three-dimensional graphics drawing, image rendering, synthesis, and layer processing and the like.
[0146] The 2D graphics engine is a drawing engine for 2D drawing.
[0147] The kernel layer is a layer between hardware and software. The kernel layer at least includes display driver, camera driver, audio driver, sensor driver.
[0148] FIG. 2 exemplarily shows a structural schematic diagram of another electronic device 100 provided by the present application.
[0149] As shown in FIG. 2, the electronic device 100 can include a component instrumentation detection module, a UI framework instrumentation detection module, a window manager instrumentation detection module, a frozen screen detection module, a window manager, a desktop service, a memory leakage detection module, a memory management module, and a process management module.
[0150] In some embodiments, the electronic device 100 can instrument the components, the UI framework, and the window manager. The above-mentioned instrumentation can be source code instrumentation.
[0151] The source code instrumentation of the component by the electronic device 100 can include instrumenting in a system interface that needs to be called by the component. That is, the electronic device 100 can insert custom code in the code of one or more system interfaces. When the component calls the above-mentioned instrumented system interface during running, the inserted custom code runs along with the running of the component. In this way, the component display information can be obtained by the component instrumentation detection module according to the running result of the custom code for instrumenting the component. The component display information can include but is not limited to: component identification (ID), display position of the component, sub-component contained by the component, transparency of the component, and the like. The above-mentioned component ID can be used to uniquely identify the corresponding component on the screen.
[0152] Since the UI framework and the window manager are modules provided by the operating system of the electronic device 100, the electronic device 100 can insert custom code in the source code of the UI framework, and can insert custom code in the source code of the window manager. The component operation information can be obtained by the UI framework instrumentation detection module according to the running result of the custom code for instrumenting the UI framework. The component operation information can include but is not limited to: whether the component has the ability to respond to user operations, position of user operation, type of user operation, whether the component responds to user operations, and the like. In some embodiments, whether the component responds to user operations can be determined by whether the component has a UI callback for user operations. The UI callback can refer to a function executed by the component when responding to user operations. The electronic device 100 can update the user interface based on the UI callback to provide the response result of the component to the user operation. That is, if the component has a UI callback for user operations, it can indicate that the component responds to user operations. If the component does not have a UI callback for user operations, it can indicate that the component does not respond to user operations. The window management information can be obtained by the window manager instrumentation detection module according to the running result of the custom code for instrumenting the window manager. The window management information can include but is not limited to: display level of the window, and the like. The display level of the window can be used to indicate the upper and lower position relationship of the window display. For example, the electronic device can determine whether the window is displayed in the foreground based on the display level of the window. The electronic device can also determine whether window 1 is displayed above window 2 based on the display levels of window 1 and window 2.
[0153] The specific implementation method of the electronic device 100 for instrumenting is not limited by the embodiments of the present application. For example, in addition to source code instrumentation, the electronic device 100 can also use byte code instrumentation and the like to instrument and detect the component.
[0154] In some embodiments, a component plug-in detection module of a component, e.g., component 1, can send component display information of component 1 to a UI framework plug-in detection module and a window manager plug-in detection module. The UI framework plug-in detection module can obtain component operation information of component 1. The window manager plug-in detection module can obtain window management information of a window to which component 1 belongs.
[0155] In some embodiments, the UI framework plug-in detection module and the window manager plug-in detection module can send plug-in detection information of a component to a frozen screen detection module. The plug-in detection information of a component can include component display information of the component, component operation information of the component, and window management information of a window to which the component belongs.
[0156] Without being limited to plug-in detection of a component, the electronic device 100 can also obtain component display information of a component, component operation information of the component, and window management information of a window to which the component belongs by other methods.
[0157] The frozen screen detection module can be configured to detect whether the electronic device has a frozen screen according to the plug-in detection information of a component. The specific method of detecting whether the electronic device has a frozen screen by the frozen screen detection module will be described in subsequent embodiments, which will not be described here.
[0158] In some embodiments, if a user operation is performed on a component that has the ability to respond to the user operation, but the component does not respond to the user operation, the frozen screen detection module can determine that the electronic device has a frozen screen. Then, the frozen screen detection module can send a frozen screen detection result to a window manager. The frozen screen detection result can include a component ID. The component corresponding to the component ID can be the component that does not respond to the user operation.
[0159] The window manager can send a component redraw notification to a desktop service according to the frozen screen detection result. The component redraw notification can include the component ID in the frozen screen detection result. The desktop service can redraw the component corresponding to the component ID.
[0160] As can be seen, the electronic device 100 can perform plug-in detection on a component to determine whether the component responds to a user operation. If the component has the ability to respond to the user operation but does not respond to the user operation, the electronic device 100 can redraw the component through the desktop service to compensate for errors that occurred when the component was previously drawn. In this way, the component can quickly respond to the user operation after being redrawn. The above method can quickly solve the frozen screen problem, reduce the time for the user to wait for the component to respond after the user performs a user operation on the component, and can reduce the situation of solving the frozen screen problem by restarting the related application, thereby saving the resources of the electronic device.
[0161] The memory leakage detection module can be configured to detect whether one or more processes in the electronic device 100 have memory leakage, and the amount of leakage of the process memory leakage. The memory leakage detection module can send the memory leakage detection result to the memory management module. The memory leakage detection result can include a process identifier, and the amount of leakage of the process memory leakage corresponding to the process identifier.
[0162] The memory management module can determine a process management strategy according to the memory leakage detection result, and notify the process management module of the process management strategy. The process management module can manage the processes in response to the process management strategy. In some embodiments, the process management strategy can include, but is not limited to, a leakage prevention strategy, a leakage containment strategy, a leakage removal strategy, and the like. The specific content of the process management strategy will be described in subsequent embodiments, which will not be expanded here.
[0163] As can be seen, the electronic device 100 can manage the processes when memory leakage occurs, and can take different process management strategies according to different amounts of leakage. In this way, not only can the freezing screen caused by memory leakage be reduced, but also the impact of the above process management on the user's use of the application can be reduced.
[0164] FIG. 3 illustrates a flowchart of a freezing screen processing method according to an embodiment of the present application.
[0165] S311, the electronic device 100 detects operation 1 acting on position 1 on the screen, and component 1 exists at position 1.
[0166] Component 1 can be a component displayed in the foreground in the electronic device 100. That is, component 1 can be displayed on the top layer of all interface elements.
[0167] Operation 1 can be a click operation, or a long press operation, or a double-click operation, and the like. The type of operation 1 is not limited in the embodiments of the present application.
[0168] In some embodiments, component 1 can be displayed transparently due to abnormal conditions. That is, component 1 is a transparent component. Alternatively, component 1 can also be a non-transparent component.
[0169] In some embodiments, component 1 has the ability to respond to operation 1. The electronic device 100 can detect whether component 1 responds to operation 1. Based on the response of component 1 to operation 1, the electronic device 100 can perform step S312 or step S313.
[0170] S312, when component 1 does not respond to operation 1, the electronic device 100 redraws component 1.
[0171] If the component 1 does not respond to the operation 1, the electronic device 100 can redraw the component 1. If the component 1 includes a sub-component, redrawing the component 1 can include redrawing the sub-component in the component 1. The component 1 not responding to the operation 1 can indicate that the electronic device 100 is frozen.
[0172] In some embodiments, in addition to the component 1, other components are displayed on the screen. When redrawing the component 1, the electronic device 100 can not need to redraw the other components.
[0173] It can be understood that the component 1 not responding to the operation 1 can be due to an abnormality of the electronic device 100 when drawing the component 1. The electronic device 100 can handle the freezing problem by redrawing the component 1. When redrawing the component 1, the electronic device 100 can not have an abnormality, and thus the redrawn component 1 can respond to the user operation on the component 1 in time.
[0174] In some embodiments, if the component 1 does not respond to the operation 1, the electronic device 100 can redraw all components of the window 1 including the component 1. In this way, the electronic device 100 can redraw the window that the user wants to open in time after the freezing occurs, and reduce the time for the user to wait for the component to respond to the user operation when the user wants to open other components.
[0175] In some embodiments, if the component 1 still does not respond to the user operation on the component 1 after being redrawn, the electronic device 100 can restart the application associated with the component 1 to solve the freezing problem. Alternatively, the electronic device 100 can save the interface information and other data of the application associated with the component 1 when the application is closed, so that the application can display the interface displayed before being restarted after being restarted.
[0176] The electronic device 100 can restart the application associated with the component 1 if the component 1 does not respond to the user operation on the component 1 within a preset time period. The preset time period is not limited in the embodiments of the present application. For example, the preset time period can be 4 seconds or 5 seconds.
[0177] It can be seen that the time and resources required for redrawing the component 1 are less than those required for restarting the application. When freezing occurs and the component that the user needs to use is the component 1, the electronic device 100 can first try to solve the freezing problem by redrawing the component 1. If the redrawn component 1 can respond to the user operation on the component 1 in time, the electronic device 100 can provide the response result of the component 1 to the user operation, so that the application associated with the component 1 does not need to be restarted. In this way, the electronic device 100 can solve the freezing problem at the least cost, quickly restore the response of the component that the user needs to use, and reduce the waiting time of the user.
[0178] S313, when the component 1 responds to the operation 1, the electronic device 100 provides a response result of the component 1 to the operation 1.
[0179] If the component 1 responds to the operation 1, the electronic device 100 can provide a response result of the component 1 to the operation 1. For example, in response to the operation 1 on the component 1, the electronic device 100 can display the response result of the component 1 to the operation 1, the electronic device 100 can update the interface display content, and the electronic device 100 can open the interface corresponding to the component 1. Alternatively, in response to the operation 1 on the component 1, the electronic device 100 can execute the function corresponding to the component 1. The embodiments of the present application do not limit the response result of the component 1 to the operation 1.
[0180] As can be known from the above method, in the case that the component to be used by the user does not respond to the operation of the user, the electronic device 100 can quickly solve the problem of frozen screen by redrawing the component to be used by the user, thereby reducing the waiting time of the user. Moreover, the above method can reduce the case that the electronic device 100 restarts the application to solve the problem of frozen screen, thereby saving the resources of the electronic device.
[0181] The following describes a method for detecting and processing frozen screen based on instrumentation provided by the embodiments of the present application.
[0182] FIG. 4 exemplarily shows a flowchart of a method for processing frozen screen provided by the embodiments of the present application.
[0183] S411, detecting the operation 1 acting on the position 1 on the screen, and the component 1 exists at the position 1.
[0184] The step S411 can refer to the step S311 shown in the foregoing FIG. 3.
[0185] In some embodiments, the electronic device 100 can detect the component 1 in one or more of the following aspects: whether the component 1 is displayed in the foreground, whether the component 1 is displayed as a transparent component, whether the component 1 has the ability to respond to the operation 1, and whether the component 1 responds to the operation 1. The embodiments of the present application do not limit the method for detecting the component 1. For example, the electronic device 100 can realize the detection in one or more of the above aspects through instrumentation detection. As can be known from the foregoing embodiment of FIG. 2, the electronic device 100 can detect the instrumentation detection information of the component 1 through the UI framework detection module, the window manager instrumentation detection module, and the component instrumentation detection module of the component 1. The instrumentation detection information of the component 1 can include the component display information of the component 1 (for example, the component ID of the component 1, the transparency of the component 1, the sub-component contained in the component 1, and the like), the component operation information of the component 1 (for example, whether the component 1 has the ability to respond to the operation 1, whether the component 1 responds to the operation 1, and the like), and the window management information of the window to which the component 1 belongs (for example, the display level of the window to which the component 1 belongs).
[0186] The one or more detections on the component 1 can be performed by the freeze detection module in the electronic device 100. If the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1, or the component 1 is a non-transparent component displayed in the foreground and k times does not respond to the user operation acting on the position 1, the freeze detection module can send a freeze detection result to the window manager in the electronic device 100. The freeze detection result can be used to indicate that the component 1 is abnormal. The window manager can send a component redraw notification to the desktop service according to the freeze detection result. The component redraw notification can include the component ID of the component 1. When receiving the component redraw notification, the desktop service can redraw the component 1.
[0187] Based on the detection result of the one or more detections on the component 1, the electronic device 100 can perform step S412 or step S413 or step S414.
[0188] S412, when the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1, if the component 1 does not respond to the operation 1, redraw the component 1.
[0189] The electronic device 100 can determine whether the component 1 is a transparent component displayed in the foreground according to the instrumentation detection information of the component 1.
[0190] Specifically, the electronic device 100 can determine whether the window to which the component 1 belongs is displayed in the foreground according to the display level of the window. If the window to which the component 1 belongs is displayed in the foreground, the electronic device 100 can determine that the component 1 is displayed in the foreground.
[0191] The electronic device 100 can determine whether the component 1 is a transparent component according to the transparency of the component 1. For example, if the transparency of the component 1 is in a preset range, the electronic device 100 can determine that the component 1 is a transparent component. The preset range can be a preset range close to 0, for example, the preset range can be a value range greater than or equal to 0 and less than or equal to 0.1.
[0192] In some embodiments, if the component 1 is a transparent component displayed in the foreground, the electronic device 100 can determine whether the component 1 has the ability to respond to the operation 1. Optionally, the electronic device 100 can determine whether the component 1 has the ability to respond to the operation 1 according to the instrumentation detection information (for example, component operation information) of the component 1.
[0193] If the component 1 has the ability to respond to the operation 1, the component 1 should be visible to the user in the case that the interface is normally loaded, so that the user can operate the component 1. However, if the component 1 is a transparent component displayed in the foreground and the component 1 has the ability to respond to the operation 1, the component 1 can be abnormal when being drawn, resulting in that the component 1 is not visible to the user. Moreover, the component 1 has the ability to respond to the operation 1, but the component 1 is often not responsive to the operation 1 in the transparent display state.
[0194] Therefore, in the case that the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1, if the component 1 is not responsive to the operation 1, the electronic device 100 can redraw the component 1. Since the above-mentioned interface loading abnormality condition resulting in that the component 1 is drawn as a transparent component is usually single, the electronic device 100 can no longer exist abnormal condition when redrawing the component 1. Then, the electronic device 100 redrawing the component 1 can display the component 1 as a non-transparent component with high probability, so that the component 1 quickly recovers the response to the operation 1.
[0195] In some embodiments, in the case that the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1, if the component 1 is not responsive to the operation 1, the electronic device 100 can redraw all components of the window to which the component 1 belongs. In this way, the electronic device 100 can redraw the window that the user wants to open in time after the screen freezing occurs, reducing the time for the user to wait for the component to respond to the user operation when the user wants to open other components.
[0196] If the component 1 does not have the ability to respond to the operation 1, the electronic device 100 can perform the following step S413.
[0197] S413, when the component 1 is a transparent component displayed in the foreground and does not have the ability to respond to the operation 1, providing a response result of the component 2 to the operation 1, wherein the component 2 is a non-transparent component displayed under the component 1.
[0198] In some embodiments, if the component 1 is a transparent component displayed in the foreground and does not have the ability to respond to the operation 1, the electronic device 100 can detect the component displayed under the component 1.
[0199] If the component 2 is a non-transparent component displayed under the component 1 and can respond to the operation 1, the electronic device 100 can pass through a user operation event corresponding to the operation 1 to the component 2. The component 2 can respond to the operation 1 according to the user operation event corresponding to the operation 1. In this way, the electronic device 100 can provide a response result of the component 2 to the operation 1.
[0200] It can be understood that, in the case that the component 1 is displayed in the foreground in a transparent state, the user cannot see the component 1 but can see the component displayed under the component 1, for example, the component 2. Since the component 1 does not have the ability to respond to the operation 1, the electronic device 100 can determine that the operation 1 of the user at the position 1 is a user operation on the component 2. That is to say, even if the component 2 is covered by a transparent component (for example, the component 1), the component 2 can still respond to the user operation in the case that the transparent component does not have the ability to respond to the user operation. In this way, the user experience can be improved.
[0201] S414, when the component 1 is a non-transparent component displayed in the foreground, and k times of user operations at the position 1 are not responded, the component 1 is redrawn.
[0202] It can be understood that, in the case that the component 1 is displayed in the foreground in a transparent state, the user cannot see the component 1 but can see the component displayed under the component 1, for example, the component 2. Since the component 1 does not have the ability to respond to the operation 1, the electronic device 100 can determine that the operation 1 of the user at the position 1 is a user operation on the component 2. That is to say, even if the component 2 is covered by a transparent component (for example, the component 1), the component 2 can still respond to the user operation in the case that the transparent component does not have the ability to respond to the user operation. In this way, the user experience can be improved.
[0203] Since the operation (for example, the operation 1) acting on the screen is usually responded by the component displayed in the foreground. If the component 1 is a component not displayed in the foreground, the fact that the component 1 does not respond to the user operation cannot indicate that the electronic device 100 freezes. Therefore, the electronic device 100 can not need to consider the case that the component 1 is not displayed in the foreground.
[0204] In some embodiments, the electronic device 100 can also determine whether the component 1 does not respond to the user operation at the position 1 for k times according to the plug-in detection information of the component 1. K can be a preset positive integer. The embodiments of the present application do not limit the value of k. For example, k can be 4 or 5, etc. The k times of user operations at the position 1 are k times of user operations on the component 1. The k times of user operations on the component 1 are all user operations that the component 1 can respond to.
[0205] In the case that k is a positive integer greater than 1, the electronic device 100 can redraw the component 1 after detecting that the non-transparent component displayed in the foreground does not respond to the user operation for a plurality of times. It can be understood that it may take a certain time for one or more components displayed on the screen to respond to the user operation. If k is 1, the electronic device 100 redraws the component only after detecting that the component does not respond to the user operation within the preset time. However, the component can actually respond to the user operation, but the response speed is slow. The above redrawing of the component leads to the waste of resources of the electronic device 100. Therefore, setting k to a positive integer greater than 1 can reduce the case that the electronic device 100 redraws the non-abnormal component, and reduce the waste of resources of the electronic device 100.
[0206] In some embodiments, the UI framework instrumentation module in the electronic device 100 can detect whether the component 1 responds to each user operation at the location 1.
[0207] When the component 1 is a non-transparent component displayed in the foreground, and the component 1 does not respond to the user operation at the location 1 for k times, the electronic device 100 can redraw the component 1.
[0208] In some embodiments, if the redrawn component 1 still does not respond to the user operation on the component 1, the electronic device 100 can restart the application associated with the component 1 to solve the freeze problem.
[0209] It can be understood that the component 1 is displayed in the foreground and is visible to the user. If the user urgently needs to use the component 1, the user usually performs user operations on the component 1 multiple times in a short time. For example, after the user clicks the component 1 once and does not get the corresponding user interaction feedback, the user can click the component 1 multiple times to get the corresponding user interaction feedback. Considering the urgency of the user to use the component 1, the electronic device 100 can first handle the freeze problem by redrawing the component 1. If the redrawn component 1 can respond to the user operation on the component 1 in time, the electronic device 100 can provide the response result of the component 1 to the user operation, so as to not need to restart the application associated with the component 1. In this way, the electronic device 100 can solve the freeze problem at the least cost, quickly restore the component 1 used by the user to respond, and reduce the waiting time of the user.
[0210] It needs to be noted that if the component 1 is a non-transparent component displayed in the foreground, and the component 1 does not respond to the user operation at the location 1 for k times, the electronic device 100 can not need to redraw the component 1. The component 1 does not respond to the user operation at the location 1 for k times can include the following two cases:
[0211] Case 1: The user operation at the location 1 is responded to by the component 1 before the kth time.
[0212] For example, if the component 1 is a non-transparent component displayed in the foreground, and the component 1 responds to the m1th user operation at the location 1, the electronic device 100 can provide the response result of the component 1 to the m1th user operation, without the need to redraw the component 1. The above m1 is a positive integer less than k.
[0213] Case 2: The number of times of the user operation at the location 1 does not reach k, and the component 1 does not respond to the multiple user operations at the location 1.
[0214] For example, in the case that the component 1 is a non-transparent component displayed in the foreground, if the electronic device 100 only detects m2 times of user operations on the position 1 and the component 1 does not respond to the m2 times of user operations, the electronic device 100 can not need to redraw the component 1. The m2 is a positive integer less than k. It can be understood that the user will not continue to perform user operations on the component 1 after m2 times of user operations on the component 1 do not obtain user interaction feedback. This can indicate that the user does not have an urgent need to use the component 1. In the case that the component 1 is abnormal and does not respond to user operations, if the user does not have an urgent need to use the component 1, the electronic device 100 can not redraw the component 1 to save resources of the electronic device 100.
[0215] It can be known from the above method that, in the case that the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1, or the component 1 is a non-transparent component displayed in the foreground and does not respond to k times of user operations, the electronic device 100 can redraw the component 1 to process the abnormality of the component 1. In this way, the component 1 can quickly recover the response, and the waiting time of the user can be reduced. Moreover, the above method can reduce the case that the electronic device 100 restarts an application associated with the component 1 to solve the freeze problem, and resources of the electronic device 100 can be saved.
[0216] FIG. 5 shows a schematic diagram of redrawing a component according to an embodiment of the present application.
[0217] As shown in FIG. 5, the electronic device 100 can draw a window 1 and a window 2. The display levels of the window 1 and the window 2 can be different. In some embodiments, the window 1 and the window 2 can be windows without application programs.
[0218] The window 1 can be a window displayed in the foreground. The window 1 can include a component 1 and a component 4. The display states of the component 1 and the component 2 are transparent states. That is, the component 1 and the component 4 are both transparent components displayed in the foreground. The window 2 can be a window displayed under the window 1. The window 2 can include a component 2 and a component 3. The component 2 and the component 3 are both non-transparent components. The display effect of the window 1 and the window 2 on the screen can be that the window 2 is visible to the user, and the window 1 is invisible to the user. That is, after the electronic device 100 draws the window 1 and the window 2, the user can see the components (for example, the component 2 and the component 3) in the window 2 on the screen, but cannot see the components (for example, the component 1 and the component 4) in the window 1.
[0219] In some embodiments, the component 1 is located at a position 1 on the screen. In response to an operation 1 on the position 1, the electronic device 100 can detect whether the electronic device 100 freezes. If it is determined that the electronic device 100 freezes, the electronic device 100 can redraw the component 1.
[0220] Specifically, the electronic device 100 can acquire the instrumentation detection information of the component 1, and detect whether the electronic device 100 freezes according to the instrumentation detection information of the component 1. The case that the electronic device 100 freezes can include: case 1, the component 1 is a transparent component displayed in the foreground and has the ability to respond to the operation 1; case 2, the component 1 is a non-transparent component displayed in the foreground and k times does not respond to the user operation acting on the position 1. The electronic device 100 can detect whether the component 1 meets the above case 1 or case 2. Specifically, reference can be made to steps S412-S414 shown in the foregoing FIG. 4. If the component 1 meets the above case 1 or case 2, the electronic device 100 can redraw the component 1.
[0221] As shown in FIG. 5, before redrawing the component 1, the component 1 is a transparent component displayed in the foreground. In response to the operation 1 acting on the position 1, if the component 1 has the ability to respond to the operation 1, the electronic device 100 can redraw the component 1. Since the above interface loading exception condition that causes the component 1 to be drawn as a transparent component is usually single, the electronic device 100 can no longer exist the exception condition when redrawing the component 1.
[0222] As shown in FIG. 5, after redrawing, the display state of the component 1 can change from the transparent state to the non-transparent component. That is, after the electronic device 100 redraws the component 1, the component 1 can become a non-transparent component displayed in the foreground.
[0223] Since the operation 1 acts on the position 1 where the component 1 is displayed, the electronic device 100 can only redraw the component 1 without redrawing other components (such as the component 4) in the window 1. After redrawing the component 1, the display state of the component 4 can still be the transparent state. It can be understood that since the user does not perform the user operation on the component 4, the component 4 is a component that the user temporarily does not need to use, and the electronic device 100 can not need to waste resources to draw the component 4. This not only can save the resources of the electronic device 100, but also can reduce the time required for redrawing the component.
[0224] After redrawing the component 1, the display effect of the above window 1 and window 2 on the screen can be that the component 1 in the window 1 is visible to the user, part of the content in the window 2 is blocked by the component 1, but the remaining content not blocked by the component 1 is still visible to the user. For example, the component 2 in the window 2 is a component displayed under the component 1. In the case that the component 1 is a non-transparent component, the component 2 is blocked by the component 1. The component 3 in the window 2 is not blocked by the component 1. Therefore, after redrawing the component 1, the component 2 is not visible to the user, and the component 3 is still visible to the user.
[0225] If the component 1 has the ability to respond to the operation 1, the component 1 should be visible to the user so that the user can operate the component 1. Before the component 1 is redrawn, the component 1 is transparently displayed due to the drawing exception, and is not responsive to the operation 1 in the case of having the ability to respond to the operation 1. That is, the transparent component causes the electronic device 100 to be frozen. The electronic device 100 redraws the component 1, which can make the component 1 return to a non-transparent component, and quickly recover the response to the operation 1. In this way, the electronic device 100 can quickly recover from the freezing by redrawing the component that the user needs to use after the freezing, and reduce the time for the user to wait for the component to respond to the user operation.
[0226] In some embodiments, in response to the operation 1 acting on the position 1, if the component 1 is a transparent component displayed in the foreground and does not have the ability to respond to the operation 1, the electronic device 100 can transparently transmit the user operation event corresponding to the operation 1 to the component 2 without redrawing the component 1. The component 2 can respond to the operation 1 according to the user operation event corresponding to the operation 1. In this way, the electronic device 100 can provide the response result of the component 2 to the operation 1.
[0227] In some embodiments, before the component 1 is redrawn, the display state of the component 1 is a non-transparent state. In response to the operation 1 acting on the position 1, if the component 1 has the ability to respond to the operation 1, the electronic device 100 can detect whether the component 1 responds to the operation 1. If the component 1 does not respond to the user operation acting on the position 1 for k times, the electronic device 100 can redraw the component 1. When the electronic device 100 redraws the component 1, the abnormal situation may no longer exist, so that the component 1 quickly recovers the response. That is, before and after the component 1 is redrawn, the component 1 is visible to the user, but the component 1 can respond to the operation 1 after being redrawn. It can be seen that if the electronic device 100 can make the component 1 recover the response by redrawing the component 1, there is no need to restart the application associated with the component 1. In this way, the electronic device 100 can solve the freezing problem at the least cost, make the component that the user needs to use quickly recover the response, and reduce the waiting time of the user.
[0228] In some embodiments, in response to the operation 1 acting on the position 1 of the component 1, the electronic device 100 can redraw all the components included in the window 1. In this way, the electronic device 100 can timely redraw the window that the user wants to open after the freezing, and reduce the time for the user to wait for the component to respond to the user operation when the user wants to open other components.
[0229] FIGS. 6A and 6B show another schematic diagram of redrawing a component provided in the present application.
[0230] In some embodiments, the electronic device 100 redraws the component displayed on the screen, and can adjust the component ID of the component. That is, the component ID of the component changes before and after being redrawn.
[0231] As shown in FIG. 6A, the components displayed on the screen of the electronic device 100 can include component 1, component 2, component 3, and component 4. The components 1-4 can include transparent components and / or non-transparent components, and can be components of the same or different application programs. Without being limited to the components 1-4, more or fewer components can also be displayed on the screen. Here, the components 1-4 are taken as examples for illustration.
[0232] For example, the component ID of the component 1 can be ID1. The component ID of the component 2 can be ID2. The component ID of the component 3 can be ID3. The component ID of the component 4 can be ID4. If the component 1 needs to be redrawn, the desktop service can redraw the component 1 and adjust the component ID of the component 1. For example, the component ID of the redrawn component 1 is ID5. Alternatively, the desktop service can determine the component ID of the redrawn component 1 according to the component IDs of the components currently existing on the screen. The component ID of the redrawn component 1 can be used to uniquely identify the component 1 on the screen. The above process of redrawing the component 1 can be equivalent to destroying the component 1 with the component ID of ID1 and drawing the component 1 with the component ID of ID5.
[0233] The above method of determining whether the component 1 needs to be redrawn can refer to the foregoing description of FIG. 4.
[0234] As shown in FIG. 6A, since the components 2-4 are not redrawn, the component IDs of the components 2-4 can remain unchanged before and after the component 1 is redrawn.
[0235] The above adjustment of the component ID when the component 1 is redrawn can effectively indicate that the electronic device 100 performs the redrawing operation on the component 1.
[0236] Alternatively, the electronic device 100 can also keep the component ID of the component 1 unchanged before and after the component 1 is redrawn.
[0237] In some embodiments, the component 1 includes one or more sub-components. When the component 1 is redrawn, the electronic device 100 can also redraw the sub-components included in the component 1.
[0238] As shown in FIG. 6B, the component ID of the component 1 is ID1. The sub-components of the component 1 can include component 11 and component 12. Without being limited to the components 11 and 12, the component 1 can also include more or fewer sub-components.
[0239] If component 1 needs to be redrawn, the desktop service can redraw component 1 as well as component 11 and component 12. Component 11' can be the redrawn component 11. Component 12' can be the redrawn component 12. After component 1 is redrawn, the component ID of component 1 can change. For example, the component ID of component 1 changes from ID1 to ID5. Component 11 and component 12 also have responsive component IDs. When component 11 and component 12 are redrawn with component 1, the component IDs of component 11 and component 12 can also change. That is, the component ID of component 11' can be different from the component ID of component 11. The component ID of component 12' can be different from the component ID of component 12. Embodiments of the present application do not limit the component IDs of component 11' and component 12'.
[0240] It can be understood that a component contains sub-components that are usually displayed within the area displayed by the component. That is, the position of the sub-component display usually does not exceed the boundary of the content presented by the parent component. The content presented by the sub-component can be equivalent to a part of the content redrawn when the parent component is redrawn. Therefore, when the electronic device redraws a component, the electronic device can redraw the sub-components contained in the component.
[0241] In some embodiments, the freezing of the electronic device 100 can be caused by memory leakage. The electronic device 100 can detect memory leakage and manage the processes in the electronic device 100 according to the amount of memory leakage and the amount of currently available memory in the electronic device 100. In this way, the freezing caused by memory leakage can be prevented, and the freezing problem can be quickly solved when the electronic device 100 freezes.
[0242] FIG. 7 exemplarily shows a flowchart of a method for processing memory leakage according to an embodiment of the present application.
[0243] S711. The electronic device 100 performs memory leakage detection on the processes in the electronic device 100 in turn, and the processes in the electronic device 100 include process 1.
[0244] In some embodiments, a plurality of processes can be executable in the electronic device 100. The electronic device 100 performs memory leakage detection on the plurality of processes in turn and cyclically. The order of performing memory leakage detection in turn is not limited in the embodiments of the present application. Alternatively, the electronic device 100 can select a process for memory leakage detection every preset time period. The duration of the preset time period is not limited in the embodiments of the present application.
[0245] Here, the electronic device 100 performing memory leakage detection on process 1 and managing process 1 is taken as an example for illustration. Process 1 can be the process of any application program.
[0246] S712. The electronic device 100 detects that the amount of memory leakage of process 1 is leakage amount 1.
[0247] In some embodiments, the electronic device 100 can store memory usage thresholds corresponding to different processes. The memory usage threshold corresponding to a process can be used to detect the memory leakage amount of the process. The memory usage threshold corresponding to a process can reflect the peak value of the memory occupied by the process in the case of no memory leakage or only a small amount of memory leakage. The memory usage threshold corresponding to a process can be determined according to the amount of memory occupied by the process during the running process. The embodiments of the present application do not limit the method for determining the memory usage threshold corresponding to a process.
[0248] The memory usage thresholds corresponding to different processes can be different. For example, the memory usage threshold corresponding to process 1 can be memory usage threshold 1.
[0249] The electronic device 100 can obtain the amount of memory occupied by process 1. The electronic device 100 can determine the memory leakage amount of process 1 by comparing the amount of memory occupied by process 1 with the memory usage threshold corresponding to process 1. For example, if the amount of memory occupied by process 1 is less than or equal to memory usage threshold 1, the electronic device 100 can determine that process 1 has no memory leakage. If the amount of memory occupied by process 1 is greater than memory usage threshold 1, the electronic device 100 can determine that process 1 has memory leakage, and the memory leakage amount is leakage amount 1. Leakage amount 1 can be the value obtained by subtracting memory usage threshold 1 from the amount of memory occupied by process 1.
[0250] In some embodiments, step S712 can be performed by a memory leakage detection module in the electronic device 100. The memory leakage detection module can send leakage amount 1 to a memory management module in the electronic device 100.
[0251] The above embodiments are only exemplary descriptions of the method for detecting the memory leakage amount of a process provided by the present application, and should not limit the present application. The electronic device 100 can also use other methods to detect the memory leakage amount of a process.
[0252] Based on the size of leakage amount 1, the electronic device 100 can perform step S713 or step S714 or step S715.
[0253] S713, when leakage amount 1 is less than or equal to leakage threshold 1, the electronic device 100 takes leakage prevention strategy for process 1.
[0254] In some embodiments, the electronic device 100 determines whether leakage amount 1 is greater than leakage threshold 1. Leakage threshold 1 can be preset. The embodiments of the present application do not limit the value of leakage threshold 1. For example, leakage threshold 1 can be 200MB.
[0255] Alternatively, the leakage amount threshold 1 can be determined according to the memory usage threshold 1. For example, the leakage amount threshold 1 can be 1 / 2 of the memory usage threshold 1.
[0256] In some embodiments, the leakage prevention strategy can include, but is not limited to, prohibiting new thread creation in the background, prohibiting background association or binding of services, no longer allocating new memory to the process, periodically performing memory leakage detection on the process, and the like. Among them, the above-mentioned background association or binding of services can be used to realize the communication and interaction between the background service in the process and other components.
[0257] As can be seen, the above-mentioned leakage prevention strategy is mainly used to prevent the memory leakage amount of the process from further increasing while trying not to affect the running of the process. The leakage prevention strategy can also be called other names.
[0258] If the leakage prevention strategy is taken for the process 1, the electronic device 100 performs memory leakage detection on the process 1 according to a preset period in addition to the order of round-robin detection in step S711. In this way, when the memory leakage amount of the process 1 changes, the electronic device 100 can timely adjust the management strategy of the process 1 according to the memory leakage amount of the process 1.
[0259] As can be understood, the leakage amount 1 being less than or equal to the leakage amount threshold 1 can indicate that the current memory leakage amount of the process 1 is small, and the impact and harm caused in the electronic device 100 is not large. Therefore, the electronic device 100 can take the leakage prevention strategy for the process 1. This can not only reduce the impact on the running of the process 1 to avoid affecting the user to use the application program corresponding to the process 1, but also prevent the memory leakage amount of the process 1 from increasing, and reduce the situation of the electronic device 100 freezing due to memory leakage.
[0260] S714, when the leakage amount 1 is greater than the leakage amount threshold 1, and the memory currently available to the electronic device 100 is greater than the memory threshold 1, the electronic device 100 takes the leakage containment strategy for the process 1.
[0261] In some embodiments, when the leakage amount 1 is greater than the leakage amount threshold 1, the electronic device 100 can further determine whether the memory currently available to the electronic device 100 is greater than the memory threshold 1. The memory currently available to the electronic device 100 can be the memory that has not been allocated in the electronic device 100, that is, the available memory.
[0262] The above-mentioned memory threshold 1 can be preset. The present application embodiment does not limit the value of the memory threshold 1. For example, the memory threshold 1 can be 1 GB.
[0263] In some embodiments, the leakage containment strategy can include, but is not limited to, garbage collection (GC), clearing thread local caching (tcache), memory compression, memory reclamation, and the like. GC can refer to when a part of memory space occupied by an application program is no longer accessed by the program, the program can return the part of memory space by means of a garbage collection algorithm. A process can include one or more threads. Each thread can have its own cache. The above-mentioned clearing tcache can mean clearing the cache of one or more threads in the process and reclaiming the memory space occupied by the cleared cache. The above-mentioned memory compression can adopt zip random access memory (zRAM) technology and the like.
[0264] As can be seen, the above-mentioned leakage containment strategy mainly recovers part of the memory occupied by the process to reduce the amount of memory leakage of the process. The leakage containment strategy can also be called other names. The effect of taking the leakage containment strategy on process 1 is greater than the effect of taking the leakage prevention strategy on process 1.
[0265] As can be understood, leakage amount 1 is greater than leakage amount threshold 1, which can indicate that the current memory leakage amount of process 1 is large. The current available memory of electronic device 100 is greater than memory threshold 1, which can indicate that the current available memory of electronic device 100 is still sufficient. In the case that the memory leakage amount of process 1 is large, but the current available memory of electronic device 100 is sufficient, electronic device 100 can basically withstand the impact caused by the memory leakage of process 1. Therefore, electronic device 100 can take the leakage containment strategy for process 1. This can reduce the memory leakage of process 1 while minimizing the impact on the running of process 1, thereby reducing the impact on the user using the application program corresponding to process 1.
[0266] S715, when leakage amount 1 is greater than leakage amount threshold 1, and the current available memory of electronic device 100 is less than or equal to memory threshold 1, electronic device 100 takes the leakage removal strategy for process 1.
[0267] In some embodiments, the leakage removal strategy can include, but is not limited to, cleaning foreground processes and providing process cleaning prompts, cleaning foreground associated processes when electronic device 100 is turned off, prioritizing cleaning of non-resident processes and non-foreground dependent processes, and killing and recovering background processes.
[0268] Here, the electronic device 100 is taken as an example to introduce the leakage removal strategy for the process 1. The above cleaning foreground processes and providing process cleaning prompts can mean that, in the case that the electronic device 100 is in a bright screen state, if the process 1 is a foreground process, the electronic device 100 can provide a prompt to clean the process 1. In this way, the electronic device 100 can determine whether to clean the process 1 according to the user's selection. For example, in response to the user selecting an operation of not cleaning the process 1, the electronic device 100 can keep the process 1 running in order to affect the user's use experience. The above background process killing and recovery can mean that, in the case that the electronic device 100 is in a bright screen state, if the process 1 is a background process, the electronic device 100 can clean the process 1 (i.e., terminate the running of the process 1) and recover the memory of the process 1. The above cleaning foreground associated processes when the electronic device 100 is in a dark screen state can mean that, in the case that the electronic device 100 is in a dark screen state, the electronic device 100 can clean the process 1. The above non-resident process and non-foreground dependent process prioritization cleaning can mean that the electronic device 100 can determine whether the process 1 is a process that the foreground process runs on or a non-resident process. If the process 1 is a non-foreground dependent process and a non-resident process, the electronic device 100 can clean the process 1. If the process 1 is a process that the foreground process runs on, the electronic device 100 can wait until the process 1 becomes a non-foreground dependent process before cleaning the process 1, or provide a prompt to clean the process 1 for the user to select whether to clean the process 1. If the process 1 is a resident process, the electronic device 100 can keep the process 1 running.
[0269] It can be seen that the leakage removal strategy for the process 1 can make the process 1 stop running. After the process 1 stops running, the memory occupied by the process 1 is all recovered. In this way, the memory leakage of the process 1 is naturally eliminated with the process 1 stopping running. That is to say, the above leakage removal strategy mainly eliminates the memory leakage of the process by ending the process. The leakage removal strategy can also be called other names.
[0270] It can be understood that the leakage amount 1 is greater than the leakage threshold 1, which can indicate that the current memory leakage amount of the process 1 is large. The current available memory of the electronic device 100 is less than or equal to the memory threshold 1, which can indicate that the current available memory of the electronic device 100 is insufficient. At this time, if there is a process in the electronic device 100 that needs to apply for new memory, the electronic device 100 can occur memory overflow. The electronic device 100 running the program can be stuck, and thus the freezing screen is extremely likely to occur. Therefore, the electronic device 100 can take the leakage removal strategy for the process 1. In this way, the memory leakage of the process 1 can be eliminated, and the freezing screen caused by the memory leakage of the electronic device 100 can be reduced. Moreover, if the electronic device 100 appears the freezing screen caused by the memory leakage, the electronic device 100 can eliminate the memory leakage of one or more processes by the above leakage removal strategy, so that the available memory of the electronic device 100 is increased. The freezing screen problem can be solved as the available memory of the electronic device 100 is increased.
[0271] In some embodiments, the above determining whether the leakage amount 1 is greater than the leakage threshold 1, and determining whether the current available memory of the electronic device 100 is greater than the memory threshold 1 can be performed by a memory management module in the electronic device 100. The above taking the leakage prevention strategy or the leakage containment strategy or the leakage removal strategy for the process 1 can be performed by a process management module in the electronic device 100. The memory management module can send the process management strategy (such as the leakage prevention strategy, or the leakage containment strategy, or the leakage removal strategy) for the process 1 to the process management module.
[0272] From the above method, it can be known that the electronic device 100 can manage the process when the process appears memory leakage. The electronic device 100 can determine to take the leakage prevention strategy or the leakage containment strategy or the leakage removal strategy for the process according to the memory leakage amount of the process and the available memory in the electronic device 100. In this way, the freezing screen caused by memory leakage can be reduced, and the influence of managing the process on the running of the process can be reduced as much as possible, and the user experience can be improved.
[0273] In some embodiments, when the leakage containment strategy or the leakage removal strategy is taken for the process, the electronic device 100 can recycle part of the memory occupied by the process. The electronic device 100 can adjust the memory usage threshold corresponding to the process according to the memory recycling benefit. The adjusted memory usage threshold can more accurately reflect the peak value of the memory occupied by the process in the case of no memory leakage or only a small amount of memory leakage.
[0274] FIG. 8 exemplarily shows a method flowchart for adjusting a memory usage threshold according to an embodiment of the present application.
[0275] S811, after the electronic device 100 takes the leakage containment strategy or the leakage removal strategy for the process 1, the electronic device 100 detects the memory recycling benefit.
[0276] In the case that the leakage containment policy or the leakage removal policy is taken for the process 1, the electronic device 100 can determine an estimated memory recovery amount of the process 1. The estimated memory recovery amount can be used to represent an estimated memory amount recovered from the memory occupied by the process 1 in the case that the process has a memory leakage.
[0277] In some embodiments, the estimated memory recovery amount can be determined according to the memory usage threshold currently corresponding to the process 1 and the memory amount currently occupied by the process. The estimated memory recovery amount of the process 1 can be a value obtained by subtracting the memory usage threshold currently corresponding to the process 1 from the memory amount currently occupied by the process 1, i.e., the memory leakage amount of the process 1 determined according to the memory usage threshold currently corresponding to the process 1. For example, the memory usage threshold currently corresponding to the process 1 is 2 GB. The memory amount currently occupied by the process 1 is 4 GB. The electronic device 100 can determine the memory leakage amount of the process 1 and the estimated memory recovery amount as 2 GB.
[0278] Alternatively, the estimated memory recovery amount can be determined according to the memory usage threshold currently corresponding to the process, the memory amount currently occupied by the process, and the leakage amount threshold of the process. The estimated memory recovery amount can be a value obtained by subtracting the memory amount currently occupied by the process from the memory usage threshold currently corresponding to the process and subtracting the leakage amount threshold of the process. For example, the memory usage threshold currently corresponding to the process 1 is 2 GB. The memory amount currently occupied by the process 1 is 4 GB. The leakage amount threshold of the process 1 is 0.5 GB. The electronic device 100 can determine the memory leakage amount of the process 1 as 2 GB and the estimated memory recovery amount as 1.5 GB.
[0279] The electronic device 100 can also detect an actual memory recovery amount after the leakage containment policy or the leakage removal policy is taken for the process 1. The actual memory recovery amount can be an actual memory amount recovered from the memory occupied by the process 1, i.e., an increment of the available memory of the whole machine after the memory of the process 1 is recovered.
[0280] According to the estimated memory recovery amount and the actual memory recovery amount, the electronic device 100 can determine a memory recovery benefit. The memory recovery benefit can be a value obtained by subtracting the actual memory recovery amount from the estimated memory recovery amount. For example, the estimated memory recovery amount is 2 GB. The actual memory recovery amount is 1 GB. Then the memory recovery benefit is 1 GB.
[0281] It can be understood that, since the memory usage threshold corresponding to the process 1 is an estimated value of the peak of the memory occupied by the process 1 in the case that there is no memory leak or only a small amount of memory leak, the memory leak amount determined by the electronic device 100 according to the memory usage threshold is actually all the memory amount of the memory leak. That is to say, the memory leak amount of the process 1 determined by the electronic device 100 is often greater than the actual memory leak amount of the process 1. Moreover, the electronic device 100 is difficult to recover all the memory occupied by the memory leak when recovering the memory of the process 1. Therefore, the actual memory recovery amount is usually less than the estimated memory recovery amount.
[0282] In S812, the electronic device 100 can adjust the memory usage threshold 1 based on the memory recovery benefit, and the memory usage threshold 1 is used to detect the memory leak amount of the process 1.
[0283] In some embodiments, the electronic device 100 can add the memory recovery benefit to the memory usage threshold currently corresponding to the process 1 to obtain a new memory usage threshold. For example, the memory usage threshold corresponding to the process 1 is the memory usage threshold 1. Before adjusting the memory usage threshold 1, the memory usage threshold 1 is 2 GB. If the memory recovery benefit is 1 GB, then after the electronic device 100 adjusts the memory usage threshold 1 based on the memory recovery benefit, the memory usage threshold 1 is 3 GB. The electronic device 100 can use the adjusted memory usage threshold 1 to detect the memory leak of the process 1.
[0284] In some embodiments, the process management module in the electronic device 100 can manage the process 1 and recover the memory of the process 1. The memory management module in the electronic device 100 can determine the actual memory recovery amount of the process 1 and send the actual memory recovery amount of the process 1 to the memory leak detection module of the electronic device 100. Then, the memory leak detection module can execute S812 according to the actual memory recovery amount of the process 1.
[0285] From the above method, it can be known that the electronic device 100 can dynamically adjust the memory usage threshold corresponding to the process 1 according to the result of recovering the memory of the process 1 when the process 1 has a memory leak. In this way, the memory usage threshold corresponding to the process 1 can more accurately reflect the peak of the memory occupied by the process 1 in the case that there is no memory leak or only a small amount of memory leak, thereby improving the accuracy of memory leak amount detection.
[0286] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the steps in the above-mentioned various method embodiments.
[0287] The embodiment of the present application further provides a computer program product, comprising a computer program, when the computer program runs on a processor, steps in each method embodiment described above can be realized.
[0288] The embodiment of the present application further provides a chip system, comprising a processing circuit and an interface circuit, the interface circuit is used for receiving code instructions and transmitting the processing circuit, the processing circuit is used for running the code instructions so that the chip system realizes steps in any method embodiment of the present application. Wherein, the chip system can be a single chip, or a chip module composed of multiple chips.
[0289] It can be understood that each user interface described in the embodiment of the present application is only an example interface, and does not limit the scheme of the present application. In other embodiments, the user interface can adopt different interface layouts, can include more or less controls, can increase or reduce other function options, as long as the same invention idea provided in the present application is based on, it is within the protection scope of the present application.
[0290] It should be noted that, in the case of no contradiction or conflict, any feature in any embodiment of the present application, or any part of any feature can be combined, and the combined technical solution is also within the scope of the embodiments of the present application.
[0291] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for handling frozen screens, characterized in that, The method includes: An electronic device displays a first interface, the first interface including a first component; The electronic device detects a first operation performed on the first component; When the first component does not respond to the first operation, the electronic device redraws the first component; When the first component responds to the first operation, the electronic device displays the response result of the first component to the first operation.
2. The method according to claim 1, characterized in that, The first component has the ability to respond to the first operation.
3. The method according to claim 1 or 2, characterized in that, Before the electronic device redraws the first component, the first component is a transparent component displayed in the foreground; after the electronic device redraws the first component, the first component is a non-transparent component displayed in the foreground.
4. The method according to claim 1 or 2, characterized in that, The first component is a non-transparent component displayed in the foreground.
5. The method according to claim 4, characterized in that, The first operation includes k second operations, where k is a positive integer greater than 1. The first component not responding to the first operation includes: the first component not responding to the second operation k times.
6. The method according to any one of claims 1-5, characterized in that, The first component includes one or more sub-components, and the electronic device redraws the first component, specifically including: The electronic device redraws the first component and the one or more sub-components.
7. The method according to any one of claims 1-6, characterized in that, Before the electronic device redraws the first component, the component ID of the first component is the first component ID; after the electronic device redraws the first component, the component ID of the first component is the second component ID.
8. The method according to any one of claims 1-7, characterized in that, When the first component is redrawn, the other components in the first interface remain unredrawn.
9. The method according to any one of claims 1-8, characterized in that, After the electronic device redraws the first component, the method further includes: The electronic device detects a third operation performed on the first component, the third operation being of the same type as the first operation; In response to the third operation, the electronic device performs the function corresponding to the first component or opens the interface corresponding to the first component.
10. The method according to any one of claims 1-8, characterized in that, After the electronic device redraws the first component, the method further includes: The electronic device detects a fourth operation performed on the first component, and the first component has the capability to respond to the fourth operation; If the first component does not respond to the fourth operation, the electronic device restarts the process associated with the first component.
11. The method according to any one of claims 1-10, characterized in that, The first interface includes a second component and a third component, wherein the second component is a transparent component displayed in the foreground, and the third component is a non-transparent component displayed below the second component. The method further includes: The electronic device detects a fifth operation acting on the locations of the second component and the third component, wherein the second component does not have the ability to respond to the fifth operation, and the third component has the ability to respond to the fifth operation; In response to the fifth operation, the electronic device performs the function corresponding to the third component or opens the interface corresponding to the third component.
12. The method according to any one of claims 1-11, characterized in that, The processes running on the electronic device include a first process, and the method further includes: If the memory leak amount of the first process is less than or equal to the first threshold, the electronic device adopts a first strategy for the first process. The first strategy includes one or more of the following: prohibiting the process from creating new threads in the background, prohibiting the process from associating or binding services in the background, no longer allocating new memory to the process, and periodically performing memory leak detection on the process.
13. The method according to claim 12, characterized in that, The method further includes: If the memory leak amount of the first process exceeds the first threshold, If the available memory of the electronic device is less than or equal to the second threshold, the electronic device adopts a second strategy for the first process. The second strategy includes one or more of the following: garbage collection, clearing thread-local cache, memory compression, and memory reclamation. If the available memory of the electronic device is greater than the second threshold, the electronic device adopts a third strategy for the first process. The third strategy includes one or more of the following: clearing foreground processes and providing process clearing prompts, clearing foreground related processes when the screen of the electronic device is turned off, prioritizing the clearing of non-resident processes and non-foreground dependent processes, and killing and restoring background processes.
14. The method according to claim 12 or 13, characterized in that, The electronic device stores a first memory usage threshold, and the memory leakage of the first process is determined based on the first memory usage threshold and the amount of memory occupied by the first process.
15. The method according to claim 14, characterized in that, The method further includes: After applying the second strategy or the third strategy to the first process, the electronic device detects the memory reclamation benefit of the electronic device, which is determined based on the estimated memory reclamation amount and the actual memory reclamation amount of the first process; The electronic device adjusts the first memory usage threshold based on the memory reclamation revenue.
16. An electronic device, characterized in that, The electronic device includes a memory and a processor, wherein the memory is used to store a computer program; the processor executes the computer program to implement the method of any one of claims 1-15.
17. A computationally readable storage medium storing instructions, characterized in that, When the instructions are executed by the processor, they implement the method of any one of claims 1-15.
18. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the method of any one of claims 1-15.
Citation Information
Patent Citations
Frozen screen processing method and electronic equipment
CN121166242A
Method and device for handling response anomaly of user equipment
CN105607980A
No touch screen response based use method and device
CN105867793A
Frozen screen processing method and terminal
CN111061410A
Frozen screen processing method, electronic equipment and storage medium
CN114879896A