Webpage resource request method, terminal equipment and computer readable storage medium

By analyzing and splitting the web page URL and using OkHTTP to request resource data, the problem of network performance detection deviation when webview loads web pages is solved, and efficient and accurate network performance parameter detection is achieved.

CN119988760APending Publication Date: 2025-05-13HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410406142.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-07
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

In the prior art, when loading a web page through a webview, there are deviations in detection network performance parameters, resulting in the inability to accurately detect network performance.

Method used

By parsing the unified resource locator URL of the web page, split it into URLs corresponding to multiple resource data, and send resource data requests corresponding to these URLs to the server through OkHTTP to obtain resource data replyed by the server to improve the accuracy and efficiency of network performance parameter detection.

Benefits of technology

It realizes that all resource data required for loading and rendering of webpages is accurately obtained without affecting webview parsing and rendering of webpages, improving the accuracy and efficiency of network performance parameter detection, and avoiding the increase in user waiting time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988760A_ABST
    Figure CN119988760A_ABST
Patent Text Reader

Abstract

The invention provides a webpage resource request method, terminal equipment and a computer readable storage medium, and relates to the technical field of terminals. The method is applied to terminal equipment and comprises the steps that in a first time period, a first uniform resource locator URL of a webpage is analyzed, and the first URL comprises at least one second URL corresponding to resource data; within a second time period after the first time period, executing the following operations: sending a request of at least one resource data corresponding to the second URL to the server; and obtaining resource data replied by the server based on the request. In the embodiment of the invention, the process of analyzing the first URL of the webpage and the process of requesting the resource from the server based on the analyzed second URL are respectively completed in two continuous time periods, so that the time length of acquiring the resource data can be ensured not to be increased. Moreover, one process can be executed in each of the two time periods, so that inaccurate data volume of the resource data is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The application number of the original application is 202311472945.9, and the original application date is November 7, 2023. The entire contents of the original application are incorporated into this application by reference. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to a web page resource request method, a terminal device, and a computer-readable storage medium. Background Art

[0003] With the popularization and development of network technology, people's requirements for network performance are gradually increasing. If users need to optimize the performance of the network, they need to analyze the performance of the network first. At present, parameters such as domain name system (DNS) delay, signal strength, processor memory usage status of network devices, etc. can be detected, and these data can be used to reflect network performance. However, these parameters cannot objectively show the actual user experience of this network device, resulting in typical scenarios where users use more, such as browsing web pages and watching videos. The user experience cannot be well quantified and represented. In response to this, an application that runs in a terminal device and can manage network devices is currently proposed. The application can obtain parameters for representing network performance, and at the same time, it can also display mapping items for describing web browsing experience and video browsing experience to users based on network performance.

[0004] When the application in the terminal device tests the network performance, it needs to first request the web page through the webview, and then detect the request process of the webview through additional methods to obtain network performance parameters. However, the additional method itself will occupy network resources and loading time, which will lead to deviations in the detected network resources and loading time, making it impossible to accurately detect network performance. Summary of the invention

[0005] In view of this, the present application provides a web resource request method, a terminal device and a computer-readable storage medium, which can improve the accuracy and efficiency of network performance parameter detection in the scenario of loading web pages using webview.

[0006] In a first aspect, the present application provides a webpage resource request method, which is applied to a terminal device, and the method comprises: within a first time period, parsing a first uniform resource locator URL of a webpage, the first URL including at least one second URL corresponding to resource data; within a second time period after the first time period, performing the following operations:

[0007] Sending a request for at least one resource data corresponding to the second URL to the server;

[0008] Get the resource data that the server responds to based on the request.

[0009] The first URL includes at least one second URL corresponding to resource data.

[0010] The resource data obtained by the terminal device from the server may include indication information, and the indication information is used to indicate the data volume of the resource data. Optionally, the indication information may be included in the resource data, or may be indication information existing independently of the resource data.

[0011] In a possible implementation manner of the first aspect, the method is applied to detect network performance parameters, where the network performance parameters include at least one of the following parameters: loading time of a web page, and average loading rate of the web page.

[0012] In a possible implementation manner of the first aspect, the average loading rate is determined based on the loading duration and the data volume of the resource data.

[0013] In a possible implementation manner of the first aspect, the loading duration is a duration corresponding to the first time period and a duration corresponding to the second time period.

[0014] The loading time is the sum of the time corresponding to the first period and the time corresponding to the second period.

[0015] In another possible implementation of the first aspect, after obtaining the resource data of the server based on the request reply, it also includes: updating the resource data. For example, the resource data can be updated by replacing keywords or replacing part of the resource data. Afterwards, the terminal device can display the first interface according to the updated resource data.

[0016] In a possible implementation of the first aspect, after obtaining the resource data of the server based on the request reply, the method further includes: sending the resource data to the network visual webview; and rendering a web page based on the resource data in response to the webview.

[0017] In a possible implementation manner of the first aspect, the types of resource data include Response type and WebResourceResponse type. Before sending the resource data to the webview, the method also includes: converting the resource data of the Response type into resource data of the WebResourceResponse type; and sending the resource data of the WebResourceResponse type to the webview.

[0018] In a possible implementation of the first aspect, resource data of the Response type includes a first reply header and a first reply body, and resource data of the WebResourceResponse type includes a second reply header and a second reply body; converting the resource data of the Response type into resource data of the WebResourceResponse type includes: extracting a key object from the first reply header, and converting the key object into a second reply header using the object's construction method; converting the first reply body into a response stream of a byte input stream class; and composing the key object and the response stream into a second reply body.

[0019] In a possible implementation of the first aspect, resource data of the Response type includes a first reply header and a first reply body, and resource data of the WebResourceResponse type includes a second reply header and a second reply body; the second reply header includes a first key object; the first key object is obtained by converting the second key object using the object construction method, and the second key object is in the first reply header; the second reply body includes the second key object and a response stream, and the response stream is obtained by converting the first reply body into a byte input stream class.

