Page exception processing method and device, equipment and storage medium

By listening to the loading events and network status of the WebView, displaying the page to close the control or refresh the control, it solves the problem that the interface area cannot be exited or reloaded when the WebView loads abnormally, and improves loading efficiency and user experience.

CN119088467APending Publication Date: 2024-12-06安徽三七极光网络科技有限公司
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410937749.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

When a WebView encounters network problems or page code errors when loading a H5 page in WebView, it is difficult for users to find functional controls such as closing the page, resulting in the interface area being in a white screen state, unable to exit or reload, affecting the user experience.

Method used

By obtaining the unified resource locator of the target page, listening to the loading event of the WebView, obtaining the amount of resource data, determining the loading time threshold based on network status and device performance, displaying the page closing control and/or page refresh control when loading fails or timeout.

Benefits of technology

It solves the problem that the interface area cannot be exited or reloaded when the WebView loads abnormally, improves page loading efficiency and flexibility, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088467A_ABST
    Figure CN119088467A_ABST
Patent Text Reader

Abstract

The invention discloses a page exception processing method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps that a uniform resource locator of a target page is acquired, the target page is loaded through WebView and the uniform resource locator, and all loading events of the WebView in the loading process are monitored; under the condition that the WebView processes a network request event in each loading event, obtaining a resource data volume of a target page through the network request event, and determining a loading duration threshold according to a network state, equipment performance and the resource data volume; and displaying a page closing control and / or a page refreshing control at a preset position of the application interface under the condition that loading of the loading event fails or loading completion of each loading event is not monitored when a loading duration threshold value is exceeded, so that the problem that an interface area cannot exit or be reloaded when the WebView is loaded abnormally in the prior art is solved. And the user experience is ensured.
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 in particular to a page exception processing method, device, equipment and storage medium. Background Art

[0002] WebView is a control or component that embeds web content in mobile applications (such as Android and iOS applications). It can display web pages directly in the application interface without users having to leave the application and open an external browser to view the web pages. Since WebView can seamlessly integrate web content into mobile applications, it is widely used in various mobile applications, such as news reading applications, e-commerce applications, and game applications.

[0003] In the prior art, WebView loads an H5 page to display all or part of the content of the page, thereby providing users with an experience similar to browsing the web. In order to display the page content more flexibly, the mobile application will completely hand over the entire interface area to WebView for control, so that functional controls such as closing the page will be randomly placed at any position on the page. When WebView encounters abnormal problems such as network problems and page code errors when loading an H5 page and a white screen occurs, it is difficult for users to find functional controls such as closing the page, resulting in the interface area being in a white screen state and unable to exit or reload, thereby reducing the efficiency of WebView loading pages and affecting the user experience. Summary of the invention

[0004] The present application provides a page exception processing method, apparatus, device and storage medium, so as to display a page close control and / or a page refresh control in an application interface when a failure in loading a page by WebView is detected, thereby solving the problem in the prior art that an interface area of ​​WebView cannot be exited or reloaded when a loading exception occurs, improving the efficiency and flexibility of loading pages by WebView and ensuring the user experience.

[0005] In a first aspect, the present application provides a page exception handling method, comprising:

[0006] Obtaining the uniform resource locator of the target page, loading the target page through WebView and the uniform resource locator, and monitoring each loading event of the WebView during the loading process;

[0007] When the WebView processes a network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and a loading time threshold is determined according to the network status, device performance and the resource data volume;

[0008] When it is detected that the loading event fails to load or the loading time threshold is exceeded but the loading of each loading event is not completed, a page close control and / or a page refresh control is displayed at a preset position of the application interface.

[0009] In a second aspect, the present application provides a page exception processing device, comprising:

[0010] A page loading module is configured to obtain a uniform resource locator of a target page, load the target page through WebView and the uniform resource locator, and monitor various loading events of the WebView during the loading process;

[0011] A loading duration determination module is configured to obtain the resource data volume of the target page through the network request event when the WebView processes the network request event in each loading event, and determine the loading duration threshold according to the network status, device performance and the resource data volume;

[0012] The loading exception handling module is configured to display a page close control and / or a page refresh control at a preset position of the application interface when it is detected that the loading event fails to load or the loading time threshold is exceeded and the loading of each loading event is not detected to be completed.

[0013] In a third aspect, the present application provides a page exception processing device, including:

[0014] one or more processors;

[0015] The memory stores one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the page exception handling method as described in the first aspect.

[0016] In a fourth aspect, the present application provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the page exception handling method as described in the first aspect.

