Webpage view control method and device, electronic equipment and storage medium

By responding to the exit command of the web view in an Android application, removing its subview and releasing the reference relationship through the reflection mechanism, the memory leak problem after the web view is closed is solved, realizing timely memory recycling and stable device performance.

CN119884517APending Publication Date: 2025-04-25GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411916415.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

After closing, the web page view embedded in Android applications is not properly handled, resulting in memory leaks, occupying more and more memory, affecting device performance.

Method used

By responding to the exit command of the web page view, the subview in the root view it belongs to is removed, and the access permissions of the target private field is obtained through the reflection mechanism, and its parameter value is modified to a preset value to release the reference relationship, and finally control the exit of the web page view.

Benefits of technology

It effectively solves the problem of memory leak after the web view is closed, ensures that the system can recycle memory in time, maintains stable device performance, and avoids device performance degradation or application crashes caused by memory leaks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119884517A_ABST
    Figure CN119884517A_ABST
Patent Text Reader

Abstract

The invention provides a webpage view control method and device, electronic equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: in response to an exit instruction of a webpage view, removing a sub-view in a root view to which the webpage view belongs; obtaining an access permission of a target private field in a class corresponding to the webpage view through a reflection mechanism; under the condition that the access permission is obtained, modifying a parameter value of the target private field into a preset value so as to release a reference relationship of the webpage view; and controlling the webpage view to exit. According to the method, the problem of memory leakage after the webpage view is closed can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a control method, a control device, an electronic device and a storage medium for a web page view in the field of computer technology. Background Art

[0002] During the interface display process, a component for displaying web content, the web view, can be embedded in the Android application; the web page can be displayed in the application through the web view, and the user does not need to close the application and use the browser to view it.

[0003] When the user closes the content displayed by the web view, the activity cannot be completely destroyed due to the reference relationship between the web view and other resources in the system, resulting in more and more memory being occupied and a memory leak problem.

[0004] Therefore, it is necessary to provide a method for solving the memory leak problem after the web page view is closed. Summary of the invention

[0005] The present application provides a control method, a control device, an electronic device and a storage medium for a web page view, which can solve the memory leakage problem that exists after the web page view is closed.

[0006] In a first aspect, a method for controlling a web page view is provided, the method comprising:

[0007] In response to an exit instruction of the webpage view, remove a subview in a root view to which the webpage view belongs;

[0008] Get access to the target private fields in the class corresponding to the web view through the reflection mechanism;

[0009] When the access rights are obtained, the parameter value of the target private field is modified to the preset value to release the reference relationship of the web page view;

[0010] Controls web view exit.

[0011] In the above technical solution, after receiving the exit instruction of the web page view, in response to the exit instruction, the subview in the root view to which the web page view belongs is first removed; then the access rights to the target private field in the class corresponding to the web page view are obtained through the reflection mechanism; after obtaining the access rights, the parameter value of the target private field is modified to a preset value to release the reference relationship between the web page view and other parts; finally, the web page view is controlled to exit. When the web page view exits, if its related reference relationship is not properly handled, the memory occupied by the view and its associated objects may not be properly recycled, eventually causing a memory leak. The use of a reflection mechanism to release the reference relationship of the web page view can enable the system to recycle the memory occupied by the related references in a timely manner, thereby ensuring the stability of the overall available memory of the system, solving the memory leak problem after the web page view is closed, and further avoiding device performance degradation or even application crashes caused by memory leaks.

[0012] In combination with the first aspect, in some possible implementations, modifying the parameter value of the target private field to a preset value includes:

[0013] Modify the parameter value of the first private field of the target window to a preset value;

[0014] When the parameter value of the first private field of the target window is a preset value, modify the parameter value of the second private field of the root view to the preset value;

[0015] When the parameter value of the second private field of the root view is a preset value, modify the parameter value of the third private field of the root view context to the preset value;

[0016] When the parameter value of the third private field of the root view context is a preset value, modify the parameter value of the fourth private field of the root view to the preset value;

[0017] The second private field and the fourth private field are different private fields in the root view.

[0018] In the above technical solution, the corresponding parameter values ​​are modified to preset values ​​in the order of the first private field of the target window, the second private field of the root view, the third private field of the root view context, and the fourth private field of the root view. Modifying the parameter value of the private field to the preset value can release the reference relationship between the web page view and the related parts, thereby ensuring that after the web page view exits, there will be no memory leak problem due to the existence of the reference relationship, ensuring that the memory can be recycled and reused in time, and improving memory usage efficiency. In addition, according to the order of processing the target window first and then processing the root view, problems such as abnormal window display caused by premature release of root view resources are avoided, ensuring a smooth and orderly memory release process.

[0019] In combination with the first aspect and the above implementation manner, in some possible implementation manners, modifying the parameter value of the first private field of the target window to a preset value includes:

[0020] Change the parameter value of the window close callback field of the target window to a null value;

[0021] When the parameter value of the window close callback field of the target window is a null value, the parameter value of the window controller callback field of the target window is modified to a null value;

[0022] When the parameter value of the window controller callback field of the target window is a null value, the parameter value of the context information field of the target window is modified to a null value.

[0023] In the above technical solution, in the process of modifying the parameter value of the first private field of the target window, the window closing callback field, the window controller callback field, and the context information field are modified in sequence, and the parameter value is modified to a null value. The relevant reference relationship between the web page view and the target window can be cut off, so that the system can identify and recycle these unused resources, ensure that the memory is effectively released, maintain the healthy state of the overall system memory, and thus solve the memory leak problem after the web page view is closed.