[0020] In a possible implementation manner of the first aspect, the first key object includes a content type and an encoding type, wherein the content type and the encoding type are common key objects in a request header.

[0021] In a possible implementation manner of the first aspect, converting the first key object into the second key object using an object construction method includes: converting the first key object into a key-value pair of a map type, where the key-value pair of the map type is the second key object.

[0022] In a possible implementation of the first aspect, before parsing the first uniform resource locator URL of the webpage, the second URL of at least one resource data is intercepted by the shouldinterceptRequest method in WebViewClient. The resource URL can be intercepted by the shouldinterceptRequest method in WebViewClient, and the webview no longer sends a request to the server based on the resource URL.

[0023] In a possible implementation manner of the first aspect, sending a request for at least one resource data corresponding to the second URL to the server includes: sending a request for at least one resource data corresponding to the second URL to the server through OkHTTP.

[0024] In a possible implementation of the first aspect, before parsing the first uniform resource locator URL of the web page, the method also includes: in response to receiving a network performance test instruction, the network performance test application obtains the URL of the web page and sends the URL to the webview.

[0025] In a second aspect, the present application provides a terminal device, comprising a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; the display screen is used to display an image generated by the processor, and the memory is used to store computer program code, wherein the computer program code comprises computer instructions; when the processor executes the computer instructions, the terminal device executes the method described in the first aspect and any possible design thereof.

[0026] In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions, which, when executed on a terminal device, enables the terminal device to execute the method described in the first aspect and any possible design thereof.

[0027] In a fourth aspect, the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the method described in the first aspect and any possible design thereof.

[0028] In a fifth aspect, the present application provides a device, which is included in a terminal device, and the device has the function of implementing the behavior of the terminal device in any of the above aspects and possible implementation methods. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, an allocation module or unit, a scanning module or unit, a recycling module or unit, a moving module or unit, and a storage module or unit, etc.

[0029] In a sixth aspect, an embodiment of the present application provides a chip system, which includes a processor and may also include a memory, for implementing any one of the methods provided in the first aspect. The chip system may be composed of a chip, or may include a chip and other discrete devices.

[0030] It can be understood that the terminal device described in the second aspect and any possible design method provided above, the computer-readable storage medium described in the third aspect, and the computer program product described in the fourth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1A schematic diagram of a console page displayed on a PC provided in an embodiment of the present application;

[0032] Figure 2 A communication diagram of a terminal device provided in an embodiment of the present application;

[0033] Figure 3 A schematic diagram of a routing card management operation interface provided in an embodiment of the present application;

[0034] Figure 4 A schematic diagram of an existing web page resource request method provided in an embodiment of the present application;

[0035] Figure 5 A schematic diagram of another existing web page resource request method provided in an embodiment of the present application;

[0036] Figure 6 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0037] Figure 7 A schematic diagram of a system architecture of a terminal device provided in an embodiment of the present application;

[0038] Figure 8 A schematic diagram of a web page resource request method provided in an embodiment of the present application;

[0039] Fig. 9 A flowchart of a web page resource request method provided in this application;

[0040] Fig.10 A flowchart of another web page resource request method provided by this application;

[0041] Fig.11 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0043] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0044] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0045] Before introducing the embodiments of the present application, the technologies involved in the embodiments of the present application are first introduced in detail.

[0046] 1. Average loading rate: It is calculated by dividing the total amount of resource data loaded by the web page by the total time it takes to load the web page.

[0047] During the loading process of a web page, the terminal device first needs to parse the uniform resource locator (URL) of the web page (i.e. the first URL mentioned above), that is, the URL of the web page, and split it into multiple URLs corresponding to resource data (i.e. the second URL mentioned above, hereinafter referred to as: resource URL).

[0048] In some examples, parsing the URL of a web page can obtain the protocol (i.e., service mode), the IP address of the host storing the resource data (including the port number), and the specific address of the resource data on the host (such as the directory and file name, etc.). All the resource data involved in the URL of a web page may exist at the same or different addresses on a host, or may exist on multiple hosts. Therefore, parsing the URL of a web page can obtain at least one resource URL. For example, all the resource data involved in the URL of a web page may exist at an address on a host, and the URL of a web page corresponds to one resource URL. For another example, all the resource data involved in the URL of a web page may exist at different addresses on a host, or exist on multiple hosts, and the URL of a web page corresponds to multiple resource URLs.

[0049] After splitting the URL of a web page into multiple resource URLs, the terminal device then initiates a request to the server based on each resource URL, and finally renders the request result returned by the server onto the display page. During this process, the browser needs to send multiple resource requests to the server to obtain all resource data and display a visible web page to the user. Therefore, the request and forwarding capabilities for continuous resource URLs are also a manifestation of router performance. In this way, the average loading rate has a greater impact on the user's web browsing experience. For example, if the average loading rate is slow, it means that the longer it takes to load a web page with the same amount of data, the longer the user needs to wait.

[0050] In addition, parameters that have a great impact on the user's web browsing experience also include web page loading time. For example, if the web page loading time is too long, the user needs to wait for a long time. However, since the average loading rate actually includes the total loading time, the embodiment of the present application does not discuss the web page loading time too much for the time being, and the subsequent embodiments focus on the average loading rate.

[0051] 2. Webview (web page view): Webview is a control used by the terminal device operating system to display web pages. It can be understood as a browser embedded in the terminal device, providing the function of browsing web pages for applications running in the terminal device.

[0052] In the framework user interface (framework UI) mechanism, webview is used to embed web content into native applications. Webview uses the built-in browser engine to load and render web pages, and provides a communication interface with native applications, allowing developers to display part or all of the application interface through the web, and also enable interaction between web pages and native applications.