[0017] In the present application, the uniform resource locator of the target page is obtained, the target page is loaded through WebView and the uniform resource locator, and various loading events of WebView during the loading process are monitored; when WebView processes a network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and the loading duration threshold is determined according to the network status, device performance and resource data volume; when it is monitored that the loading event fails to load or the loading duration threshold is exceeded without monitoring the loading completion of each loading event, a page close control and / or a page refresh control is displayed at a preset position on the application interface. Through the above-mentioned technical means, it is possible to determine whether the page is loaded successfully by monitoring the loading event of WebView, and set the loading time threshold according to the network status, device performance and resource data volume. According to the loading time threshold, it is determined whether the page loading time is too long. When the page loading fails or the page loading time is too long, it is determined that an abnormality has occurred in the page loading process, and then the page closing control and / or page refresh control are displayed in the application interface, so that the user can close the page or refresh the page of the application interface through the page closing control or page refresh control, which solves the problem in the prior art that the interface area of ​​WebView cannot be exited or reloaded when the loading is abnormal, improves the efficiency and flexibility of WebView loading pages, and ensures the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a flow chart of a page exception handling method provided by an embodiment of the present application;

[0019] Figure 2 It is a flow chart of obtaining the resource data amount of a target page through a network request event provided by an embodiment of the present application;

[0020] Figure 3 This is a flow chart of determining a target page loading time threshold provided by an embodiment of the present application;

[0021] Figure 4 It is a flowchart of detecting whether the display of a target page is abnormal based on page elements provided by an embodiment of the present application;

[0022] Figure 5 is a flowchart of detecting whether the display of a target page is abnormal based on a first image of an application interface provided by an embodiment of the present application;

[0023] Figure 6 It is a structural schematic diagram of a page exception processing device provided in an embodiment of the present application;

[0024] Figure 7 It is a structural diagram of a page exception processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.

[0026] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0027] In the more common existing implementation methods, mobile applications load H5 pages through integrated WebView controls to display all or part of the content of the H5 page in the application interface of the mobile application, thereby providing users with an experience similar to browsing the web using a browser. In order to display the page content more flexibly, the mobile application will completely hand over the entire interface area of ​​the application interface to WebView for control, so that functional controls such as closing the page and refreshing the page will be randomly placed in any position on the page. When WebView encounters abnormal problems such as network problems and page code errors when loading the H5 page and a white screen occurs, it is difficult for users to find functional controls such as closing the page and refreshing the page, resulting in the interface area being in a white screen state and unable to exit or reload, thereby reducing the efficiency of WebView loading pages and affecting the user experience.

[0028] To solve the above problems, this embodiment provides a page exception handling method to display a page close control and / or a page refresh control in the application interface when it is detected that the WebView fails to load the page, thereby improving the efficiency and flexibility of the WebView loading page and ensuring the user experience.

[0029] The page exception handling method provided in this embodiment may be executed by a page exception handling device, which may be implemented by software and / or hardware, and may be composed of two or more physical entities or one physical entity. For example, the page exception handling device may be a computer or a processor of a computer.

[0030] The page exception handling device is installed with at least one type of operating system, wherein the operating system includes but is not limited to Android system, Linux system and Windows system. The page exception handling device can install at least one application based on the operating system, and the application can be an application that comes with the operating system, or an application downloaded from a third-party device or server. In this embodiment, the page exception handling device has at least an application that can execute the page exception handling method. The application that executes the page exception handling method can be a mobile application integrated with WebView.

[0031] For ease of understanding, this embodiment is described by taking a mobile application as an example of a subject that executes the page exception handling method.

[0032] Figure 1 A flow chart of a page exception handling method provided by an embodiment of the present application is given. Figure 1 , the page exception handling method specifically includes:

[0033] S110, obtaining the uniform resource locator of the target page, loading the target page through WebView and the uniform resource locator, and monitoring various loading events of WebView during the loading process.

[0034] Among them, the target page is the H5 page to be loaded, and the uniform resource locator (URL) is the web address of the target page. This embodiment is described by taking the mobile application as a game application as an example. When the user clicks the link of the active page in the game application, the game application determines the active page as the target page to be loaded according to the click operation, calls the URL transmission interface to pass the URL of the active page as a parameter to WebView, and WebView loads the active page based on the received URL. After the active page is successfully loaded, WebView can render the web page content corresponding to the active page and display it in the application interface of the game application.

[0035] After obtaining the URL transmitted by the game application, WebView can search for the resource corresponding to the URL in the local cache. After finding the resource corresponding to the URL, it can load and display the target page corresponding to the URL based on the resource corresponding to the URL in the cache, thereby improving the page loading speed. If the resource corresponding to the URL is not found, WebView initiates a request to the domain name system server to request to resolve the IP address corresponding to the domain name in the URL. WebView establishes a communication connection with the corresponding server based on the IP address. After establishing a communication connection with the server, it sends an HTTP request to the server. The server sends an HTTP response to WebView based on the HTTP request. WebView loads and displays the target page corresponding to the URL based on the resources in the HTTP response.

[0036] In this embodiment, the loading process of WebView is: obtaining the resource corresponding to the URL, and loading and displaying the target page corresponding to the URL according to the obtained resource. During the loading process of WebView, WebView can process multiple loading events, monitor the processing status of each loading event, and determine that an abnormality has occurred in the loading process when any loading event fails to load, and determine that no abnormality has occurred in the loading process when all loading events are successfully loaded.

