Loading traversal method for optimizing browser capability

The loading traversal method optimizes browser performance by encrypting patch files, using a Chrome Vector cache, and implementing fuzzy URL matching to reduce memory usage and streamline rule writing, thereby improving system efficiency and user experience.

CN119106214AActive Publication Date: 2024-12-10ANDROIDMOV TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411108462.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2024-12-10
Estimated Expiration
2044-08-13

AI Technical Summary

Technical Problem

Existing browser technologies face issues with high memory usage and increased time complexity due to large patch files and the need for repetitive rule writing for similar replacements, lacking fuzzy matching capabilities.

Method used

Implement a loading traversal method that uses a private key to encrypt patch files, stores replacement rules in a Chrome Vector cache table, supports fuzzy URL matching, and includes an HTML Parser, CSS Parser, and V8 engine for efficient resource file parsing and replacement.

Benefits of technology

Reduces memory usage, improves system performance, and simplifies rule writing by enabling accurate fuzzy matching, enhancing browser efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119106214A_ABST
    Figure CN119106214A_ABST
Patent Text Reader

Abstract

The invention discloses a loading traversal method for optimizing browser capability, which comprises the following steps of: S1, creating a browser Webvi ew, and calling an interface provided by the browser by a user to issue configuration; a browser kernel is initialized; step S2, reading the patch file by the browser kernel, and storing the replacement rule by the browser kernel by using Chromi um Vector as a cache table; s3, loading a page, and triggering a net module to initiate a request to a server; s4, the search engine analyzes the resource files respectively; s5, when the user performs page switching or interactive operation, repeating the steps S3 and S4, and reloading and rendering new page content; and step S6, the system triggers WebView resource release and kernel component destruction, and the process is ended. By means of the method, the regular matching function supporting the URL is introduced, the page needing to be replaced can be matched more accurately, unnecessary traversal and processing are avoided, and the accuracy of the replacement rule is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of browser performance, and specifically relates to a loading traversal method for optimizing browser capabilities. Background Art

[0002] Because the pages provided by customers may not be compatible with the current browser version, or there may be problems with the writing of the pages themselves, the pages cannot be displayed or operated normally. In order to solve this problem, the browser has specially developed a solution to dynamically replace the page content. Through this technology, compatibility and adaptation are achieved, ensuring that the customer's pages can be perfectly presented in various browsers, improving the user experience.

[0003] Existing technology: The content to be replaced is written into a special patch file and encrypted. Subsequently, the encrypted patch file is packaged into the client's APK. After the browser starts downloading the page document and before parsing the document, the encrypted patch file is extracted and applied through a specific mechanism to achieve dynamic replacement of the page content. This process ensures that the page is repaired and optimized before presentation, thereby providing a better user experience and page display effect.

[0004] The main disadvantages of existing technologies include:

[0005] 1. Regarding the problem of too much patch file content, when the number of replacement rules stored in the process cache is huge, it may lead to an increase in memory usage and an increase in the time complexity of traversal operations, thus affecting system performance.

[0006] 2. Currently, the system can only perform exact matching, and cannot perform fuzzy matching on URLs. This means that when the same replacement rule needs to be used on multiple pages, multiple rules need to be written repeatedly, increasing workload and maintenance costs. Summary of the invention

[0007] The purpose of the present invention is to provide a loading traversal method for optimizing browser capabilities, so as to solve the problem in the prior art proposed in the background technology that there is too much content in the patch file, and when the same replacement rules need to be used on multiple pages, multiple rules need to be repeatedly written, which increases the workload and maintenance costs.

[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0009] A loading traversal method for optimizing browser capabilities includes the following steps:

[0010] Step S1, create a browser Webview, the user calls the interface provided by the browser to send the configuration; and initialize the browser kernel;

[0011] Step S2: Use the private key to encrypt the plaintext patch file, and the encrypted file is packaged into the APK. When the browser is running, it will read the encrypted patch file from the assets directory of the application, decrypt it, and restore the file to plaintext using the same private key. The browser kernel uses Chrome Vector as a cache table to store replacement rules, and stores them in three different cache tables according to the type.

[0012] Step S3, calling loadUr 1 to trigger a network request, the browser uses the network module to establish a connection with the server to which the URL belongs, and sends a request message to the server, the request message includes the request method, URL address, and request header information; the server processes the request according to the request message and returns a corresponding response message, the response message includes the resource files required for the web page;