[0024] In combination with the first aspect and the above implementation, in some possible implementations, modifying the parameter value of the second private field of the root view to a preset value includes:

[0025] Change the parameter value of the root content field of the root view to a null value;

[0026] When the parameter value of the root content field of the root view is a null value, the parameter value of the window field of the root view is modified to a null value;

[0027] When the parameter value of the window field of the root view is a null value, the parameter of the context field of the root view is configured as a global context parameter.

[0028] In the above technical solution, in the process of modifying the parameter value of the private field related to the root view, the second private field of the root view is first modified, and then the parameter value of the root content field, the parameter value of the window field and the parameter value of the online text field are modified in sequence. The strong reference relationship between the above resources and the web page view is cut off, so that the objects associated with them can be identified and recycled by the system, avoiding the problem of long-term memory occupation caused by the failure to properly release the root view and its related resources, thereby ensuring the reasonable use of system memory and preventing the occurrence of memory leaks.

[0029] In combination with the first aspect and the above implementation, in some possible implementations, modifying the parameter value of the third private field of the root view context to a preset value includes:

[0030] Change the parameter value of the context information field of the root view context to a null value;

[0031] When the parameter value of the context information field of the root view context is a null value, the parameter value of the phone window field of the root view context is modified to a null value.

[0032] In the above technical solution, the parameter of the context information field of the root view context is first modified to a null value; and then the parameter value of the phone window field is modified to a null value. By modifying the parameter values ​​of these fields to null values ​​in sequence, the association between the web page view and the root view context can be cut off, so that the relevant memory resources can be correctly released, ensuring the rational use of system memory resources, maintaining the healthy state of memory, avoiding the problem of excessive memory usage due to long-term operation, and solving the problem of memory leaks.

[0033] In combination with the first aspect and the above implementation, in some possible implementations, modifying the parameter value of the fourth private field of the root view to a preset value includes:

[0034] Change the parameter value of the key tag field of the root view to an empty value;

[0035] When the parameter value of the key tag field of the root view is null, modify the parameter value of the parent view field of the root view to a null value.

[0036] In the above technical solution, the parameter value of the key tag field of the root view and the parameter value of the parent view field are modified to null values ​​in turn. The reference relationship between the key tag field and the parent view field in the web page view and the root view is released, so that the relevant memory resources can be released smoothly, ensuring the effective use of memory, maintaining the healthy state of the system memory, and solving the memory leak problem caused by the uncut reference relationship.

[0037] In combination with the first aspect and the above implementation, in some possible implementations, removing a subview in a root view to which a webpage view belongs includes:

[0038] Get the subview of the root view to which the web view belongs;

[0039] Remove the subviews in the root view through the view removal function.

[0040] In the above technical solution, in response to the exit instruction of the web page view, all subviews in the root view to which the web page view belongs are first obtained; and then all subviews in the root view are removed through the view removal function. Since the subviews in the root view to which the web page view belongs will occupy a certain amount of memory space to store their own data, status, and related graphic resources, etc. When the user closes the web page view, if the subviews are not removed in time, memory leaks may occur. By obtaining and removing them using the view removal function, the association between these subviews and the root view and the entire system can be cut off, so that the relevant memory can be recovered by the garbage collection mechanism, thereby effectively avoiding the waste of memory resources and maintaining the healthy state of the system memory.

[0041] In a second aspect, a device for controlling a web page view is provided, the device comprising:

[0042] A removal module, used to remove a subview in a root view to which the webpage view belongs in response to an exit instruction of the webpage view;

[0043] The acquisition module is used to obtain the access rights of the target private field in the class corresponding to the web view through the reflection mechanism;

[0044] A modification module is used to modify the parameter value of the target private field to a preset value to release the reference relationship of the web page view when the access permission is obtained;

[0045] The control module is used to control the exit of the web page view.

[0046] In combination with the second aspect, in some possible implementations, the modification module is also used to modify the parameter value of the first private field of the target window to a preset value; when the parameter value of the first private field of the target window is the preset value, the parameter value of the second private field of the root view is modified to the preset value; when the parameter value of the second private field of the root view is the preset value, the parameter value of the third private field of the root view context is modified to the preset value; when the parameter value of the third private field of the root view context is the preset value, the parameter value of the fourth private field of the root view is modified to the preset value; wherein the second private field and the fourth private field are different private fields in the root view.

[0047] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the modification module is specifically used to modify the parameter value of the window close callback field of the target window to a null value; when the parameter value of the window close callback field of the target window is a null value, the parameter value of the window controller callback field of the target window is modified to a null value; when the parameter value of the window controller callback field of the target window is a null value, the parameter value of the context information field of the target window is modified to a null value.

[0048] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the modification module is specifically used to modify the parameter value of the root content field of the root view to a null value; when the parameter value of the root content field of the root view is a null value, modify the parameter value of the window field of the root view to a null value; when the parameter value of the window field of the root view is a null value, configure the parameters of the context field of the root view as global context parameters.

[0049] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the modification module is specifically used to modify the parameter value of the context information field of the root view context to a null value; when the parameter value of the context information field of the root view context is a null value, the parameter value of the phone window field of the root view context is modified to a null value.

[0050] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the modification module is specifically used to modify the parameter value of the key tag field of the root view to a null value; when the parameter value of the key tag field of the root view is a null value, the parameter value of the parent view field of the root view is modified to a null value.

[0051] In combination with the second aspect and the above implementations, in some possible implementations, the removal module is specifically used to obtain a subview in a root view to which the web page view belongs; and remove the subview in the root view through a view removal function.

[0052] In a third aspect, an electronic device is provided, comprising a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in the first aspect or any possible implementation of the first aspect.