[0037] S120. When WebView processes a network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and a loading time threshold is determined according to the network status, device performance, and resource data volume.

[0038] Among them, the loading time threshold is the maximum time required for WebView to load the target page set in this embodiment. When the time for WebView to load the target page exceeds the loading time threshold, it indicates that an abnormality has occurred in the loading process of WebView. This embodiment aims to accurately estimate the loading time threshold of WebView based on the amount of resource data of the target page, the network status and device performance of the terminal device corresponding to the mobile application.

[0039] The network request event is an event in which the WebView sends a network request (HTTP request) to the server corresponding to the domain name in the URL and receives a request response returned by the server. The request response carries the resources of the target page, and the resource data volume of the target page can be determined based on the resources of the target page carried in the request response. For example, Figure 2 1 is a flow chart of obtaining the resource data volume of a target page through a network request event provided by an embodiment of the present application. Figure 2 As shown, the step of obtaining the resource data volume of the target page through the network request event specifically includes S1201-S1202:

[0040] S1201. Monitor the usage of the application interface corresponding to each loading event through the first monitoring function injected by WebView, and determine the loading event processed by WebView according to the usage of the application interface; wherein the first monitoring function is written in JavaScript code.

[0041] Exemplarily, the first monitoring function monitors the usage of the application interface corresponding to each loading event. When monitoring that WebView calls the application interface of a loading event, it can be determined that WebView is processing the loading event corresponding to the application interface.

[0042] S1202: When WebView processes a network request event in each loading event, intercept a request response corresponding to the network request event, and extract resource data volume of the target page from the request response.

[0043] Exemplarily, when processing a network request event, WebView will call a request sending interface to send the network request to the server corresponding to the domain name in the URL. Therefore, when the first monitoring function listens to WebView using the request sending interface, it can be determined that WebView is processing a network request event. When WebView processes a network request event, it intercepts the request response sent by the server to WebView, and determines the amount of resource data of the target page based on the resources of the target page in the request response. In order to ensure that WebView handles the request response normally, the response request is passed to WebView after the amount of resource data is obtained. This embodiment listens to the loading event that WebView is processing through the first monitoring function, so as to intercept the response request sent by the server corresponding to the domain name in the URL when listening to WebView processing a network request event, and accurately obtains the amount of resource data of the target page based on the response request, without affecting the loading process of WebView.

[0044] After obtaining the resource data volume of the target page, the network status and device performance of the corresponding terminal device are obtained, and the resource data volume, network status and device performance can be input into a pre-trained deep learning model to predict the target page loading time threshold. The deep learning model is trained based on the resource data volume, network status, device performance and loading time of various pages loaded by WebView in history.

[0045] In another embodiment, a clustering algorithm can be used to analyze multiple historical loading data of WebView, and the target page loading time threshold can be determined based on the analysis results, the amount of resource data of the target page, the network status, and the device performance. Figure 3 1 is a flow chart of determining a target page loading time threshold provided by an embodiment of the present application. Figure 3As shown, the step of determining the loading time threshold of the target page specifically includes S1203-S1206:

[0046] S1203. Obtain multiple historical loading data of WebView, each historical loading data includes historical resource data volume, historical network status, historical device performance, and historical loading duration.

[0047] Exemplarily, multiple historical loading data of WebView are obtained in a preset database, and historical loading data with too short loading time and too long loading time are removed according to the historical loading time in each historical loading data. Among them, too short loading time indicates that the corresponding loaded page is a cached page, and too long loading time indicates that the corresponding loaded page has an abnormality during the loading process. Therefore, after removing the invalid or abnormal historical loading data with too short loading time and too long loading time, retaining the remaining normal historical loading data is conducive to improving the estimation accuracy of the loading time threshold.

[0048] S1204: Cluster each historical loading data according to the historical resource data volume, historical network status, and historical device performance of each historical loading data to obtain multiple historical loading data sets.

[0049] Exemplarily, the similarity between the remaining historical loading data is determined by clustering algorithm and the historical resource data volume, historical network status and historical device performance of the remaining historical loading data. The remaining historical loading data are divided into multiple historical loading data sets according to the similarity between the remaining historical loading data.

[0050] S1205: Determine the average value of the historical loading durations of the historical loading data in the historical loading data set as the historical loading duration corresponding to the historical loading data set.

[0051] Exemplarily, the historical loading duration of each historical loading data in the historical loading data set is obtained, an average value of the obtained historical loading durations is calculated, and the average value is determined as the historical loading duration corresponding to the historical loading data set.

[0052] S1206: Determine a corresponding matching historical loading data set according to the network status, device performance, and resource data volume, and determine the historical loading duration corresponding to the historical loading data set as a loading duration threshold.