[0053] Among them, framework is a language development software that provides a framework for software development. In the development process of terminal device operating systems and corresponding applications, framework occupies a core position, providing many functions and services for terminal device operating systems and corresponding applications, such as UI components, data storage, network communication, multimedia, security, device drivers and system APIs. In the process of using framework for application development, the framework UI mechanism is used for design, the purpose of which is to separate the logic (business logic) of the UI and the application. In the framework UI mechanism, developers can use specific frameworks or libraries to build user interfaces, while the application logic can be developed and managed independently of the interface. This separation design pattern reduces the coupling between the interface and the logic, thereby improving the maintainability and scalability of the code.

[0054] 3.OkHTTP: The OkHTTP framework can be understood as a hypertext transfer protocol (http) client. We can use OkHTTP to send http requests to the server and then get the corresponding response content.

[0055] OkHTTP allows all requests to the same host address to share the same socket connection. The connection pool reduces request latency, thereby achieving more efficient results.

[0056] OkHTTP Client is the entry class of the OkHTTP framework, responsible for creating the OkHTTP client and configuring various parameters and interceptors.

[0057] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0058] In order to better understand the embodiments of the present application, the terminal device provided in the embodiments of the present application is first introduced.

[0059] Terminal equipment may also be referred to as terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. Terminal equipment may be a mobile phone, smart TV, wearable device, tablet computer (Pad), virtual reality (VR) terminal equipment, augmented reality (AR) terminal equipment, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, etc.

[0060] It should be noted that, in order to facilitate portability, the size of common mobile terminal devices such as mobile phones and tablets is smaller than that of personal computers (PCs). In a limited space, it is impossible to use hardware devices with better performance and larger size. Therefore, the hardware resources of mobile phones are more limited than those of PCs. Therefore, the operating systems used by mobile phones and PCs are different, and the specific type of operating system of terminal devices is not limited here.

[0061] There are also differences in the browser kernels used in different operating systems. Currently, the hardware performance of PC processors and other hardware is better than that of mobile terminals. Therefore, the functions in the PC are also richer, and more operations can be provided to users. Taking the browser as an example, the current PC browser that includes developer options can display the buffering time and page size when loading web pages. For example, the browser on the PC includes a developer option that can call up the console. The loading status of each web page can be detected in the console, including what resource data is loaded in each web page, as well as the response and time of each request. For example, Figure 1 , a schematic diagram of a console page displayed on a PC is shown in FIG. 1 , in which it can be seen that the completion time of loading the homepage of a shopping website on the left is 4.33 seconds, and the resource data file loaded is 2.3MB. In this way, the browser on the PC can directly calculate the average loading rate based on the total time and total data volume of the loaded web page.

[0062] Mobile phones using terminal device operating systems often use webview controls when loading web pages. After the webview control of the terminal device obtains the URL of the web page, webview needs to parse the URL of the web page to be loaded, split a URL into multiple resource requests, and then request different resource data and hypertext markup language (HTML) and other content based on multiple resource requests. When webview obtains all resource request results, it combines these resource request results and renders them, finally displaying the web page we can see.

[0063] Theoretically, the terminal device can obtain the total time and total data volume of the web page loading process during the webview loading the web page, and then obtain the average loading rate according to the calculation formula of the average loading rate.

[0064] In some examples, the smart space application installed in the terminal device can detect the network performance during the process of webview loading web pages. Taking the terminal device as a mobile phone as an example, Figure 2 As shown, a smart space application is installed in the mobile phone, and the mobile phone 100 is connected to the server 300 through the router 200. The smart space application can provide users with functions for managing routers.

[0065] In some application scenarios, the smart space application includes a routing card for managing the router. Users can use the routing card to manage the router and manage network performance. For example, the management interface corresponding to the routing card includes an intelligent detection option. For example, the terminal device detects that the user has Figure 3 After clicking the route card control 301 shown in (a), the mobile phone displays the following Figure 3 The management interface shown in (b) of FIG. The management interface includes an intelligent detection card, and the intelligent detection card includes a score for network performance and a grade corresponding to the score. When the terminal device detects that the user Figure 3 After the control 302 shown in (b) is clicked, the mobile phone displays the following Figure 3 The operation interface corresponding to the smart detection card shown in (c) in the figure includes a physical examination control 303. After the terminal device detects that the user clicks the control, the mobile phone displays specific physical examination items, for example, Figure 3 As shown in (d), the terminal device displays the following physical examination items: broadband test, web experience, video experience, network connectivity, connection speed, routing status, signal quality, and interference analysis. Figure 3After clicking the one-key physical examination control 304 in (d), the mobile phone can execute each test item corresponding to the physical examination item and obtain the corresponding test results.

[0066] like Figure 3 The test results corresponding to the broadband test shown in (e) show that the current broadband speed is 30M, and the current speed is at a relatively slow level. In addition, the broadband test results also include specific average upload speeds and average download speeds, as well as reminders issued to users based on the current broadband speed. For another example, the general conclusion shown in the test results of the web page experience indicates that the current Internet experience is good, and gives relevant parameters for web page loading, such as the average full load time, the average load rate, and the average response time. For another example, the general conclusion shown in the test results of the video experience indicates that the current video viewing experience is smooth, and users can watch Blu-ray (1080P) videos. In addition, the interface also gives relevant parameters for video loading, such as buffering delay, buffering rate, and the number of freezes. In this way, regardless of whether the user understands theoretical knowledge related to the network, they can understand the network performance from aspects such as broadband, web pages, and videos based on the test results.

[0067] Understandably, due to the limited content displayed on the mobile phone screen, Figure 3 (e) shows only the test results of broadband test, web experience and video experience. Figure 3 The interface shown in (e) includes the test results corresponding to all physical examination items, and the user can view the test results corresponding to each physical examination item by sliding the screen.

[0068] However, since webview is completely encapsulated, in the process of using webview to load web pages, webview makes requests and renders by itself. The terminal device cannot directly obtain the resource request results corresponding to each resource request loaded by webview in the above process, and cannot obtain the total data volume of resource data required to load the web page, and cannot calculate the average loading rate.