[0013] Step S4, the search engine will traverse its corresponding cache table to match according to the type, and then the search engine will parse the resource files respectively;

[0014] Step S5, when the user switches pages or performs interactive operations, repeat steps S3 and S4 to reload and render new page content; and when the user exits the application, proceed to step S6;

[0015] Step S6, when exiting the application, the system triggers the release of WebView's resources and the destruction of kernel components, ending the process.

[0016] According to the above technical solution, in step S2, the original content includes several replacement rules, and the replacement rules include type, URL, source string and target string.

[0017] According to the above technical solution, in step S3, the resource files include HTML, CSS and JavaScript files.

[0018] According to the above technical solution, in step S4, the search engine includes one or more of an HTML Parser, a CSS Parser and a V8 engine.

[0019] According to the above technical solution, in step S4, traversing the corresponding cache table according to the type for matching is specifically as follows:

[0020] Step S401, determine whether the file is being processed. If it is being processed, determine whether the URL of the file matches the URL in the Modify Item successfully. If the match is successful, proceed to step S402; if the match fails, proceed to step S403;

[0021] Step S402, determining whether the processed file content includes the source string in the Modify Item, if yes, replacing the source string with the target string and proceeding to step S404, if no, proceeding to step S403;

[0022] Step S403: the match fails, indicating that the file does not need to be replaced;

[0023] Step S404, repeating steps S401 and S402 to complete the traversal of the cache table.

[0024] According to the above technical solution, in step S401, the condition for successful matching is whether the URL of the file is exactly the same as the URL in ModifyItem, or whether the URL of the file satisfies the matching rule defined by the URL in ModifyItem.

[0025] According to the above technical solution, in step S6, the system calls the corresponding life cycle method to trigger the resource release and kernel component destruction of WebView, including using one or more of the onPause, onStop and onDestroy methods.

[0026] According to the above technical solution, triggering the resource release and kernel component destruction of WebView includes stopping network requests, releasing memory, closing network connections, and terminating related processes.

[0027] Compared with the prior art, the present invention has the following beneficial effects:

[0028] The purpose of the present invention is to solve these shortcomings of the prior art by adding a fuzzy matching function to the URL. By introducing a regular matching function, the page to be replaced can be matched more accurately, reducing unnecessary traversal and processing, thereby reducing memory usage and improving system efficiency. At the same time, supporting regular matching also simplifies the writing of replacement rules, reduces duplication of work, and improves the flexibility and maintainability of the system. This technical improvement is intended to optimize system performance and enhance user experience to address the shortcomings of the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 It is a schematic diagram of the implementation process of the present invention. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] Embodiment 1

[0032] like Figure 1 As shown, a loading traversal method for optimizing browser capabilities includes the following steps:

[0033] Step S1, create a browser Webview, the user calls the interface provided by the browser to send the configuration; and initialize the browser kernel;

[0034] Step S2: Use the private key to encrypt the plaintext patch file, and the encrypted file is packaged into the APK. When the browser is running, it will read the encrypted patch file from the assets directory of the application, decrypt it, and restore the file to plaintext using the same private key. The browser kernel uses Chrome Vector as a cache table to store replacement rules, and stores them in three different cache tables according to the type.

[0035] Step S3, the loadUr l method is an interface provided by the browser, which is used to load the specified URL address, that is, to open a web page. Calling loadUr l triggers a network request. The browser uses the network module to establish a connection with the server to which the URL belongs, and sends a request message to the server. The request message contains the request method, URL address, and request header information. The server processes the request according to the request message and returns the corresponding response message. The response message includes the resource files required for the web page.

[0036] Step S4, the search engine will traverse its corresponding cache table to match according to the type, and then the search engine will parse the resource files respectively;

[0037] Step S5, when the user switches pages or performs interactive operations, repeat steps S3 and S4 to reload and render new page content; and when the user exits the application, proceed to step S6;

[0038] Step S6, when exiting the application, the system triggers the release of WebView's resources and the destruction of kernel components, ending the process.

[0039] Through the method of the present invention, by introducing a regular matching function that supports URLs, the page that needs to be replaced can be matched more accurately, unnecessary traversal and processing can be avoided, and the accuracy of the replacement rule is improved.