[0053] Exemplarily, the resource data volume characteristics, network status characteristics and device performance characteristics of the historical loading data set are determined based on the historical resource data volume, historical network status and historical device performance of each historical loading data in the historical loading data set. The network status and device performance of the terminal device at the current moment and the resource data volume of the target page are determined as the loading data of the target page, and the distance between the loading data of the target page and the data characteristics of each historical loading data set is determined based on the loading data of the target page and the resource data volume characteristics, network status characteristics and device performance characteristics of each historical loading data set. The historical loading data set with the smallest distance is determined as the historical loading data set that matches the loading data of the target page, and the historical loading duration of the historical loading data set is determined as the loading duration threshold of the target page.

[0054] This embodiment performs cluster analysis on multiple historical loading data of WebView, divides the multiple historical loading data into multiple historical loading data sets, determines a historical loading data set that is similar to the loading data of the target page according to the data characteristics of each historical loading data set, and then determines the historical loading time of the historical loading data set as the loading time threshold of the target page, thereby achieving accurate estimation of the loading time threshold.

[0055] S130: When a loading event fails to load or a loading time threshold is exceeded but no loading event is completed, a page close control and / or a page refresh control is displayed at a preset position on the application interface.

[0056] For example, when any loading event fails to load, it can be determined that an abnormality occurs in the process of WebView loading the page, and then a function bar pops up at the bottom of the application interface, and a page close control and / or a page refresh control are displayed in the function bar. Among them, the page close control is used to trigger the operation of closing the page in the application interface, and the page refresh control is used to trigger the operation of filtering the pages in the application interface.

[0057] In this embodiment, when a load event fails to be monitored, the error capture callback method of WebView can be called to obtain the first failure type of the load event; a corresponding recovery operation prompt is generated according to the first failure type, and the first failure type and the corresponding recovery operation prompt are displayed in the application interface. Exemplarily, when the game application monitors the message that the load event fails to load, the error capture callback method of WebView is called to obtain the error code and error description of the load event, the first failure type of the load event is determined according to the error code and the error description, the corresponding recovery operation prompt is generated according to the first failure type, and the first failure type and the corresponding recovery operation prompt are displayed above the function bar. For example, when the first failure type is a network problem, the corresponding recovery operation prompt is to prompt the user to check the network connection of the terminal device, and when the first failure type is a server problem, the corresponding recovery operation prompt is to prompt the user to reconnect to the server later. In this embodiment, when the message of the load event failure is monitored, the error capture callback method is called to obtain the first failure type of the load event and generate the corresponding recovery operation prompt, and the first failure type and the corresponding recovery operation prompt are displayed in the application interface, so as to provide users with useful feedback and solutions and improve the user experience.

[0058] Similarly, when the loading time threshold is exceeded and no message indicating that each loading event is completed is heard, it can be determined that an abnormality has occurred in the process of WebView loading the page, and a function bar pops up at the bottom of the application interface, displaying a page close control and / or a page refresh control in the function bar.

[0059] In this embodiment, when the loading time threshold is exceeded and the loading completion of each loading event is not monitored, an abnormality detection is performed based on the network connection status, the server status pointed to by the uniform resource locator, the page content of the target page, and the running performance of WebView to determine the second failure type of the loading process; a corresponding recovery operation prompt is generated according to the second failure type, and the second failure type and the corresponding recovery operation prompt are displayed in the application interface. Exemplarily, there are four reasons for the general page loading timeout, namely network problems, server problems, content problems, and loading engine problems. For this, the game application can perform an abnormality detection based on the network connection status of the terminal device, the server status pointed to by the domain name in the URL, the page content of the target page, and the running performance of WebView to determine the second failure type of the loading event. If it is detected that the network of the terminal device is not connected to the Internet or the network connection is slow, the second failure type is determined to be a network problem; if it is detected that the server does not respond or responds slowly, the second failure type is determined to be a server problem; if it is detected that the page content contains a large number of resources or some resources are loaded slowly, the second failure type is determined to be a content problem; if it is detected that the running performance of WebView has abnormal data, such as excessive memory usage, etc., the second failure type is determined to be a loading engine problem. After determining the second failure type of the loading process, a corresponding recovery operation prompt is generated according to the second failure type, and the second failure type and the corresponding recovery operation prompt are displayed above the function bar. This embodiment performs multi-faceted abnormality detection on the network, server, page content, and loading engine when the message that all loading events have been loaded is not monitored within the loading time threshold, determines the second failure type of the loading process and generates a corresponding recovery operation prompt, displays the second failure type and the corresponding recovery operation prompt in the application interface, provides users with useful feedback and solutions, and improves the user experience.

[0060] If the game application listens to the message that each loading event is loaded within the loading time threshold, it is determined that there is no abnormality in the WebView loading process, and then the page close control and / or page refresh control are not displayed in the application interface to ensure the visual effect of displaying the target page in the application interface.