[0069] At present, in order to calculate the average loading rate, the terminal device can start another thread to obtain the total amount of resource data required by the webview to load the web page, thereby realizing the detection function of the above-mentioned smart space application.

[0070] In some embodiments, the terminal device can start a custom visual network performance test thread while starting the thread for loading web pages in webview to obtain the total amount of data loaded by webview. Figure 4As shown in the figure, the straight line with an arrow represents the timeline, the line segment below the timeline represents the running thread, and the length of the line segment represents the time taken for the running. At time t1, thread a1 for webview to load the webpage and thread b for data acquisition start running. At time t2, thread a1 for webview to load the webpage and thread b for data acquisition end running, and thread a2 for webview to render the webpage starts running. At time t3, thread a2 ends running, and the terminal device can calculate and display the measured average loading rate.

[0071] However, in the above process, the threads a1 and b running at the same time will occupy the bandwidth at the same time. Therefore, the amount of data actually obtained by thread b is the sum of the amount of data requested by thread a1 and the amount generated by the running of thread b. In this way, the total amount of data obtained by this method is too large, and the calculated average loading rate will also be too large.

[0072] In order to avoid the problem that the custom visual network performance test thread and the webview webpage loading thread occupy bandwidth at the same time, the terminal device can first run the webview webpage loading thread, and then use the custom data acquisition thread to obtain the total data volume of the webview loading webpage after the webview loads the webpage. For example, after the webview completes the loading of webpage A, the terminal device can call the OkHTTP request to send a webpage resource request corresponding to webpage A to the server. The webpage resource request is sent to the server when the webview loads the webpage, and after receiving the webpage resource data replied by the server, the data volume of the webpage resource data is counted, and the total data volume requested by the same webview can be obtained. Starting the custom data acquisition thread after the webview loads the webpage can avoid the custom data acquisition thread occupying the bandwidth of the webview webpage loading thread, so that the total data volume can be accurately obtained.

[0073] For example, Figure 5 As shown, the straight line with an arrow represents the timeline, the line segment below the timeline represents the running thread, and the length of the line segment represents the time taken for the running. At time t1, thread a1 for webview to load the web page starts running, and at time t2, thread a1 for webview to load the web page ends running, while thread a2 for webview to render the web page and thread b for data acquisition start running. At this time, thread a1 and thread b are not running at the same time, and thread b will not occupy bandwidth when thread a1 is running, so the amount of data actually obtained by thread b is the same as the amount of data requested by thread a1. However, at time t3, after thread a2 for webview to render the web page ends running, thread b is still in a running state until time t4. It can be seen that Figure 5The total time from t1 to t4 is relative to Figure 4 The total time from time t1 to time t3 is relatively long. In other words, the above process will prolong the entire test time and increase the time users have to wait for the test results.

[0074] For example, if the network condition is good, if threads a1 and b both take 10 seconds, and thread a2 takes 2 seconds, then Figure 4 When the network performance test is performed in the above method, the total waiting time of the user is 12 seconds from time t1 to time t3. Figure 5 When the network performance test is performed in the above method, the total waiting time of the user is 20 seconds from time t1 to time t4. Figure 5 The test method in makes the user wait longer. Furthermore, when the network condition is poor, the user's waiting time will become even longer. Figure 4 The testing method in will reduce the user's testing experience.

[0075] In response to the above problems, the present application provides a web resource request method, which can obtain all resource data required for loading and rendering web pages through other means without affecting the webview's parsing of the web page URL and rendering of the web page, thereby ensuring that the user's waiting time does not increase, and the terminal device can efficiently and accurately obtain resource data, so as to efficiently and accurately test the network performance parameters.

[0076] the following, Figure 6 The schematic diagram of the structure of a terminal device 100 provided in an embodiment of the present application is shown. The terminal device 100 may include a processor 610, an external memory interface 620, an internal memory 621, a universal serial bus (USB) interface 630, a charging management module 640, a power management module 641, a battery 642, an antenna 1, an antenna 2, a mobile communication module 650, a wireless communication module 660, an audio module 670, a speaker 670A, a receiver 670B, a microphone 670C, an earphone interface 670D, a sensor module 680, a button 690, a motor 691, an indicator 692, a camera 693, a display screen 694, and a subscriber identification module (SIM) card interface 695, etc.

[0077] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0078] The processor 610 may include one or more processing units, for example: the processor 610 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural network processor (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. Among them, the controller can be the nerve center and command center of the terminal device 100. The controller can generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0079] The processor 610 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 610 is a cache memory. The memory may store instructions or data that the processor 610 has just used or cyclically used. If the processor 610 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 610, and thus improves the efficiency of the system.

[0080] In some embodiments, the processor 610 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0081] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0082] The charging management module 640 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger. While the charging management module 640 charges the battery 642, it can also power the terminal device through the power management module 641. The power management module 641 is used to connect the battery 642, the charging management module 640 and the processor 610. The power management module 641 receives input from the battery 642 and / or the charging management module 640, and powers the processor 610, the internal memory 621, the external memory, the display 694, the camera 693, and the wireless communication module 660. In some embodiments, the power management module 641 can be set in the processor 610. In other embodiments, the power management module 641 and the charging management module 640 can also be set in the same device.

[0083] The wireless communication function of the terminal device 100 can be implemented through antenna 1, antenna 2, mobile communication module 650, wireless communication module 660, modem processor and baseband processor.

[0084] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0085] The modulation and demodulation processor may include a modulator and a demodulator, wherein the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal, and the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.

[0086] The mobile communication module 650 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the terminal device 100. The mobile communication module 650 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 650 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 650 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.

[0087] The wireless communication module 660 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the terminal device 100. The wireless communication module 660 can be one or more devices integrating at least one communication processing module. The wireless communication module 660 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 610. The wireless communication module 660 can also receive the signal to be sent from the processor 610, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0088] In some embodiments, antenna 1 of terminal device 100 is coupled to mobile communication module 650, and antenna 2 is coupled to wireless communication module 660, so that terminal device 100 can communicate with the network and other devices through wireless communication technology.