[0040] By optimizing the content of patch files, memory usage is reduced, system performance is improved, and resource consumption is reduced. Optimizing traversal efficiency and simplifying rule writing make the system run more efficiently and increase the overall browser page loading speed by 5%. The function of supporting regular matching simplifies the writing process of replacement rules, reduces duplication of work, improves work efficiency, and reduces maintenance costs.

[0041] Through the above optimization measures, the present invention can significantly improve system performance, speed up page loading, enhance user experience, and enable users to use the system more smoothly.

[0042] Embodiment 2

[0043] This embodiment is a further refinement of the first embodiment.

[0044] In step S2, the original content includes several replacement rules, and the replacement rules include type, URL, source string and target string.

[0045] In step S3, the resource files include HTML, CSS and JavaScript files.

[0046] In step S4, the search engine includes one or more of an HTML Parser, a CSS Parser and a V8 engine.

[0047] In step S4, the corresponding cache table is traversed according to the type for matching as follows:

[0048] Step S401, determining whether the file is being processed. If it is being processed, determining whether the URL of the file matches the URL in the Modify Item successfully. If the match is successful, proceed to step S402. If the match fails, proceed to step S403.

[0049] Step S402, determining whether the processed file content includes the source string in Modify Item, if yes, replacing the source string with the target string and proceeding to step S404, if no, proceeding to step S403;

[0050] Step S403: the match fails, indicating that the file does not need to be replaced;

[0051] Step S404, repeating steps S401 and S402 to complete the traversal of the cache table.

[0052] In step S401, the condition for successful matching is whether the URL of the file is exactly the same as the URL in the Modify Item, or whether the URL of the file satisfies the matching rule defined by the URL in the Modify Item, which is a template composed of a series of characters (numbers, letters and underscores) and special characters (., +, *, \, etc.) to check whether the text to be matched is constructed according to the template. For example, the defined URL rule is / path / to / \d+ / index.html, where \d+ can represent any number, so the URL that meets the rule can be / path / to / 01 / index.html, while / path / to / at / index.html does not meet the rule.

[0053] In step S6, the system calls the corresponding life cycle method to trigger the resource release and kernel component destruction of the WebView, including using one or more of the onPause, onStop and onDestroy methods.

[0054] The resource release and kernel component destruction that triggers WebView include stopping network requests, releasing memory, closing network connections, and terminating related processes.

[0055] Embodiment 3

[0056] This embodiment provides a specific implementation method.

[0057] Step 1: Create a browser. Users can call the interface provided by the browser to send configurations according to their needs, such as setting the window size, enabling cache, etc.

[0058] During the process of initializing the browser kernel, the system will load the WebView kernel module, initialize the operating environment, provide a communication interface for WebView, ensure that the WebView kernel can smoothly load and render network resources, and perform security management to ensure that WebView runs stably in the application.

[0059] Step 2: The browser kernel reads the encrypted patch file in the assets directory of the Android application and decrypts it to obtain the original content. The original content contains multiple replacement rules (Modify Item), each of which consists of a type (HTML, JavaScript or CSS), a URL, a source string, and a target string.

[0060] The kernel uses Chrome Vector as a cache table to store these rules, and stores them in three different cache tables according to the type. In this way, in subsequent operations, the kernel can directly traverse the corresponding cache table according to the type, thereby reducing unnecessary traversal time and being able to efficiently perform page replacement operations without repeatedly reading and decrypting files, thereby significantly improving the efficiency and performance of replacement operations.

[0061] Step 3: Actively load the page through the browser interface loadUrl method, which will trigger the net module to initiate a request to the server to establish a connection and download various resource files required for the web page (mainly HTML, CSS, JavaScript files). The process of network and resource loading is the first step in web page loading and rendering, and it is also an indispensable part. Once the loading is completed, the user can interact with the page, including clicking hyperlinks, filling out forms, etc., to browse and operate the web page content.

[0062] Step 4: In order to adapt and be compatible with the web pages provided by the customer, after downloading the resources in step 3, the HTMLParser, CSS Parser, and V8 engines will first traverse their corresponding cache tables for matching according to the type before parsing these resource files respectively:

[0063] 1. If the URL of the file being processed matches the URL in Modify Item, proceed to step 2; otherwise, proceed to step 3.