[0061] It should be noted that there is a situation that after WebView successfully loads the target page, the target page displayed on the application interface is missing part of the page content due to rendering or other problems, that is, the display of the target page is abnormal. In order to further optimize the user experience, after WebView successfully loads the target page, it can be detected whether the target page displayed in the application interface is normal. In the case of abnormal problems with the displayed target page, a page close control and / or page refresh control is displayed in the application interface so that the user can close or refresh the page in the application interface through the page close control or page refresh control.

[0062] In this embodiment, it is possible to detect whether the display of the target page is abnormal based on the page elements displayed on the application interface. Figure 4 1 is a flow chart of detecting whether the display of a target page is abnormal based on page elements provided by an embodiment of the present application. Figure 4 As shown, the step of detecting whether the display of the target page is abnormal based on the page elements specifically includes S1401-S1403:

[0063] S1401. When the loading of each loading event is monitored to be completed within the loading time threshold, the second monitoring function injected by WebView is used to detect whether each element in the target page exists in the application interface; wherein the second monitoring function is written in JavaScript code.

[0064] Exemplarily, when the completion of each loading event is monitored within the loading time threshold, WebView has rendered the loaded target page in the application interface. At this time, it can be detected whether the display of the target page is abnormal based on the page displayed in the application interface.

[0065] The second monitoring function determines each element in the target page based on the resources of the target page, detects the page displayed by the application interface according to each element in the target page, and determines whether each element in the target page exists in the page displayed by the application interface.

[0066] S1402: When an element in the target page exists in the application interface, detect through a second monitoring function whether the attributes of the element displayed in the application interface match the attributes of the corresponding element in the target page.

[0067] Exemplarily, when each element in the target page exists in the page displayed on the application interface, the second monitoring function is used to detect whether the element attributes in the page displayed on the application interface are the same as the corresponding element attributes in the target page, such as determining whether the text content of the text elements is the same.

[0068] S1403: When the element does not exist in the application interface or the attribute of the element does not match, display a page close control and / or a page refresh control at a preset position of the application interface.

[0069] Exemplarily, when at least one element in the target page does not exist in the page displayed in the application interface, or when at least one element attribute in the target page is different from the corresponding element attribute in the page displayed in the application interface, it can be determined that the display of the target page is abnormal, and then a function bar is popped up below the application interface, and a page close control and / or a page refresh control are displayed in the function bar, so that the user can close or refresh the page in the application interface in time through the page close control or the page refresh control, thereby improving the user's experience. When the attributes of each element in the target page are the same as the corresponding element attributes in the page displayed in the application interface, it can be determined that the display of the target page is normal, and the function bar is not popped up below the application interface to ensure the visual effect of the page displayed in the application interface. In this embodiment, the second monitoring function injected by WebView detects whether the display of the target page rendered by WebView in the application interface is abnormal, thereby realizing accurate detection of abnormal display of the target page. When the display of the target page is abnormal, a page close control and / or a page refresh control are displayed in the application interface to avoid the application interface being in an abnormal display state and unable to exit or reload, thereby improving the efficiency and flexibility of WebView loading pages and ensuring the user's experience.

[0070] In this embodiment, it is also possible to detect whether the display of the target page is abnormal based on the first image of the application interface. Figure 5 1 is a flowchart of detecting whether the display of a target page is abnormal based on the first image of the application interface provided by an embodiment of the present application. Figure 5 As shown, the step of detecting whether the display of the target page is abnormal based on the first image of the application interface specifically includes S1404-S1406:

[0071] S1404: When it is monitored that each loading event is loaded within the loading time threshold, capture a first image of the application interface.

[0072] Exemplarily, when the completion of each loading event is monitored within the loading time threshold, WebView has rendered the loaded target page in the application interface. At this time, it can be detected whether the display of the target page is abnormal based on the page displayed in the application interface.

[0073] The application interface is screenshoted to obtain a first image of the application interface, the first image includes page content displayed on the application interface, and whether the display of the target page is abnormal can be determined based on the page content in the first image.

[0074] S1405 . Rendering in a canvas element according to the document structure model of the target page, converting the canvas element into a second image.

[0075] Exemplarily, a document structure model (DOM) of the target page is obtained by obtaining the WebView, rendering the document structure model onto a canvas element (Canvas element), and converting the canvas element into an image format to obtain a second image. Since the second image is rendered based on the document structure model of the target page, the second image includes the page content of the target page.

[0076] S1406: When the matching degree between the first image and the second image is less than a preset matching degree threshold, display a page close control and / or a page refresh control at a preset position of the application interface.