[0089] In some examples, after receiving an instruction to load a web page, the terminal device can obtain resource data corresponding to the web page from the server through wireless communication technology. The terminal device then renders the web page based on the resource data and displays the rendered web page on the display screen of the terminal device.

[0090] The terminal device 100 implements the display function through a GPU, a display screen 694, and an application processor. The GPU is a microprocessor for image processing, which is connected to the display screen 694 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 610 may include one or more GPUs, which execute program instructions to generate or change display information. In some embodiments, after the terminal device obtains data for representing network performance, it can display an interface corresponding to the network detection application based on the data. For example, after the terminal device obtains data such as the average loading rate of the web page loading process, it can display Figure 3 The interface shown in (e).

[0091] The display screen 694 is used to display images, videos, etc. The display screen 694 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLED, Micro-OLED, quantum dot light-emitting diodes (QLED), etc. In some embodiments, the terminal device 100 may include 1 or N display screens 694, where N is a positive integer greater than 1.

[0092] The external memory interface 620 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 610 through the external memory interface 620 to implement a data storage function. For example, files such as music and videos are stored in the external memory card.

[0093] The internal memory 621 can be used to store computer executable program codes, which include instructions. The processor 610 executes various functional applications and data processing of the terminal device 100 by running the instructions stored in the internal memory 621. The internal memory 621 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the terminal device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 621 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, a universal flash storage (UFS), etc.

[0094] The terminal device 100 can implement audio functions such as music playing and recording through the audio module 670, the speaker 670A, the receiver 670B, the microphone 670C, the headphone interface 670D, and the application processor.

[0095] The sensor module 680 may include a touch sensor 680K. The touch sensor 680K is also called a "touch panel". The touch sensor 680K may be arranged on the display screen 694, and the touch sensor 680K and the display screen 694 form a touch screen, also called a "touch screen". The touch sensor 680K is used to detect a touch operation acting on or near it. The touch sensor may pass the detected touch operation to the application processor to determine the type of touch event. A visual output related to the touch operation may be provided through the display screen 694. In other embodiments, the touch sensor 680K may also be arranged on the surface of the terminal device 100, which is different from the position of the display screen 694.

[0096] The key 690 includes a power button, a volume button, etc. The key 690 may be a mechanical key. It may also be a touch key. The terminal device 100 may receive key input and generate key signal input related to user settings and function control of the terminal device 100. The motor 691 may generate a vibration prompt. The motor 691 may be used for incoming call vibration prompts or for touch vibration feedback. The indicator 692 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0097] The SIM card interface 695 is used to connect a SIM card. The SIM card can be connected to and separated from the terminal device 100 by inserting the SIM card interface 695 or pulling it out from the SIM card interface 695. The terminal device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 695 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 695 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 695 can also be compatible with different types of SIM cards. The SIM card interface 695 can also be compatible with external memory cards. The terminal device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the terminal device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the terminal device 100 and cannot be separated from the terminal device 100.

[0098] The software system of the terminal device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes a terminal device operating system of a layered architecture as an example to exemplify the software structure of the terminal device 100.

[0099] The above-mentioned terminal devices can use a layered architecture to divide the software into several layers, each layer has a clear role and division of labor, and the layers communicate with each other through software interfaces.

[0100] The embodiments of this application are Figure 7 As shown in the system architecture, the software of the terminal device 100 is divided into four layers, namely, from top to bottom, the application layer, the application framework layer, the Android runtime (runtime) and system library, and the kernel layer.

[0101] It should be understood that Figure 7 The software layers shown are only exemplary, and actual implementation may include more or fewer layers. For example, a hardware abstraction layer may also be included, and the hardware abstraction layer is located between the kernel layer and the hardware layer.

[0102] The application layer can include a series of application packages. Figure 7 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, browser, network test, etc.

[0103] Among them, the network test application refers to an application that has the function of testing network performance, and the embodiments of the present application do not limit the name of the application. In some embodiments, when the setting application installed in the terminal device has the function of testing network performance, the setting application can be called a network test application. In other embodiments, if an instant messaging application has the function of testing network performance, the instant messaging application can also be called a network test application. For example, Figure 2 As shown, the smart space application with network performance testing is a network testing application.

[0104] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0105] like Figure 7 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, OkHTTP, etc.

[0106] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0107] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0108] The view system includes visual controls, such as controls for displaying text, controls for displaying images, webview, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a network performance detection icon can include a view for displaying text and a view for displaying images.

[0109] Among them, the webview can parse the first uniform resource locator URL of the web page, and the first URL includes a second URL corresponding to at least one resource data.

[0110] In some examples, the view system also includes WebViewClient, and the terminal device can intercept the URL of at least one resource data obtained by the webview analyzing the URL of the web page through the shouldinterceptRequest method in WebViewClient.

[0111] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0112] OkHTTP can send a request for at least one resource data corresponding to the second URL to the server, and obtain the resource data replied by the server.

[0113] Runtime includes core libraries and virtual machines. Runtime is responsible for scheduling and managing the operating system of the terminal device.

[0114] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the core library for terminal device operations.

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

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

[0117] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0118] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0119] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0120] A 2D graphics engine is a drawing engine for 2D drawings.

[0121] The kernel layer is a layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, sensor driver, and communication driver. The communication driver is used to drive devices such as mobile communication module 650, wireless communication module 660, modem processor, and baseband processor.

[0122] It should be noted here that in the process of network performance testing, the system library is mainly used to provide the required system-level implementation for the application framework layer, such as the library providing database support, 3D graphics support, browser kernel support, etc.