[0064] 2. If the processed file content contains the source string in Modify Item, the source string will be replaced with the target string. This step is to be compatible with the page provided by the customer so that it can be displayed perfectly; then proceed to step 4.

[0065] 3. If the match fails, it means that the file does not need to be replaced; then proceed to step 4.

[0066] 4. If the cache table has not been traversed completely, repeat steps 1 and 2, otherwise proceed to step 5.

[0067] Step 5: When the user switches pages or performs interactive operations, repeat steps 3 and 4 to load and render new page content; when the user exits the application, proceed to step 6;

[0068] Step 6: Exit the application. The system calls the corresponding life cycle methods (including onPause, onStop, and onDestroy) to trigger the release of WebView resources and destruction of kernel components, including stopping network requests, releasing memory, closing network connections, and terminating related processes to ensure that resources are released and the corresponding processes are terminated, thereby avoiding memory leaks and performance issues.

[0069] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0070] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A loading traversal method for optimizing browser capabilities, characterized by: The following steps are involved: Step S1, create a browser Webview, the user calls the interface provided by the browser to send the configuration; and initialize the browser kernel; Step S2: Use the private key to encrypt the plaintext patch file, and the encrypted file is packaged into the APK. When the browser is running, it will read the encrypted patch file from the assets directory of the application, decrypt it, and restore the file to plaintext using the same private key. The browser kernel uses Chromium Vector as a cache table to store replacement rules, and stores them in three different cache tables according to the type. Step S3, calling loadUrl to trigger a network request, the browser uses the network module to establish a connection with the server to which the URL belongs, and sends a request message to the server, the request message including the request method, URL address, and request header information; The server processes the request according to the request message and returns the corresponding response message, which includes the resource files required by the web page; Step S4, the search engine will traverse its corresponding cache table to match according to the type, and then the search engine will parse the resource files respectively; Step S5, when the user switches pages or performs interactive operations, repeat steps S3 and S4 to reload and render new page content; and when the user exits the application, proceed to step S6; Step S6, when exiting the application, the system triggers the release of WebView resources and the destruction of kernel components, ending the process.

2. A loading and traversal method for optimizing browser capabilities according to claim 1, characterized in that: In step S2, the original content includes several replacement rules, and the replacement rules include type, URL, source string and target string.

3. A loading and traversal method for optimizing browser capabilities according to claim 1, characterized in that: In step S3, the resource files include HTML, CSS and JavaScript files.

4. The method for loading and traversing to optimize browser capabilities according to claim 1, characterized in that: In step S4, the search engine includes one or more of an HTML Parser, a CSS Parser and a V8 engine.

5. The method for loading and traversing to optimize browser capabilities according to claim 1, characterized in that: In step S4, the corresponding cache table is traversed according to the type for matching as follows: Step S401, determine whether the file is being processed. If it is being processed, determine whether the URL of the file matches the URL in ModifyItem successfully. If the match is successful, proceed to step S402; if the match fails, proceed to step S403; Step S402, determining whether the processed file content includes the source string in ModifyItem, if yes, replacing the source string with the target string and proceeding to step S404, if no, proceeding to step S403; Step S403: the match fails, indicating that the file does not need to be replaced; Step S404, repeating steps S401 and S402 to complete the traversal of the cache table.

6. A loading and traversal method for optimizing browser capabilities according to claim 5, characterized in that: In step S401, the condition for successful matching is whether the URL of the file is exactly the same as the URL in ModifyItem, or whether the URL of the file satisfies the matching rule defined by the URL in ModifyItem.

7. A loading and traversal method for optimizing browser capabilities according to claim 1, characterized in that: In step S6, the system calls the corresponding life cycle method to trigger the resource release and kernel component destruction of WebView, including using one or more of the onPause, onStop and onDestroy methods.

8. A loading and traversal method for optimizing browser capabilities according to claim 7, characterized in that: Triggering the release of WebView's resources and destruction of kernel components includes stopping network requests, releasing memory, closing network connections, and terminating related processes.

Citation Information

Patent Citations

  • File deleting method and file deleting device

    CN102880713A

  • Method and device for adjusting memory occupied by application program based on domain name

    CN105094977A

  • URL data mining method and system

    CN110287428A

  • Content interpolating web proxy server

    US8135860B1

  • Method for constructing runtime model of terminal application behavior

    WO2020248512A1