[0053] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.

[0054] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a schematic diagram of a system architecture provided by an embodiment of the present application;

[0056] Figure 2 It is a hierarchical structure diagram of a web page view display provided by an embodiment of the present application;

[0057] Figure 3 is a schematic flow chart of a method for controlling a web page view provided in an embodiment of the present application;

[0058] Figure 4 is a schematic flow chart of another method for controlling a web page view provided in an embodiment of the present application;

[0059] Figure 5 is a structural schematic diagram of a control device for a web page view provided in an embodiment of the present application;

[0060] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0062] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0063] Android 12 for the Android system is an operating system developed by Google. The Android system's web view (WebView) is a component that embeds web page (Web) content in Android applications. It allows developers to display web pages in applications without requiring users to leave the application and use a browser to view them. WebView can load web content such as HTML (Hypertext Markup Language) pages, JavaScript scripts, CSS (Cascading Style Sheets), and provide interfaces for interacting with web pages, such as clicking links, filling out forms, and other operations. WebView is a control based on the WebKit engine that displays web pages. Figure 1 Schematic diagram of a system architecture provided by an embodiment of the present application. Figure 1 As shown, the system architecture includes application software, application software framework, C / C++ library and Linux kernel, etc.

[0064] Application software provides users with an intuitive operating interface to meet their needs in different fields. Application software includes home screen (Home), contacts, phone and browser, etc.

[0065] The application software framework provides the basic structure and common services for the development of application software. The application software framework may include an activity manager, which is mainly responsible for managing the activity components in the application and allocating system resources to different activities to ensure the normal operation of the activity;

[0066] The Window Manager is used to create, display, and manage application windows, as well as handle user interaction events related to windows, such as touch, key, and other input operations;

[0067] Content providers are used to share data between different applications or between different components of an application, and also coordinate the storage and management of data within the application;

[0068] The View system is used to build the user interface of the application and is responsible for rendering the view, presenting the layout and components of the interface to the user in a visual way;

[0069] Package manager, which is used to manage the installation, uninstallation, and update operations of applications, and provides the function of querying application-related information, such as the application name, version, permission requirements, etc.

[0070] Phone Manager, used to manage phone-related functions and monitor phone status changes, such as incoming calls, ongoing calls, and call endings;

[0071] The resource manager is responsible for organizing and managing various resources required by the application, including strings, colors, images, layout files, etc. During the application running process, the resource manager is responsible for loading the required resources and optimizing them according to the application status and system resource conditions;

[0072] The location manager is used to obtain the device's geographic location information and can regularly update the location information based on application requirements and user settings;

[0073] The message manager is responsible for managing the process of sending and receiving messages, as well as filtering messages. According to the user's settings (such as blocking text messages from certain numbers, only receiving messages from important contacts, etc.), the messages that meet the conditions will be processed accordingly.

[0074] C / C++ library is a set of pre-written functions and classes. C / C++ library may include display manager, media framework, SQLite, OpenGL (Open Graphics Library), FreeType, WebKit, SGL, SSL (Secure Sockets Layer), Libc (C Standard Library), etc. The operating environment of C / C++ library includes Java core library and Dalvik virtual machine.

[0075] The Linux kernel is the core part of the Linux operating system. It is responsible for managing the system's hardware resources and software processes and is the most basic part of the operating system. The Linux kernel can include a driver model that is responsible for the operating system's control of hardware devices and data exchange;

[0076] Memory management, which is responsible for managing and allocating the computer system's memory resources, including physical memory (RAM) and virtual memory;

[0077] Process management is responsible for creating, scheduling, synchronizing and terminating processes, and managing communications between processes.

[0078] Figure 2 This is a hierarchical structure diagram of a web page view display provided by an embodiment of the present application. Figure 2 As shown in the figure, in the display process of the web view (WebView), multiple hierarchical structures are involved, including the activity (Activity), the phone window (PhoneWindow), the root view (DecorView) and the web view (WebView).

[0079] The following describes the functions of each level and how the levels relate to each other.

[0080] Activity is one of the basic building blocks of Android applications and represents a single screen. Each Activity has a corresponding user interface and can interact with other Activities. Activity can be used to manage the user interface, handle user input, execute business logic, etc.

[0081] PhoneWindow is a concrete implementation class of Window, which is responsible for managing the window content of Activity. Each Activity has an associated PhoneWindow instance. PhoneWindow can be used to provide window management functions, including setting content view, adding title bar, displaying dialog boxes, etc.

[0082] The relationship between Activity and PhoneWindow is as follows: Each Activity has a PhoneWindow object inside to manage its window content. You can get the PhoneWindow instance of the current Activity through the Activity.getWindow() method.

[0083] DecorView is the top-level View of the entire Window interface, representing the entire Window interface. It is the root view of PhoneWindow and contains the contents of the entire Window. It is a subclass of ViewGroup and is usually used as the top-level container of Window. DecorView can be used to carry all other views, such as ContentView (actual application content), status bar, navigation bar, etc.

[0084] The relationship between PhoneWindow and DecorView is as follows: DecorView is the top-level view container of PhoneWindow. PhoneWindow uses DecorView to organize and manage all views within the window.

[0085] WebView is a view component used to embed web content, allowing developers to load and display web pages in applications. WebView can be used to provide web browsing functions and support web technologies such as HTML, CSS, and JavaScript.

[0086] The relationship between DecorView and WebView is as follows: WebView is one of the subviews of DecorView and is usually added to DecorView through the setContentView() method. WebView can be a direct subview or part of a deeper subview.