[0077] Exemplarily, feature points of the first image and feature points of the second image are extracted, and the feature points of the first image are matched with the feature points of the second image to determine the matching degree between the first image and the second image. When the matching degree is greater than or equal to the preset matching degree threshold, it is determined that the page content in the first image is substantially the same as the page content in the second image, that is, the page displayed in the application interface is substantially the same as the target page, and then it is determined that the display of the target page is normal. When the matching degree is less than the preset matching degree threshold, it is determined that the page content in the first image is different from the page content in the second image, that is, the page displayed in the application interface is different from the target page, and then it is determined that the display of the target page is abnormal. When the display of the target page is abnormal, a function bar pops up below the application interface, and a page close control and / or a page refresh control are displayed in the function bar, so that the user can close or refresh the page in the application interface in time through the page close control or the page refresh control, thereby improving the user's experience. When the display of the target page is normal, the function bar does not pop up below the application interface to ensure the visual effect of the page displayed in the application interface. This embodiment determines whether the page displayed in the application interface is the same as the target page by comparing the actual screenshot of the application interface and the image generated by rendering the document structure model of the target page on the canvas, thereby determining whether the display of the target page rendered by WebView in the application interface is abnormal, and accurately detecting the abnormal display of the target page. When the display of the target page is abnormal, a page close control and / or a page refresh control are displayed in the application interface to avoid the application interface being in an abnormal display state and unable to exit or reload, thereby improving the efficiency and flexibility of WebView loading pages and ensuring the user experience.

[0078] In summary, the page exception handling method provided in the embodiment of the present application obtains the uniform resource locator of the target page, loads the target page through WebView and the uniform resource locator, and monitors various loading events of WebView during the loading process; when WebView processes the network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and the loading time threshold is determined according to the network status, device performance and resource data volume; when it is monitored that the loading event fails to load or the loading time threshold is exceeded and the loading completion of each loading event is not monitored, a page close control and / or a page refresh control is displayed at a preset position of the application interface. Through the above-mentioned technical means, it is possible to determine whether the page is loaded successfully by monitoring the loading event of WebView, and set the loading time threshold according to the network status, device performance and resource data volume. According to the loading time threshold, it is determined whether the page loading time is too long. When the page loading fails or the page loading time is too long, it is determined that an abnormality has occurred in the page loading process, and then the page closing control and / or page refresh control are displayed in the application interface, so that the user can close the page or refresh the page of the application interface through the page closing control or page refresh control, which solves the problem in the prior art that the interface area of ​​WebView cannot be exited or reloaded when the loading is abnormal, improves the efficiency and flexibility of WebView loading pages, and ensures the user experience.

[0079] Based on the above embodiments, Figure 6 A schematic diagram of the structure of a page exception handling device provided in an embodiment of the present application. Figure 6 The page exception handling device provided in this embodiment specifically includes: a page loading module 21, a loading time determination module 22 and a loading exception handling module 23.

[0080] The page loading module 21 is configured to obtain the uniform resource locator of the target page, load the target page through the WebView and the uniform resource locator, and monitor various loading events of the WebView during the loading process;

[0081] The loading time determination module 22 is configured to obtain the resource data volume of the target page through the network request event when the WebView processes the network request event in each loading event, and determine the loading time threshold according to the network status, device performance and resource data volume;

[0082] The loading exception handling module 23 is configured to display a page close control and / or a page refresh control at a preset position of the application interface when a loading event fails to load or the loading time threshold is exceeded without listening to the completion of each loading event.

[0083] Based on the above embodiment, the loading duration determination module 22 includes: a processing time determination unit, which is configured to be a first monitoring function injected through WebView, monitors the usage of the application interface corresponding to each loading event, and determines the loading event processed by WebView according to the usage of the application interface; wherein the first monitoring function is written in JavaScript code; a resource data volume acquisition unit, which is configured to intercept the request response corresponding to the network request event when WebView processes the network request event in each loading event, and extract the resource data volume of the target page in the request response.

[0084] On the basis of the above embodiment, the loading time determination module 22 includes: a historical data acquisition unit, configured to acquire multiple historical loading data of WebView, each historical loading data includes historical resource data volume, historical network status, historical device performance and historical loading time; a data clustering unit, configured to cluster each historical loading data according to the historical resource data volume, historical network status and historical device performance of each historical loading data to obtain multiple historical loading data sets; a set time determination unit, configured to determine the average value of the historical loading time of each historical loading data in the historical loading data set as the historical loading time corresponding to the historical loading data set; the loading time determination unit, configured to determine the corresponding matching historical loading data set according to the network status, device performance and resource data volume, and determine the historical loading time corresponding to the historical loading data set as the loading time threshold.

[0085] Based on the above embodiment, the loading exception handling module 23 includes: a first failure type determination unit, which is configured to display a page close control and / or a page refresh control at a preset position of the application interface, and then, when a loading event failure is detected, call the WebView's error capture callback method to obtain the first failure type of the loading event; a first prompt display unit, which is configured to generate a corresponding recovery operation prompt according to the first failure type, and display the first failure type and the corresponding recovery operation prompt in the application interface.