[0123] The following is based on Figure 7 , briefly describes the process of loading a web page through webview on a terminal device. The related technology provides a method for loading and rendering a web page. After the terminal device obtains the web page URL entered by the user in the address bar of the browser, it enters the URL into the webview ( Figure 7 After that, the webview parses the webpage URL to obtain multiple resource URLs, and then sends a driver request to the communication driver based on each resource URL ( Figure 7 Then, the communication driver can drive the network device ( Figure 7 Process ③) in the above process sends a resource request to the server. The network device can also receive the web resource data fed back by the server for each resource URL, and feed the web resource data back to the webview ( Figure 7 Process ④) in the process enables webview to render all web page resource data to obtain the web page finally displayed on the display screen.

[0124] Combination Figure 4 as well as Figure 5 , and the aforementioned related descriptions, it can be seen that after requesting resource data through the above process, the amount of data obtained is inaccurate, or the user needs to wait for a long time.

[0125] In order to solve the above technical problems, in the web resource request method provided in the embodiment of the present application, the network test application sends a web page URL for testing to the webview ( Figure 7In the process ⑤), after the webview decomposes the URL into multiple resource URLs, the terminal device uses an embodiment of the present application to provide an OkHTTP based on the webview to parse the URL of the webpage to obtain the resource URL, and sends the resource request action to the server through the network driver, so that the terminal device no longer executes Figure 7 Process ② in OkHTTP obtains all resource URLs ( Figure 7 After process ⑥), you can replace webview and send a driver request to the communication driver ( Figure 7 Process ⑦) Then, the communication driver can drive the network device ( Figure 7 Process ③) in the above process sends a resource request to the server. After receiving the web resource data fed back by the server for each resource URL, the network device can obtain network performance parameters based on the web resource data, and then feed back the web resource data and web performance parameters to webview ( Figure 7 Process ⑧ and process ⑨) in the process enable webview to render all web page resource data and web page performance parameters, and finally display a visual interface including network performance parameters.

[0126] like Figure 8 As shown, thread a1 is the process of webview parsing the URL, and the execution process of thread b includes Figure 7 Process ⑥, process ⑦, process ③, process ⑧ and process ⑨ in it. After thread a2 feeds back the resource data and performance parameters of the webpage to webview by OkHTTP, webview performs rendering based on the resource data of the webpage. Thread b can be used to obtain the requested resource data. And based on the resource data, indication information indicating the data volume of the resource data can be obtained. After that, thread b gives these resource data to webview, and the page rendering can be realized through thread a2, and the following is obtained: Figure 3 In addition, the terminal device can also obtain the total time of loading the web page. In this way, thread b will not be connected with thread a (referring to the total process of webview loading and rendering the web page, i.e. Figure 4 and Figure 5 Thread a1) in the process is executed simultaneously to avoid bandwidth occupation and ensure the accuracy of the acquired resource data size. In addition, thread b will not be executed again after thread a is completely executed, which will increase the waiting time of the user and reduce the user experience of the terminal device.

[0127] During this process, OkHTTP intercepts the resource URL obtained by webview and initiates a resource request based on the resource URL, and webview will no longer repeatedly initiate resource requests based on the resource URL, which can avoid OkHTTP and webview occupying bandwidth at the same time, thereby ensuring that the amount of data can be accurately obtained. In addition, after OkHTTP sends a request based on the resource URL, the terminal device can calculate and display the network performance parameters, so it will not cause the problem of increased waiting time.

[0128] See also Fig. 9 , Fig. 9 A flowchart of a web page resource request method provided in this application.

[0129] During the first period, the terminal device performs the following steps:

[0130] Step S901: parsing a first uniform resource locator URL of a web page, where the first URL includes at least one second URL corresponding to resource data.

[0131] Exemplary, combined Figure 8 , the terminal device can perform the parsing operation on the webpage URL through thread a1 during the period from time t1 to time t2. In some examples, the parsing operation of thread a1 is performed by webview.

[0132] In a second time period after the first time period, the following steps are performed:

[0133] Step S902: Send a request for at least one resource data corresponding to the second URL to the server;

[0134] Step S903: Obtain resource data from the server based on the request response.

[0135] Exemplary, combined Figure 8 , the terminal device can execute the above steps S902 and S903 through thread b during the period from time t2 to time t3. In some examples, OkHTTP sends a request for resource data to the server, and receives the resource data request replied by the server.

[0136] In some embodiments, the resource data obtained by the terminal device from the server may include indication information, and the indication information is used to indicate the data volume of the resource data. Optionally, the indication information may be included in the resource data, or may be indication information that exists independently of the resource data.

[0137] Optionally, in a third period after the second period, if Figure 8 As shown, the terminal device can execute the following steps through thread a2: rendering to obtain a web page based on the resource data.

[0138] In some embodiments, the webpage resource request method is applicable to the scenario of detecting network performance. Below, the webpage resource request method provided in the embodiment of the present application is described in detail.

[0139] like Fig.10 As shown, the webpage resource request method provided in the embodiment of the present application includes the following steps:

[0140] Step S1001: In response to receiving a network performance test instruction, the network performance test application obtains a web page URL.

[0141] In the embodiment of the present application, the terminal device detects that the user Figure 3 The click operation of the one-key physical examination control 304 in (d) can be regarded as receiving a network performance test instruction.

[0142] In some embodiments, the webpage URL may be pre-set in the terminal device. For example, after the network performance detection application is installed in the terminal device, the webpage URL for testing network performance is stored in the terminal device.

[0143] In some examples, when the terminal device detects that the user Figure 3 After the one-key physical examination control 304 is clicked in (d), the terminal device obtains all pre-stored web page URLs from the memory.

[0144] In some examples, when a plurality of web page URLs are pre-set in the terminal device, the terminal device may also randomly select at least one web page URL from the plurality of pre-stored web page URLs.

[0145] Step S1002: The network performance test application sends the web page URL to the webview.

[0146] Step S1003: webview parses the web page URL and obtains multiple resource URLs.

[0147] When webview loads a webpage, it does not only issue one request to obtain all resource data, but needs to make separate requests for different resource data. Therefore, after webview gets the webpage URL, it will first parse the webpage URL and split the webpage URL into multiple resource URLs. For example, a shopping webpage consists of pictures, videos, and text, so the shopping webpage URL can be split into resource URLs for requesting pictures, resource URLs for requesting videos, and resource URLs for requesting text.

[0148] Step S1004: In response to obtaining multiple resource URLs, intercept all resource URLs.

[0149] In some embodiments, a custom WebViewClient can be used to rewrite the shouldinterceptRequest method to intercept all resource URLs. WebViewClient is a tool used to help webview handle various notification and request events. In this method, the shouldinterceptRequest method in WebViewClient is rewritten so that the resource URL can be intercepted through the shouldinterceptRequest method in WebViewClient.

[0150] In some examples, the interception principle of the shouldInterceptRequest method is to intercept the resource URL in the response phase, and then use other methods to make resource requests for the resource URL, and the webview no longer sends requests to the server based on the resource URL.

[0151] Step S1005: Request each resource URL separately and obtain all resource data replied by the server.

[0152] In some embodiments, the terminal device can utilize OkHTTP to request each resource URL.

[0153] Step S1006: Determine network performance parameters based on all resource data replied by the server.

[0154] In some embodiments, the network performance test application includes a process for calculating network performance parameters. After receiving all resource data replied by the server, the process can count the sum of the data size of each resource data to obtain the total data size required to load the web page. Afterwards, the process can also calculate the average loading rate based on the total data size and the total loading time of loading the web page using webview.

[0155] In some examples, the reply header corresponding to some resource URLs includes the data size of the resource data. For these replies, the process can directly obtain the data size of the resource data based on the reply header. However, for replies without the resource data size in the reply header, the process needs to estimate the resource data size based on the reply resource data.

[0156] Optionally, after step S1006, in order to ensure that the webview can continue to render the web page, the following method can be used (such as Fig.10 The step in the dotted box 2) sends the resource data to the webview.

[0157] Step S1007: Convert the Response type reply into a WebResourceResponse type reply.

[0158] The reply refers to the resource data in the aforementioned embodiment.

[0159] When the terminal device uses OkHTTP or other methods to request the resource data corresponding to each resource URL, the type of response obtained by the terminal device from the server is Response, and the response type that webview can process is WebResourceResponse type. Therefore, the terminal device can convert the response type response into a WebResourceResponse type response.

[0160] In some embodiments, a Response type reply may be converted into a WebResourceResponse type reply by the following process: first, a request header for requesting a Response type reply is obtained, and the content type (Content-type) and encoding type are obtained from the request header.

[0161] Among them, Content-type and encoding type are common key objects in the request header. Content-Type generally refers to the Content-Type that exists in the web page, which is used to define the type of content of the web page file and determines the form in which the browser will read the web page file. In other words, Content-Type can tell the client the content type of the content actually returned. The encoding type refers to the encoding method of the web page file, which determines the encoding in which the browser will read the web page file. In some examples, if the browser's native form does not set the encoding type, the data will eventually be submitted in application / x-www-form-urlencoded mode.

[0162] Then, the terminal device can use the object construction method to construct the Content-type and encoding type into a header of the WebResourceResponse type. After that, the terminal device converts the data part (body) of the Response type reply into a response stream of the byte input stream class (inputStream). Subsequently, the terminal device combines the Content-type, encoding type, and response stream into an object in the WebResourceResponse type reply, namely, resourceResponse.

[0163] In some embodiments, the head of resourceResponse is a key-value pair of map type, which is different from the head of the string of the Response type reply. Therefore, the terminal device can add a colon to the head in the Response type reply, and then convert it into a key-value pair of map type, and use the converted map type key-value pair as the head of resourceResponse.

[0164] Step S1008: Send a reply of type WebResourceResponse and network performance parameters to the webview.

[0165] In some embodiments, the network performance parameters may be determined based on the actual application scenario. For example, the network performance parameters may include the average loading rate, the average complete loading time, and the average response time.

[0166] Step S1009, webview renders a network performance display page based on the response of the WebResourceResponse type and the network performance parameters.

[0167] In this way, through the above steps S1007 to S1009, it can be ensured that the webview can receive resource data of the WebResourceResponse type that the webview can process.

[0168] In some embodiments, the above method is applied to a scenario of detecting network performance, and the detected network performance parameters include at least one of the following parameters: the loading time of a web page, and the average loading rate of a web page. The average loading rate of a web page is determined based on the loading time of the web page and the amount of resource data.

[0169] In some instances, such as Figure 8 As shown, the loading time of the webpage may be the time from time t1 to time t3.

[0170] Some examples include Fig. 9 In the corresponding embodiment, the loading duration of the webpage may be the sum of the duration corresponding to the first time period and the duration corresponding to the second time period.

[0171] In some embodiments, Fig.10 As shown, step S1001 and step S1002 in the dotted box 1 are optional steps. Accordingly, when the terminal device does not execute step S1001 and step S1002, when executing step S1003, the terminal device can obtain the preset webpage URL through webview and parse it to obtain multiple resource URLs.

[0172] In some embodiments, the terminal device may obtain the multiple resource URLs parsed by the webview in other ways, for example, directly, or through other interception methods. The specific method by which the terminal device obtains the multiple resource URLs parsed by the webview is not limited here.

[0173] In some embodiments, the webpage resource request method is applicable to the scenario of webpage display. Below, the webpage resource request method provided in the embodiment of the present application is briefly described in detail.

[0174] In some examples, after step S1005, the terminal device can obtain all resource data replied by the server. Then the terminal device can modify the resource data based on the user's needs, so that the terminal device can render a web page that meets the user's needs based on the modified resource data. For example, a specified field can be added or reduced in all resource data replied by the server, or all resource data replied by the server can be replaced with other content, or part of the content in all resource data replied by the server can be filtered, so as to achieve the effect of filtering out advertisements or other content in the page.

[0175] For example, when all resource data replied by the server to the terminal device are resource data of web games, in order to prevent children from viewing web games, the guardian of the child inputs a request to prohibit access to all web games in the terminal device. At this time, after the child inputs the URL of the web game, the first interface actually displayed on the terminal device may include information prompting prohibited access.

[0176] like Figure 8 As shown, thread a1 is the part where webview parses the URL, thread b is the process of steps S1004-S1008, and thread a2 is step S1009. It can be seen that the above scheme can decouple the process of obtaining webpage resource data and the process of rendering based on webpage resource data. Thread b can be used to obtain the statistical data size of the requested resource data and the resource data used to load the webpage. After that, thread b gives these resource data to webview, and the page rendering can be realized through thread a2, as shown below. Figure 3 In this way, thread b does not execute the same steps as thread a, which increases the waiting time, nor does it need to execute together with thread a to avoid bandwidth occupation, thus ensuring the accuracy of the size of the acquired resource data.

[0177] Combination of the above Figure 6-Figure 10 The webpage resource request method provided by the embodiment of the present application is described in detail. Fig.11 The terminal device provided in the embodiment of the present application is described in detail.

[0178] In one possible design, Fig.11 This is a schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Fig.11 As shown, the terminal device 1100 may include: a display unit 1101, a processing unit 1102, and a transceiver unit 1103. The terminal device 1100 may be used to implement the functions of the terminal device involved in the above method embodiment.

[0179] Optionally, the display unit 1101 is used to support the terminal device 1100 to display interface content; and / or to support the terminal device 1100 to execute Fig. 9 Also used to support the terminal device 1100 to execute Fig.10 The method in .

[0180] Optionally, the processing unit 1102 is used to support the terminal device 1100 to execute Fig. 9 Also used to support the terminal device 1100 to execute Fig.10 The method in .

[0181] Optionally, the transceiver unit 1103 is used to support the terminal device 1100 to execute Fig. 9 Also used to support the terminal device 1100 to execute Fig.10 The method in .

[0182] The transceiver unit may include a receiving unit and a sending unit, and may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. The operations and / or functions of each unit in the terminal device 1100 are respectively to implement the corresponding process of the webpage resource request method described in the above method embodiment. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional unit, and for the sake of brevity, they will not be repeated here.

[0183] Optionally, Fig.11 The terminal device 1100 shown may also include a storage unit ( Fig.11 (not shown), the storage unit stores a program or instruction. When the processing unit 1102 and the transceiver unit 1103 execute the program or instruction, Fig.11 The terminal device 1100 shown can execute the webpage resource request method described in the above method embodiment.

[0184] Fig.11 The technical effects of the terminal device 1100 shown can refer to the technical effects of the web resource request method described in the above method embodiment, which will not be repeated here.

[0185] In addition to being in the form of the terminal device 1100, the technical solution provided in the embodiment of the present application may also be a functional unit or chip in the terminal device, or a device used in conjunction with the terminal device.

[0186] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned terminal device, the terminal device executes each function or step in the above-mentioned method embodiment.

[0187] The embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed on a terminal device, the terminal device executes each function or step in the above method embodiment.

[0188] Through the description of the above implementation methods, technical personnel in the relevant field can clearly 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.

[0189] In the several 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 the modules or units is only a logical function division. 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.

[0190] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0191] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0192] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0193] 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 changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A webpage resource request method, characterized in that: Applied to a terminal device, the method comprises: In a first time period, a first uniform resource locator URL of a web page is parsed through a network visual webview to obtain a plurality of second URLs, wherein the first URL includes the second URL corresponding to at least one resource data, and the first URL is a web page URL for testing; Intercepting a second URL using a hypertext transfer protocol client; wherein after intercepting the second URL, the webview does not send a request for at least one resource data corresponding to the second URL to the server; In a second time period after the first time period, using the hypertext transfer protocol client to send a request for at least one resource data corresponding to the second URL to the server; Obtain resource data replied by the server based on the request; Sending the resource data to the network visual webview; The webview renders the webpage based on the resource data.