[0087] There is only one Window implementation class: PhoneWindow, which inherits from the Window abstract class. Each Window has a control center - ViewRootImpl, which is responsible for drawing the View tree and is the bridge between Window and DecorView. DecorView is the top-level View and the ancestor node (root node) of all Views. WebView is one of the many subviews (Views) added to DecorView.

[0088] A memory leak will occur when WebView is used normally in Android 12. Since WebView will hold a reference to the current Activity, the Activity will not be destroyed normally, which will cause memory leaks in the Activity, and the memory will increase with the usage time.

[0089] In view of the problems existing in the above-mentioned prior art, the embodiments of the present application provide a control method, a control device, an electronic device and a storage medium for a web page view. When an exit instruction of a web page view is received, in response to the exit instruction, all subviews in the root view where the web page view is located are removed; then the access rights to the target private field are obtained through the reflection mechanism; then, the parameter value in the target private field is modified to a preset value to release the reference relationship of the web page view, and finally the web page view is controlled to exit. This method can avoid the memory leak problem after the web page view is closed.

[0090] Combine the following Figure 3 and Figure 4 The control method of the web page view provided in the embodiment of the present application is described in detail.

[0091] Figure 3 This is a schematic flow chart of a method for controlling a web page view provided in an embodiment of the present application. It should be understood that the method can be applied to an electronic device; or, to a processor in an electronic device; or, to a chip in a processor mounted in an electronic device.

[0092] For example, Figure 3 As shown, the method 300 includes the following steps S301 to S304.

[0093] S301, in response to an exit instruction of a webpage view, removing a subview in a root view to which the webpage view belongs.

[0094] For example, when the user finishes accessing the web view interface through the application, he clicks the exit control (e.g., a close button, etc.) of the web view interface to close the web view. At this time, an exit instruction is generated according to the user's exit operation, and in response to the exit instruction, all subviews in the root view (DecorView) to which the web view belongs are removed.

[0095] In one implementation, the specific process of removing the subview in the root view to which the webpage view belongs may include: acquiring the subview in the root view to which the webpage view belongs; and removing the subview in the root view by using a view removal function.

[0096] Exemplarily, during the sub-view removal process, all sub-views in the root view to which the web page view belongs may be first acquired according to the web page view currently to be closed; and then all sub-views in the root view may be removed through the view removal function.

[0097] Optionally, the view removal function may be reviewAllViews; other function algorithms capable of implementing view removal may also be used; this embodiment of the present application does not specifically limit this.

[0098] In an embodiment of the present application, in response to the exit instruction of the web page view, all subviews in the root view to which the web page view belongs are first obtained; and then all subviews in the root view are removed through the view removal function. Because the subviews in the root view to which the web page view belongs will occupy a certain amount of memory space to store their own data, status, and related graphic resources. When the user closes the web page view, if the subviews are not removed in time, memory leaks may occur. By obtaining and removing them using the view removal function, the association between these subviews and the root view and the entire system can be cut off, so that the relevant memory can be recovered by the garbage collection mechanism, thereby effectively avoiding the waste of memory resources and maintaining the health of the system memory.

[0099] S302, obtaining access rights to a target private field in a class corresponding to the web page view through a reflection mechanism.

[0100] Reflection mechanism, also known as reflection technology, refers to a mechanism that can obtain the internal information of a class (such as member variables, methods, constructors, etc.) and operate these members during program execution. Reflection mechanisms are available in many programming languages, such as Java, C#, etc. Taking Java as an example, through reflection, classes can be dynamically loaded at runtime, class structure information can be obtained, and class methods and member variables can be called, and these operations do not need to be determined at compile time. Under normal circumstances, Java's encapsulation principle does not allow direct access to a class's private fields. For example, WebView or its related components (such as PhoneWindow, DecorView, etc.) may hold strong references to Activity internally, but these references are usually private and cannot be directly accessed. Through the reflection mechanism, developers can bypass access modifiers (such as private) and directly access and modify these private fields.

[0101] Exemplarily, after removing all subviews in the root view, the access rights to the target private field in the class to which the web page view belongs can be obtained through the reflection mechanism.

[0102] The target private fields may include private fields in the target window, private fields in the root view, and private fields in the root view context.

[0103] S303: When the access permission is obtained, the parameter value of the target private field is modified to a preset value to release the reference relationship of the web page view.

[0104] Exemplarily, after obtaining access rights to the target private field, the target private field can be accessed and operated; in order to release the reference relationship between the web page view and other structures, the parameter value of the target private field can be modified to a preset value when the access rights are obtained.

[0105] In one implementation, the process of modifying the parameter value of the target private field to a preset value may include:

[0106] Modify the parameter value of the first private field of the target window to a preset value;

[0107] When the parameter value of the first private field of the target window is a preset value, modify the parameter value of the second private field of the root view to the preset value;

[0108] When the parameter value of the second private field of the root view is a preset value, modify the parameter value of the third private field of the root view context to the preset value;

[0109] When the parameter value of the third private field of the root view context is a preset value, modify the parameter value of the fourth private field of the root view to the preset value;

[0110] The second private field and the fourth private field are different private fields in the root view.

[0111] For example, during the display of a web view (WebView), WebView and related components, such as the target window (Window), the root view (DecorView) and the root view context (DecorContext), will have strong references to the activity (Activity). In order to release the reference relationship between the web view and other parts, the parameter values ​​of the related private fields need to be adjusted. Due to the association between different levels, during the parameter value modification process, in order to avoid the influence of incorrect settings on subsequent processes, the parameter values ​​need to be modified accordingly in the order of the first private field of the target window, the second private field of the root view, the third private field of the root view context, and the fourth private field of the root view.