[0086] On the basis of the above embodiment, the loading exception handling module 23 includes: a second failure type determination unit, which is configured to, after displaying a page close control and / or a page refresh control at a preset position of the application interface, perform an exception detection based on the network connection status, the server status pointed to by the uniform resource locator, the page content of the target page, and the running performance of the WebView when the loading time threshold is exceeded and the loading completion of each loading event is not monitored, to determine the second failure type of the loading process; a second prompt display unit, which is configured to generate a corresponding recovery operation prompt according to the second failure type, and display the second failure type and the corresponding recovery operation prompt in the application interface.

[0087] On the basis of the above embodiments, the page exception handling device includes a display exception handling module, which includes: a display element detection unit, which is configured to determine the loading time threshold according to the network status, device performance and resource data volume, and when it monitors the completion of each loading event within the loading time threshold, detect whether each element in the target page exists in the application interface through a second monitoring function injected by WebView; wherein the second monitoring function is written in JavaScript code; an element attribute detection unit, which is configured to detect that the attributes of the elements displayed in the application interface match the attributes of the corresponding elements in the target page through the second monitoring function when the elements in the target page exist in the application interface; a first display exception handling unit, which is configured to display a page close control and / or a page refresh control at a preset position of the application interface when the element does not exist in the application interface or the attributes of the element do not match.

[0088] On the basis of the above embodiment, the display exception handling module also includes: a first image acquisition unit, configured to capture a first image of the application interface after determining the loading time threshold according to the network status, device performance and resource data volume, and when monitoring the completion of each loading event within the loading time threshold; a second image acquisition unit, configured to render in a canvas element according to the document structure model of the target page, and convert the canvas element into a second image; a second display exception handling unit, configured to display a page close control and / or a page refresh control at a preset position of the application interface when the matching degree between the first image and the second image is less than a preset matching degree threshold.

[0089] As described above, the page exception handling device provided in the embodiment of the present application obtains the uniform resource locator of the target page, loads the target page through WebView and the uniform resource locator, and monitors various loading events of WebView during the loading process; when WebView processes the network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and the loading time threshold is determined according to the network status, device performance and resource data volume; when it is monitored that the loading event fails to load or the loading time threshold is exceeded and the loading completion of each loading event is not monitored, a page close control and / or a page refresh control is displayed at a preset position of the application interface. Through the above-mentioned technical means, it is possible to determine whether the page is loaded successfully by monitoring the loading event of WebView, and set the loading time threshold according to the network status, device performance and resource data volume. According to the loading time threshold, it is determined whether the page loading time is too long. When the page loading fails or the page loading time is too long, it is determined that an abnormality has occurred in the page loading process, and then the page closing control and / or page refresh control are displayed in the application interface, so that the user can close the page or refresh the page of the application interface through the page closing control or page refresh control, which solves the problem in the prior art that the interface area of ​​WebView cannot be exited or reloaded when the loading is abnormal, improves the efficiency and flexibility of WebView loading pages, and ensures the user experience.

[0090] The page exception handling device provided in the embodiment of the present application can be used to execute the page exception handling method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0091] Figure 7 is a schematic diagram of a page exception processing device provided in an embodiment of the present application, with reference to Figure 7 The page exception handling device includes: a processor 31, a memory 32, a communication device 33, an input device 34 and an output device 35. The number of processors 31 in the page exception handling device can be one or more, and the number of memories 32 in the page exception handling device can be one or more. The processor 31, memory 32, communication device 33, input device 34 and output device 35 of the page exception handling device can be connected through a bus or other means.

[0092] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the page exception handling method of any embodiment of the present application (for example, the page loading module 21, the loading duration determination module 22 and the loading exception handling module 23 in the page exception handling device). The memory 32 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to the use of the device, etc. In addition, the memory 32 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0093] The communication device 33 is used for data transmission.

[0094] The processor 31 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 32, that is, implements the above-mentioned page exception processing method.

[0095] The input device 34 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 35 may include a display device such as a display screen.

[0096] The page exception handling device provided above can be used to execute the page exception handling method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0097] An embodiment of the present application also provides a storage medium containing computer executable instructions, which are used to execute a page exception handling method when executed by a computer processor. The page exception handling method includes: obtaining a uniform resource locator of a target page, loading the target page through WebView and the uniform resource locator, and monitoring various loading events of WebView during the loading process; when WebView processes a network request event in each loading event, obtaining the amount of resource data of the target page through the network request event, and determining a loading time threshold according to the network status, device performance and the amount of resource data; when a loading event fails to load or exceeds the loading time threshold without listening to the completion of each loading event, displaying a page close control and / or a page refresh control at a preset position of the application interface.

[0098] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.

[0099] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application is not limited to the above page exception handling method, and the computer executable instructions can also execute related operations in the page exception handling method provided in any embodiment of the present application.

[0100] The page exception handling device, storage medium and page exception handling equipment provided in the above embodiments can execute the page exception handling method provided in any embodiment of the present application. For technical details not described in detail in the above embodiments, please refer to the page exception handling method provided in any embodiment of the present application.