2. The method according to claim 1, characterized in that The method further comprises: A network performance parameter is determined based on the resource data, where the network performance parameter includes at least one of the following parameters: the loading time of the webpage and the average loading rate of the webpage.

3. The method according to claim 2, characterized in that The average loading rate is determined based on the loading duration and the data volume of the resource data.

4. The method according to claim 2 or 3, characterized in that: The loading duration is the duration corresponding to the first time period and the duration corresponding to the second time period.

5. The method according to claim 1, characterized in that The types of the resource data include a Response type and a WebResourceResponse type. Before sending the resource data to the webview, the method further includes: Convert the resource data of the Response type into the resource data of the WebResourceResponse type; Send the resource data of WebResourceResponse type to the webview.

6. The method according to claim 5, characterized in that The resource data of the Response type includes a first reply header and a first reply body, and the resource data of the WebResourceResponse type includes a second reply header and a second reply body; The second reply header includes a first key object; the first key object is obtained by converting the second key object using an object construction method, and the second key object is in the first reply header; The second reply body includes the second key object and a response stream, and the response stream is obtained by converting the first reply body into a byte input stream class.

7. The method according to claim 6, characterized in that The first key object includes content type and encoding type.

8. The method according to claim 6 or 7, characterized in that: The first key object is converted into a second key object by using an object construction method, including: The first key object is converted into a key-value pair of a map type, where the key-value pair of the map type is the second key object.

9. The method according to any one of claims 1 to 3, characterized in that: Before parsing the first uniform resource locator URL of the webpage, the second URL of the at least one resource data is intercepted by the shouldinterceptRequest method in WebViewClient.

10. The method according to any one of claims 1 to 9, characterized in that The Hypertext Transfer Protocol client is an OkHTTP client.

11. A terminal device, characterized in that: The terminal device includes a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; the display screen is used to display an image generated by the processor, and the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the terminal device executes the method described in any one of claims 1-10.

12. A computer-readable storage medium, characterized in that: The method comprises computer instructions, and when the computer instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 10.