[0112] In an embodiment of the present application, the corresponding parameter values ​​are modified to preset values ​​in the order of the first private field of the target window, the second private field of the root view, the third private field of the root view context, and the fourth private field of the root view. Modifying the parameter value of the private field to the preset value can release the reference relationship between the web page view and the related parts, thereby ensuring that after the web page view exits, there will be no memory leak problem due to the existence of the reference relationship, ensuring that the memory can be recycled and reused in time, and improving memory usage efficiency. In addition, according to the order of processing the target window first and then processing the root view, problems such as abnormal window display caused by premature release of root view resources are avoided, ensuring a smooth and orderly memory release process.

[0113] In one implementation, the process of modifying the parameter value of the first private field of the target window to a preset value may include:

[0114] Change the parameter value of the window close callback field of the target window to a null value;

[0115] When the parameter value of the window close callback field of the target window is a null value, the parameter value of the window controller callback field of the target window is modified to a null value;

[0116] When the parameter value of the window controller callback field of the target window is a null value, the parameter value of the context information field of the target window is modified to a null value.

[0117] Exemplarily, the first private field related to the target window includes a window closing callback field, a window controller callback field, and a context information field.

[0118] Among them, the window closing callback field may be mOnWindowDismissedCallback; the window controller callback field may be mOnWindowControllerCallback; and the context information field may be mContext.

[0119] When a window on an electronic device is closed, the system or a related window management module triggers a window closing callback function to notify other parts of the application that the window has been closed. In order to remove the callback reference when the window is closed, first modify the parameter value corresponding to mOnWindowDismissedCallback to null.

[0120] After that, the window controller of the target window is usually responsible for managing and coordinating various behaviors of the window, such as showing, hiding, resizing, moving, and other operations of the window. When the state of the window changes, such as the window is restored from the minimized state, the window size is changed, or the window position is moved, the window controller can notify other related components or modules by calling mOnWindowControllerCallback. In order to remove the callback reference of the window controller, modify the parameter value corresponding to mOnWindowControllerCallback to null.

[0121] Finally, the context information may include the display status of the window, the user's operation history (such as click location, keyboard input record, etc.), the current theme and style information (used to determine the appearance of interface elements), etc. In order to remove the reference to the window context, modify the parameter value corresponding to mContext to null.

[0122] In the embodiment of the present application, in the process of modifying the parameter value of the first private field of the target window, the window closing callback field, the window controller callback field, and the context information field are modified in sequence, and the parameter value is modified to a null value. The relevant reference relationship between the web page view and the target window can be cut off, so that the system can identify and recycle these no longer used resources, ensure that the memory is effectively released, maintain the healthy state of the overall system memory, and thus solve the memory leak problem after the web page view is closed.

[0123] In one implementation, the process of modifying the parameter value of the second private field of the root view to a preset value may include:

[0124] Change the parameter value of the root content field of the root view to a null value;

[0125] When the parameter value of the root content field of the root view is a null value, the parameter value of the window field of the root view is modified to a null value;

[0126] When the parameter value of the window field of the root view is a null value, the parameter of the context field of the root view is configured as a global context parameter.

[0127] Exemplarily, the second private field of the root view (DecorView) may include a root content field (mContentRoot), a window field (mWindow), and a context field (mContext).

[0128] In Android development, mContentRoot may point to a ViewGroup (such as LinearLayout, RelativeLayout, etc.), which is the root container of the content and contains all other view elements. It is like the root of a tree, and all leaves (other view components) are mounted on this root. This makes it easy to manage the entire view content, such as adding, deleting or modifying subviews. In order to remove DecorView's reference to the content root view, first change the parameter value corresponding to mContentRoot to null.

[0129] Furthermore, in the Android view system, Window represents an abstract window concept, which is a container for views. DecorView is the top-level view of this window and the root container of all views. In order to remove DecorView's reference to the window, modify the parameter value corresponding to mWindow to null.

[0130] Finally, when the context field is set to the global context, related resources can be effectively managed and shared globally. For example, in an application, database connection is an important resource. If the context of the database connection is set to the global context, the connection can be managed uniformly throughout the application. The connection can be established when the application starts and released at the appropriate time (such as when the application is closed), avoiding memory leaks caused by frequent creation and destruction of connections in multiple local contexts.

[0131] For some cached data, it is convenient to put it in the global context for management. For example, a web application may cache some frequently visited web page fragments or query results. By caching in the global context, you can reduce the number of repeated database queries or regeneration of data. At the same time, you can monitor the usage of the cache globally. When the cached data is no longer needed (such as when the data expires or the memory is tight), you can effectively clear the cache to avoid leaks caused by excessive cached data occupying memory. Therefore, in order to avoid memory leaks caused by local context associations, configure the parameters corresponding to mContext as global context parameters (ApplicationContext).

[0132] In the embodiment of the present application, in the process of modifying the parameter value of the private field related to the root view, the second private field of the root view is first modified, and then the parameter value of the root content field, the parameter value of the window field, and the parameter value of the online text field are modified in sequence. The strong reference relationship between the above resources and the web page view is cut off, so that the objects associated with them can be recognized and recycled by the system, avoiding the problem of long-term memory occupation caused by the failure to properly release the root view and its related resources, thereby ensuring the reasonable use of system memory and preventing the occurrence of memory leaks.

[0133] In one implementation, the process of modifying the parameter value of the third private field of the root view context to a preset value may include:

[0134] Change the parameter value of the context information field of the root view context to a null value;

[0135] When the parameter value of the context information field of the root view context is a null value, the parameter value of the phone window field of the root view context is modified to a null value.