[0101] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the protection scope of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.

Claims

1. A page exception processing method, characterized in that: include: Obtaining the uniform resource locator of the target page, loading the target page through WebView and the uniform resource locator, and monitoring each loading event of the WebView during the loading process; When the WebView processes a network request event in each loading event, the resource data volume of the target page is obtained through the network request event, and a loading time threshold is determined according to the network status, device performance and the resource data volume; When it is detected that the loading event fails to load or the loading time threshold is exceeded but the loading of each loading event is not completed, a page close control and / or a page refresh control is displayed at a preset position of the application interface.

2. The page exception handling method according to claim 1, characterized in that: When the WebView processes a network request event in each loading event, obtaining the resource data amount of the target page through the network request event includes: The first monitoring function injected by the WebView monitors the usage of the application interface corresponding to each loading event, and determines the loading event processed by the WebView according to the usage of the application interface; wherein the first monitoring function is written in JavaScript code; In the case where the WebView processes a network request event in each loading event, a request response corresponding to the network request event is intercepted, and the resource data volume of the target page is extracted from the request response.

3. The page exception handling method according to claim 1, characterized in that: Determining the loading duration threshold according to the network status, device performance and the resource data volume includes: Acquire multiple historical loading data of the WebView, each of which includes historical resource data volume, historical network status, historical device performance, and historical loading duration; Clustering each of the historical loading data to obtain a plurality of historical loading data sets according to the historical resource data volume, historical network status, and historical device performance of each of the historical loading data; Determine the average value of the historical loading durations of the historical loading data in the historical loading data set as the historical loading duration corresponding to the historical loading data set; A corresponding matching historical loading data set is determined according to the network status, the device performance and the resource data volume, and a historical loading duration corresponding to the historical loading data set is determined as a loading duration threshold.

4. The page exception handling method according to claim 1, characterized in that: After displaying the page close control and / or the page refresh control at the preset position of the application interface, the method further includes: In the case of monitoring the failure of the loading event, calling the error capture callback method of the WebView to obtain the first failure type of the loading event; A corresponding recovery operation prompt is generated according to the first failure type, and the first failure type and the corresponding recovery operation prompt are displayed in the application interface.

5. The page exception handling method according to claim 1, characterized in that: After displaying the page close control and / or the page refresh control at the preset position of the application interface, the method further includes: In the case that the loading completion of each loading event is not monitored after the loading time threshold is exceeded, anomaly detection is performed based on the network connection status, the server status pointed to by the uniform resource locator, the page content of the target page, and the running performance of the WebView to determine the second failure type of the loading process; A corresponding recovery operation prompt is generated according to the second failure type, and the second failure type and the corresponding recovery operation prompt are displayed in the application interface.

6. The page exception handling method according to claim 1, characterized in that: After determining the loading time threshold according to the network status, device performance and the resource data volume, the method further includes: When the loading of each loading event is monitored to be completed within the loading time threshold, detecting whether each element in the target page exists in the application interface through the second monitoring function injected by the WebView; wherein the second monitoring function is written in JavaScript code; In the case where the element in the target page exists in the application interface, detecting, by the second monitoring function, that the attribute of the element displayed in the application interface matches the attribute of the corresponding element in the target page; In the case that the element does not exist in the application interface or the attribute of the element does not match, a page close control and / or a page refresh control is displayed at a preset position of the application interface.

7. The page exception handling method according to claim 1, characterized in that: After determining the loading time threshold according to the network status, device performance and the resource data volume, the method further includes: When the loading of each loading event is detected to be completed within the loading time threshold, capturing a first image of the application interface; Rendering in a canvas element according to the document structure model of the target page, converting the canvas element into a second image; When the degree of matching between the first image and the second image is less than a preset matching degree threshold, a page close control and / or a page refresh control is displayed at a preset position of the application interface.

8. A page exception processing device, characterized in that: include: A page loading module is configured to obtain a uniform resource locator of a target page, load the target page through WebView and the uniform resource locator, and monitor various loading events of the WebView during the loading process; A loading duration determination module is configured to obtain the resource data volume of the target page through the network request event when the WebView processes the network request event in each loading event, and determine the loading duration threshold according to the network status, device performance and the resource data volume; The loading exception handling module is configured to display a page close control and / or a page refresh control at a preset position of the application interface when it is detected that the loading event fails to load or the loading time threshold is exceeded and the loading of each loading event is not detected to be completed.

9. A page exception processing device, characterized in that: include: one or more processors; The memory stores one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the page exception handling method as described in any one of claims 1 to 7.

10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the page exception handling method according to any one of claims 1 to 7 when executed by a computer processor.

Citation Information

Cited By

  • WebView-based cross-platform anomaly detection and repair method and system

    CN119783118A

  • Page inactivation detection method, system and equipment and storage medium

    CN120017326A

  • Page inactivation detection methods, systems, devices, and storage media

    CN120017326B