[0136] Exemplarily, the third private field related to the root view context (DecorContext) may include a context information field (mContext) and a phone window field (mPhoneWindow).

[0137] In order to remove the reference of the root view context to the context, first modify the parameter value of mContext of DecorContext to a null value (null); then, in order to remove the reference of the root view context to the phone window, modify the parameter value of mPhoneWindow to a null value (null).

[0138] In the embodiment of the present application, the parameter of the context information field of the root view context is first modified to a null value; and then the parameter value of the phone window field is modified to a null value. By modifying the parameter values ​​of these fields to null values ​​in sequence, the association between the web page view and the root view context can be cut off, so that the relevant memory resources can be correctly released, ensuring the reasonable use of system memory resources, maintaining the healthy state of the memory, avoiding the problem of excessive memory usage due to long-term operation, and solving the memory leak problem.

[0139] In one implementation, the process of modifying the parameter value of the fourth private field of the root view to a preset value may include:

[0140] Change the parameter value of the key tag field of the root view to an empty value;

[0141] When the parameter value of the key tag field of the root view is null, modify the parameter value of the parent view field of the root view to a null value.

[0142] Exemplarily, the fourth private field of the root view may include a key tag field (mKeyedTags) and a parent view field (mParent).

[0143] In Android's view system, DecorView's mKeyedTags is used to mark and classify DecorView itself or its internal subviews. For example, these tags can be used to distinguish different types of window content. For example, in an Activity that contains multiple Fragments, by adding different key-value pairs to DecorView's mKeyedTags, you can mark which parts are used to display news content, which are button areas for user interaction, etc. In order to remove the tag reference of the root view, first modify the parameter value of mKeyedTags to null.

[0144] After that, the parent view is a higher-level view container or a view object directly related to the window management system. The current web page view may have a reference relationship with the parent view; in order to remove the reference to the parent view in the root view, modify the parameter value of mParent to null.

[0145] In the embodiment of the present application, the parameter value of the key tag field of the root view and the parameter value of the parent view field are modified to null values ​​in turn. The reference relationship between the key tag field and the parent view field in the web page view and the root view is released, so that the relevant memory resources can be released smoothly, ensuring the effective use of memory, maintaining the healthy state of the system memory, and solving the memory leak problem caused by the uncut reference relationship.

[0146] S304, controlling the web page view to exit.

[0147] Exemplarily, after modifying the parameter value of the target private field related to the web page view, the related reference to the WebView held by the Activity can be removed, and then the exit of the web page view can be controlled.

[0148] Optionally, in order to further avoid memory leakage problems after closing the web view, when using the web view, a separate process can be enabled to load the web view page, so that when the web view page is closed and destroyed, the separate process can be directly destroyed; since the separate process has no reference relationship with other parts, the memory leakage problem can be solved.

[0149] In summary, in an embodiment of the present application, after receiving an exit instruction of a web page view, in response to the exit instruction, first remove the subview in the root view to which the web page view belongs; then obtain access rights to the target private field in the class corresponding to the web page view through a reflection mechanism; after obtaining access rights, modify the parameter value of the target private field to a preset value to release the reference relationship between the web page view and other parts; finally, control the exit of the web page view. When a web page view exits, if its related reference relationship is not properly handled, the memory occupied by the view and its associated objects may not be properly recovered, ultimately causing a memory leak. Using a reflection mechanism to release the reference relationship of a web page view can enable the system to promptly recover the memory occupied by related references, thereby ensuring the stability of the overall available memory of the system, solving the memory leak problem that exists after the web page view is closed, and avoiding device performance degradation or even application crashes caused by memory leaks.

[0150] Figure 4 This is a schematic flow chart of another method for controlling a web page view provided in an embodiment of the present application. It should be understood that the method can be applied to an electronic device; or to a processor in an electronic device; or to a chip in a processor of an electronic device.

[0151] For example, Figure 4 As shown, the method 400 includes the following steps S401 to S412.

[0152] S401, in response to an exit instruction of the web page view, removing all subviews in the root view through a view removal function.

[0153] Exemplarily, when an exit operation on a web page view (WebView) is received, the electronic device generates an exit instruction according to the exit operation; in response to the exit instruction, all subviews (View) in the root view (DecorView) are removed using a view removal function (reviewAllViews).

[0154] Optionally, the implementation of S401 can refer to Figure 2 The relevant description of S301 in the present application embodiment is not repeated here.

[0155] S402: Modify the parameter value of the window close callback field of the target window to a null value through a reflection mechanism.

[0156] For example, after the subview is removed, the container that holds the subview needs to be processed. First, the access permission to the window close callback field (mOnWindowDismissedCallback) of the target window (Window) is obtained through the reflection mechanism; after obtaining the permission, the parameter value of mOnWindowDismissedCallback is set to a null value (Null).

[0157] Optionally, the implementation of S402 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0158] S403, modifying the parameter value of the window controller callback field of the target window to a null value through a reflection mechanism.

[0159] Exemplarily, after setting the parameter value of the window close callback field to a null value, access to the window controller callback field (mOnWindowControllerCallback) of the target window is obtained through a reflection mechanism; after obtaining the permission, the parameter value of mOnWindowControllerCallback is set to a null value (Null).

[0160] Optionally, the implementation of S403 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0161] S404: modify the parameter value of the context information field of the target window to a null value through a reflection mechanism.

[0162] Exemplarily, after setting the parameter value of the window controller callback field to a null value, the access permission to the context information field (mContext) of the target window is obtained through the reflection mechanism; after obtaining the permission, the parameter value of mContext is set to a null value (Null).

[0163] Optionally, the implementation of S404 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0164] S405: Modify the parameter value of the root content field of the root view to a null value through a reflection mechanism.

[0165] Exemplarily, after setting the parameter value of the context information field of the target window to a null value, the access permission to the root content field (mContentRoot) of the root view (DecorView) is obtained through the reflection mechanism; after obtaining the permission, the parameter value of mContentRoot is set to a null value (Null).

[0166] Optionally, the implementation of S405 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0167] S406, modifying the parameter value of the window field of the root view to a null value through the reflection mechanism.

[0168] Exemplarily, after setting the parameter value of the root content field of the root view to a null value, the access permission to the window field (mWindow) of the root view is obtained through the reflection mechanism; after obtaining the permission, the parameter value of mWindow is set to a null value (Null).

[0169] Optionally, the implementation of S406 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0170] S407: Configure the parameters of the context field of the root view as global context parameters through the reflection mechanism.

[0171] Exemplarily, after setting the parameter value of the window field of the root view to a null value, access to the context field (mContext) of the root view is obtained through a reflection mechanism; after obtaining the permission, the parameters of mContext are configured as global context parameters (ApplicationContext).

[0172] Optionally, the implementation of S407 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0173] S408, modify the parameter value of the context information field of the root view context to a null value through a reflection mechanism.

[0174] Exemplarily, after configuring the parameters of the context field of the root view as global context parameters, access rights to the context information field (mContext) of the root view context (DecorContext) are obtained through the reflection mechanism; after obtaining the permission, the parameter value of mContext is set to a null value (Null).

[0175] Optionally, the implementation of S408 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0176] S409, modify the parameter value of the phone window field of the root view context to a null value through the reflection mechanism.

[0177] Exemplarily, after setting the parameter value of the context information field of the root view context to a null value, access permission to the phone window field (mPhoneWindow) of the root view context is obtained through a reflection mechanism; after obtaining the permission, the parameter value of mPhoneWindow is set to a null value (Null).

[0178] Optionally, the implementation of S409 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0179] S410: Modify the parameter value of the key tag field of the root view to a null value through a reflection mechanism.

[0180] Exemplarily, after setting the parameter value of the phone window field of the root view context to a null value, access to the key tag field (mKeyedTags) of the root view is obtained through the reflection mechanism; after obtaining the permission, the parameter value of mKeyedTags is set to a null value (Null).

[0181] Optionally, the implementation of S410 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0182] S411, modify the parameter value of the parent view field of the root view to a null value through the reflection mechanism.

[0183] Exemplarily, after setting the parameter value of the key tag field of the root view to a null value, access permission to the parent view field (mParent) of the root view is obtained through a reflection mechanism; after obtaining the permission, the parameter value of mParent is set to a null value (Null).

[0184] Optionally, the implementation of S411 can refer to Figure 2 The relevant description of S302 and S303 in the embodiment of the present application is not repeated here.

[0185] S412, controlling the web page view to exit.

[0186] Exemplarily, after modifying the parameters of the private fields related to the web page view through the reflection mechanism, the reference relationship between the web page view and other modules can be cut off; then, the web page view can be controlled to exit and the display of the web page view can be cancelled.

[0187] Optionally, the implementation of S412 can refer to Figure 2 The relevant description of S304 in the present application embodiment is not repeated here.

[0188] In summary, in an embodiment of the present application, in response to an exit instruction for a web page view, all subviews in the root view are first removed to eliminate the content occupied by the subviews; then, the parameter values ​​of the private fields that reference the web page view are modified in sequence through the reflection mechanism to cut off the reference relationship between the relevant parts and the web page view. After closing the web page view, since there is no reference between the web page view and other parts, the web page view can be completely closed, and the memory occupation of other parts by the web page view can be eliminated, thereby solving the memory leakage problem caused by not completely closing the web view, and thus ensuring the normal operation performance of the device.

[0189] Combination of the above Figures 1 to 4 The control method of the web page view provided by the embodiment of the present application is described in detail; Figure 5 and Figure 6 The device embodiments of the present application are described in detail. It should be understood that the device in the embodiments of the present application can execute the various methods of the aforementioned embodiments of the present application, that is, the specific working processes of the following various products can refer to the corresponding processes in the aforementioned method embodiments.

[0190] Figure 5 It is a structural schematic diagram of a control device for a web page view provided in an embodiment of the present application.

[0191] For example, Figure 5 As shown, the control device 500 includes:

[0192] A removal module 501, configured to remove a subview in a root view to which the webpage view belongs in response to an exit instruction of the webpage view;

[0193] An acquisition module 502 is used to acquire access rights to a target private field in a class corresponding to a web page view through a reflection mechanism;

[0194] The modification module 503 is used to modify the parameter value of the target private field to a preset value to release the reference relationship of the web page view when the access permission is obtained;

[0195] The control module 504 is used to control the exit of the web page view.

[0196] In a possible implementation, the modification module 503 is also used to modify the parameter value of the first private field of the target window to a preset value; when the parameter value of the first private field of the target window is the preset value, the parameter value of the second private field of the root view is modified to the preset value; when the parameter value of the second private field of the root view is the preset value, the parameter value of the third private field of the root view context is modified to the preset value; when the parameter value of the third private field of the root view context is the preset value, the parameter value of the fourth private field of the root view is modified to the preset value; wherein the second private field and the fourth private field are different private fields in the root view.

[0197] In one possible implementation, the modification module 503 is specifically used to modify the parameter value of the window close callback field of the target window to a null value; when the parameter value of the window close callback field of the target window is a null value, the parameter value of the window controller callback field of the target window is modified to a null value; when the parameter value of the window controller callback field of the target window is a null value, the parameter value of the context information field of the target window is modified to a null value.

[0198] In one possible implementation, the modification module 503 is specifically used to modify the parameter value of the root content field of the root view to a null value; when the parameter value of the root content field of the root view is a null value, modify the parameter value of the window field of the root view to a null value; when the parameter value of the window field of the root view is a null value, configure the parameters of the context field of the root view to global context parameters.

[0199] In one possible implementation, the modification module 503 is specifically used to modify the parameter value of the context information field of the root view context to a null value; when the parameter value of the context information field of the root view context is a null value, the parameter value of the phone window field of the root view context is modified to a null value.

[0200] In one possible implementation, the modification module 503 is specifically used to modify the parameter value of the key tag field of the root view to a null value; when the parameter value of the key tag field of the root view is a null value, the parameter value of the parent view field of the root view is modified to a null value.

[0201] In a possible implementation, the removal module 501 is specifically used to obtain a subview in a root view to which the webpage view belongs; and remove the subview in the root view through a view removal function.

[0202] It should be noted that the control device of the web page view is embodied in the form of a functional unit. The term "module" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.

[0203] For example, a "module" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.

[0204] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0205] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0206] For example, Figure 6 As shown, the electronic device 600 includes: a memory 601 and a processor 602, wherein the memory 601 stores an executable program code 603, and the processor 602 is used to call and execute the executable program code 603 to perform a method for controlling a web page view.

[0207] In addition, an embodiment of the present application also protects a device, which may include a memory and a processor, wherein the memory stores an executable program code, and the processor is used to call and execute the executable program code to execute a method for controlling a web page view provided in an embodiment of the present application.

[0208] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0209] In the case of dividing each functional module according to each function, the device may also include a removal module, an acquisition module, a modification module, a control module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.

[0210] It should be understood that the device provided in this embodiment is used to execute the above-mentioned method for controlling a web page view, and thus can achieve the same effect as the above-mentioned implementation method.

[0211] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to an electronic device, the processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device in executing relevant program codes, etc.

[0212] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0213] In addition, the device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the chip may include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a control method for a web page view provided in the above embodiment.

[0214] This embodiment also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a method for controlling a web page view provided in the above embodiment.

[0215] Among them, computer-readable storage media may include but are not limited to any type of disk, including floppy disks, optical disks, digital versatile disks (Digital Video Disc, DVD), compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), microdrives and magneto-optical disks, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable programmable read only memory (Electrically Erasable Programmable read only memory, EEPROM), dynamic random access memory (Dynamic Random Access Memory, DRAM), video random access memory (Video Random Access Memory, VRAM), flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.

[0216] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement a method for controlling a web page view provided in the above embodiment.

[0217] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0218] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0219] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0220] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for controlling a web page view, characterized in that: The method comprises: In response to an exit instruction of the webpage view, removing a subview in a root view to which the webpage view belongs; Obtain access rights to the target private field in the class corresponding to the web page view through a reflection mechanism; When the access right is obtained, the parameter value of the target private field is modified to a preset value to release the reference relationship of the web page view; Controls the web page view to exit.

2. The method according to claim 1, characterized in that The modifying the parameter value of the target private field to a preset value includes: Modify the parameter value of the first private field of the target window to the preset value; When the parameter value of the first private field of the target window is the preset value, modifying the parameter value of the second private field of the root view to the preset value; When the parameter value of the second private field of the root view is the preset value, modifying the parameter value of the third private field of the root view context to the preset value; When the parameter value of the third private field of the root view context is the preset value, modifying the parameter value of the fourth private field of the root view to the preset value; The second private field and the fourth private field are different private fields in the root view.

3. The method according to claim 2, characterized in that The step of modifying the parameter value of the first private field of the target window to the preset value includes: Modify the parameter value of the window close callback field of the target window to a null value; When the parameter value of the window close callback field of the target window is a null value, modifying the parameter value of the window controller callback field of the target window to a null value; When the parameter value of the window controller callback field of the target window is a null value, the parameter value of the context information field of the target window is modified to a null value.

4. The method according to claim 2, characterized in that: The modifying the parameter value of the second private field of the root view to the preset value includes: Modify the parameter value of the root content field of the root view to a null value; When the parameter value of the root content field of the root view is a null value, modifying the parameter value of the window field of the root view to a null value; When the parameter value of the window field of the root view is a null value, the parameter of the context field of the root view is configured as a global context parameter.

5. The method according to claim 2, characterized in that: The modifying the parameter value of the third private field of the root view context to the preset value includes: Modify the parameter value of the context information field of the root view context to a null value; When the parameter value of the context information field of the root view context is a null value, the parameter value of the phone window field of the root view context is modified to a null value.

6. The method according to claim 2, characterized in that The modifying the parameter value of the fourth private field of the root view to the preset value includes: Modify the parameter value of the key tag field of the root view to a null value; When the parameter value of the key tag field of the root view is a null value, the parameter value of the parent view field of the root view is modified to a null value.

7. The method according to any one of claims 1 to 6, characterized in that: The removing of the subview in the root view to which the webpage view belongs includes: Get the subview in the root view to which the webpage view belongs; The subview in the root view is removed by a view removal function.

8. A control device for a web page view, characterized in that: The device comprises: A removal module, configured to remove a subview in a root view to which the webpage view belongs in response to an exit instruction of the webpage view; An acquisition module, used to obtain access rights to a target private field in a class corresponding to the web page view through a reflection mechanism; A modification module, configured to modify the parameter value of the target private field to a preset value to release the reference relationship of the web page view when the access permission is obtained; A control module is used to control the exit of the web page view.

9. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.