A data processing method, apparatus, device, and storage medium
By obtaining initialization information from the cache pool and using asynchronous child threads to obtain resource information for rendering and display, the problem of insufficient startup optimization of WKWebView is solved, and faster web page loading is achieved.
Patent Information
- Application Number
- CN202011548870.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2040-12-24
AI Technical Summary
现有技术中,WKWebView的启动优化尚未得到有效解决,导致网页显示过程中白屏时间较长。
By obtaining the initialization information of the target web page from the cache pool, using the asynchronous information intercepting instructions to generate asynchronous subthreads, obtain resource information, and render and display based on the initialization and resource information, reducing the white screen time.
It significantly reduces the white screen time during the web page display process and improves the web page loading efficiency.
Smart Images

Figure CN114676357B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technologies, and in particular, to a data processing method, apparatus, device, and storage medium. Background Art
[0002] With the development of Internet technologies and the popularization of mobile terminals, people are increasingly accustomed to obtaining various types of information from the Internet. Among these, various application programs installed on mobile terminals, in particular, have become common tools for people to obtain information. In some operating systems such as the iOS system, WebView can refer to UIWebView or WKWebView. Currently, there is only startup optimization for UIWebView to reduce the white screen time of WebView display, but there is no startup optimization for WKWebView yet. Summary of the Invention
[0003] Embodiments of this application provide a data processing method, apparatus, device, and storage medium, which can reduce the white screen time during web page display.
[0004] On the one hand, embodiments of this application provide a data processing method, which may include:
[0005] In response to a request instruction for a target web page in a target application program, obtain initialization information corresponding to the target web page from a cache pool corresponding to the target application program;
[0006] Intercept the request instruction through an asynchronous information interception instruction and generate an asynchronous sub-thread;
[0007] Obtain resource information corresponding to the request instruction through the asynchronous sub-thread;
[0008] Render and display the target web page according to the initialization information and the resource information.
[0009] In a feasible implementation manner, the intercepting the request instruction through an asynchronous information interception instruction and generating an asynchronous sub-thread includes:
[0010] Generate the asynchronous information interception instruction in an Ajax manner;
[0011] Intercept the request instruction through the asynchronous information interception instruction and generate an asynchronous sub-thread.
[0012] In a feasible implementation manner, the obtaining, through the asynchronous sub-thread, resource information corresponding to the request instruction includes:
[0013] Through the asynchronous sub-thread, determine a local file stored in a local storage space of the target application program according to the request instruction;
[0014] If there is a HyperText Markup Language file corresponding to the target web page in the local file, obtain the resource information corresponding to the request instruction according to the HyperText Markup Language file.
[0015] In a feasible implementation manner, the obtaining the resource information corresponding to the request instruction by the asynchronous sub-thread includes:
[0016] Through the asynchronous sub-thread, determine the local file stored in the local storage space of the target application according to the request instruction;
[0017] If there is no HyperText Markup Language file corresponding to the target web page in the local file, obtain the Uniform Resource Locator corresponding to the target web page according to the request instruction; obtain the resource information corresponding to the Uniform Resource Locator as the resource information corresponding to the request instruction.
[0018] In a feasible implementation manner, it further includes:
[0019] In response to a start instruction for a target application, initialize a kernel corresponding to a target web page in the target application to generate initialization information;
[0020] Store the initialization information in a cache pool.
[0021] In a feasible implementation manner, it further includes:
[0022] Obtain extension information corresponding to the target web page, where the extension information is used to render the target web page;
[0023] Inject the extension information into the initialization information to obtain the initialization information after information injection.
[0024] In a feasible implementation manner, it further includes:
[0025] In response to an end instruction for a target web page in a target application, remove the extension information corresponding to the target web page from the target web page to obtain the information after information removal, and use the information after information removal as the initialization information corresponding to the target web page;
[0026] When the number of initialization information in the cache pool is less than a quantity threshold, store the initialization information corresponding to the target web page in the cache pool.
[0027] In a feasible implementation manner, it further includes:
[0028] When the number of initialization information in the cache pool is greater than or equal to the quantity threshold, destroy the initialization information corresponding to the target application according to the cache time of the initialization information in the cache pool.
[0029] One aspect of the embodiments of the present application provides a data processing device, which may include:
[0030] A request instruction response unit, configured to, in response to a request instruction for a target web page in a target application, obtain initialization information corresponding to the target web page from a cache pool corresponding to the target application;
[0031] A thread generation unit, configured to intercept the request instruction through an asynchronous information interception instruction and generate an asynchronous sub-thread;
[0032] An information acquisition unit, configured to obtain resource information corresponding to the request instruction through the asynchronous sub-thread;
[0033] A web page display unit, configured to render and display the target web page according to the initialization information and the resource information.
[0034] In a feasible implementation manner, the thread generation unit includes:
[0035] An instruction interception subunit, configured to generate the asynchronous information interception instruction by means of Ajax;
[0036] A thread generation subunit, configured to intercept the request instruction through the asynchronous information interception instruction and generate an asynchronous sub-thread.
[0037] In a feasible implementation manner, the thread generation subunit is specifically configured to:
[0038] Through the asynchronous sub-thread, determine a local file stored in the local storage space of the target application according to the request instruction;
[0039] If there is a hypertext markup language file corresponding to the target web page in the local file, obtain the resource information corresponding to the request instruction according to the hypertext markup language file.
[0040] In a feasible implementation manner, the thread generation subunit is specifically configured to:
[0041] Through the asynchronous sub-thread, determine a local file stored in the local storage space of the target application according to the request instruction;
[0042] If the HyperText Markup Language file corresponding to the target web page does not exist in the local file, obtain the Uniform Resource Locator corresponding to the target web page according to the request instruction; obtain the resource information corresponding to the Uniform Resource Locator as the resource information corresponding to the request instruction.
[0043] In a feasible implementation manner, it further includes:
[0044] An initialization information generation unit, configured to initialize a kernel corresponding to a target web page in the target application in response to a startup instruction for the target application, and generate initialization information;
[0045] Store the initialization information in a cache pool.
[0046] In a feasible implementation manner, it further includes:
[0047] An information injection unit, configured to obtain extension information corresponding to the target web page, where the extension information is used to render the target web page;
[0048] Inject the extension information into the initialization information to obtain the initialization information after information injection.
[0049] In a feasible implementation manner, it further includes:
[0050] An information storage unit, configured to, in response to an end instruction for the target web page in the target application, remove the extension information corresponding to the target web page from the target web page to obtain the information after information removal, and use the information after information removal as the initialization information corresponding to the target web page;
[0051] When the number of initialization information in the cache pool is less than the number threshold, store the initialization information corresponding to the target web page in the cache pool.
[0052] In a feasible implementation manner, it further includes:
[0053] An information destruction unit, configured to, when the number of initialization information in the cache pool is greater than or equal to the number threshold, destroy the initialization information corresponding to the target application according to the cache time of the initialization information in the cache pool.
[0054] An embodiment of the present application provides a computer-readable storage medium on the one hand. A computer program is stored in the computer-readable storage medium, and the computer program is adapted to be loaded and executed by a processor to perform the above method steps.
[0055] One aspect of the embodiments of the present application provides a computer device, including a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the above method steps.
[0056] One aspect of the embodiments of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above method steps.
[0057] In the embodiments of the present application, in response to a request instruction for a target web page in a target application, initialization information corresponding to the target web page is obtained from a cache pool corresponding to the target application. Further, the request instruction is intercepted by an asynchronous information interception instruction, and an asynchronous sub-thread is generated. The resource information corresponding to the request instruction is obtained through the asynchronous sub-thread. Finally, the target web page is rendered and displayed according to the initialization information and the resource information. By introducing the cache pool and asynchronously obtaining the resource information corresponding to the request instruction to render the target web page, the blank screen time during the web page display is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0059] Figure 1 It is a system architecture diagram of data processing provided by the embodiments of the present application;
[0060] Figure 2 It is a flow schematic diagram of a data processing method provided by the embodiments of the present application;
[0061] Figure 3 It is a flow schematic diagram of a data processing method provided by the embodiments of the present application;
[0062] Figure 4 It is an example schematic diagram of a data processing method provided by the embodiments of the present application;
[0063] Figure 5 It is a schematic diagram of the structure of a terminal device provided by the embodiments of the present application;
[0064] Figure 6It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0065] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0066] Please refer to Figure 1 , which is a system architecture diagram of data processing provided by an embodiment of the present invention. The server 10f establishes a connection with the user terminal cluster through the switch 10e and the communication bus 10d. The user terminal cluster may include: user terminal 10a, user terminal 10b,..., user terminal 10c. The method in this solution can be applied to the web page startup of the user terminal. Specifically, the user terminal responds to a request instruction for a target web page in the target application program. The user terminal obtains the initialization information corresponding to the target web page from the cache pool corresponding to the target application program, injects information into the initialization information, intercepts the request instruction through an asynchronous information interception instruction, and generates an asynchronous sub-thread. The resource information corresponding to the request instruction is obtained according to the asynchronous sub-thread, and the target web page is rendered and displayed according to the initialization information and the resource information after information injection. The above user terminal can be any one in the user terminal cluster.
[0067] The user terminals involved in the embodiments of the present application include: terminal devices such as tablet computers, smart phones, personal computers (PCs), notebook computers, and palm computers.
[0068] Please refer to Figure 2 , which is a schematic flowchart of a data processing method provided by an embodiment of the present application. This method can be applied to the above terminal devices, such as Figure 2 As shown, the method of the embodiment of the present application may include the following steps S101-step S104.
[0069] S101, in response to a request instruction for a target web page in a target application program, obtain the initialization information corresponding to the target web page from the cache pool corresponding to the target application program;
[0070] Specifically, the terminal device responds to a request instruction for a target web page in the target application program. It can be understood that the terminal device can be Figure 1In the user terminal, the target application can be any application in the user terminal. For example, the target application can be a video application, a social application, etc., and the embodiments of the present application do not limit this. The target web page can be any web page included in the target application, and the request instruction can be a start instruction for the target web page in the target application, specifically, it can be a click instruction or a touch instruction on the touch screen.
[0071] For example, the target application can be a video application, the target web page is the membership recharge page in the video application, and the request instruction can be the user's membership recharge instruction. Specifically, the user clicks the membership recharge entry in the video application, and the terminal device renders the membership recharge page according to the above click instruction and finally jumps to the membership recharge page.
[0072] Further, the terminal device obtains the initialization information corresponding to the target web page from the cache pool corresponding to the target application. The above initialization information is the initialization web page template corresponding to the target web page. For example, the initialization web page template can be an initialized WKWebView or an initialized UIWebView. After injecting information into the initialization web page template, the initialization information after injecting the information is further rendered by the rendering engine to generate the target web page. It can be understood that one or more web page initialization information can be stored in the cache pool. Injecting information into the initialization information means adding the extension information corresponding to the target web page to the initialization information. The initialization information after injecting the information is used to render the target web page so that the display interface of the user terminal displays the target web page. The above extension information includes cookie information, interface information, and delegate functions, etc. Specifically, the above cookie information can be the user's account information. After injecting the cookie information into the above initialization information, the user's login status will be displayed on the display page of the target web page. The above interface information can be the channel information for communication between the web page in the target application and the target application client, and the above delegate function can implement information processing for multiple target web pages in the target application. For example, there are multiple left and right sliding sub-windows in the target application, and the information in the above multiple sub-windows can be refreshed through the delegate function.
[0073] S102, intercept the request instruction through an asynchronous information interception instruction and generate an asynchronous sub-thread;
[0074] Specifically, the terminal device intercepts the request instruction through the asynchronous information interception instruction and generates an asynchronous sub-thread. Through the asynchronous sub-thread, the resource information corresponding to the request instruction can be obtained. It can be understood that the asynchronous information interception instruction is an instruction for intercepting the target web page request instruction, and specifically, it can be an instruction generated by the Asynchronous Javascript And XML (AJAX) method. Ajax is a web development technology for creating interactive and fast dynamic web applications and can be used for the startup and update of web pages. The terminal device intercepts the request instruction through the asynchronous information interception instruction, and after the interception, an asynchronous sub-thread is initiated in the process to request the resource information of the target web page through the above asynchronous sub-thread.
[0075] S103, obtaining the resource information corresponding to the request instruction through the asynchronous sub-thread;
[0076] Specifically, the resource information includes information such as Hyper Text Markup Language (HTML) files, JS / CSS, font files, and template files. If the target web page in the target application is opened for the first time, all resource information will be loaded. If the target web page in the target application is not opened for the first time, the html file stored locally for the target web page will be loaded, and then the resource information in the html file will be obtained. It should be noted that if the resource information in the html file is updated, the target web page can be partially updated according to the front end. Specifically, the resource information in the html file is compared with the corresponding tag tags for page rendering in the front end. The specific comparison method can use the diff algorithm for detection. If it is detected that there is partial update of the resource information, the target web page is partially updated according to the detected updated resource information.
[0077] S104, rendering and displaying the target web page according to the initialization information and resource information after information injection.
[0078] Specifically, the terminal device renders and displays the target web page according to the initialization information and resource information after information injection. It can be understood that the terminal device parses the html file in the resource information to generate a tree-shaped data structure DOM tree, parses the CSS information in the resource information to generate a rule tree, and calls the code execution engine. The code execution engine is used to execute the JS code, generates a presentation tree corresponding to the target web page from the DOM tree and the rule tree, performs page rendering on the information of each node in the presentation tree and the initialization information after information injection to generate the target web page, and finally displays the target web page in the display interface of the user terminal.
[0079] In an embodiment of the present application, in response to a request instruction for a target web page in a target application, initialization information corresponding to the target web page is obtained from a cache pool corresponding to the target application. Further, the request instruction is intercepted by an asynchronous information interception instruction, and an asynchronous sub-thread is generated. The resource information corresponding to the request instruction is obtained through the asynchronous sub-thread. Finally, the target web page is rendered and displayed according to the initialization information and the resource information. By introducing a cache pool and asynchronously obtaining the resource information corresponding to the request instruction to render the target web page, the blank screen time during the web page display process is reduced.
[0080] Please refer to Figure 3 , which is a schematic flowchart of a data processing method provided by an embodiment of the present application. This method can be applied to the above terminal device, such as Figure 3 shown, the method of the embodiment of the present application may include the following steps S201-step S208.
[0081] S201, in response to a start instruction for a target application, initialize the kernel corresponding to a target web page in the target application to generate initialization information; store the initialization information in a cache pool.
[0082] Specifically, the terminal device responds to a start instruction for a target application, initializes the kernel corresponding to a target web page in the target application to generate initialization information, and stores the initialization information in a cache pool. It can be understood that the terminal device can be Figure 1 the user terminal in, and the start instruction is used to start the target application. The start instruction can specifically be a click instruction or a touch instruction on the touch screen. When the terminal device obtains the start instruction for the target application, it initializes the kernel corresponding to the target web page in the target application. The kernel corresponding to the target network is responsible for interpreting web page syntax (such as HTML, JavaScript) and rendering the web page in the target application, and finally displays the web page in the target application, that is, the target application parses and renders the web page through the kernel. After initializing the kernel corresponding to the target web page, initialization information is generated and stored in the cache pool. The cache pool is used to store the initialization information corresponding to the web page in the application. It should be noted that the cache pool can store the initialization information of multiple web pages, and the number of initialization information can be changed according to the memory occupancy status of the cache pool or set by the user.
[0083] S202, in response to a request instruction for a target web page in the target application, obtain the initialization information corresponding to the target web page from the cache pool corresponding to the target application;
[0084] Among them, for step S201 of the embodiment of the present invention, please refer toFigure 1 The specific description of step S101 of the illustrated embodiment will not be elaborated here.
[0085] S203. Obtain the extension information corresponding to the target web page, where the extension information is used to render the target web page; inject the extension information into the initialization information to obtain the initialization information after information injection.
[0086] Specifically, the terminal device obtains the web page identifier of the target web page and obtains the initialization information with the web page identifier from the cache pool corresponding to the target application. It can be understood that the cache pool may store the initialization information of one or more web pages, and each initialization information corresponds to a web page identifier. Obtaining the initialization information with the above web page identifier from the cache pool means that the above initialization information is the initialization information corresponding to the target web page. Further, information injection is performed on the initialization information to obtain the initialization information after information injection, that is, the extension information corresponding to the target web page is added to the initialization information. The extension information is an interface definition for information display and information communication during the rendering process of the target page. The extension information includes cookie information, interface information such as JavaScript Application Programming Interface (JSAPI), and delegate functions, etc. The initialization information after information injection is used to render the target web page so that the display interface of the user terminal displays the target web page.
[0087] S204. Detect the target communication protocol corresponding to the request instruction.
[0088] Specifically, the terminal device detects the target communication protocol corresponding to the request instruction. It can be understood that the communication protocol set stores pre-agreed communication protocols, such as http. The communication protocol set includes at least one communication protocol. If the target communication protocol corresponding to the request instruction exists in the communication protocol set, then the display of the above target web page is within the pre-agreed communication range, that is, the rendering display of the above target web page can be performed, and step S205 is executed. By detecting whether the target communication protocol of the request instruction exists in the communication protocol set, customized processing can be performed for different communication protocols, that is, the method in this solution can be used for the web page rendering using the communication protocols in the communication protocol set, reducing the blank screen time during the web page display process. It should be noted that the communication protocols in the above communication protocol set can be changed, or no restrictions are imposed on the communication protocols.
[0089] S205. Generate the asynchronous information interception instruction in an Ajax manner, and obtain the resource information corresponding to the request instruction through the asynchronous sub-thread.
[0090] Specifically, the terminal device intercepts the request instruction in an ajax manner. It should be noted that when the terminal device sends a request instruction to the server, there may be a problem that the request body (such as POSTBODY) corresponding to the request instruction is lost. Therefore, a JS script file is injected during the interception of the request instruction in the ajax manner. The above JS script file can retrieve the lost request body and reduce the response time of the page display. Further, the local files in the local storage space of the target application are detected according to the request instruction; if the target web page in the target application is opened for the first time, that is, the html file corresponding to the target web page does not exist in the local files, the uniform resource locator corresponding to the target web page is obtained according to the request instruction, and the uniform resource locator is parsed to obtain the resource information corresponding to the request instruction. The resource information may include information such as html files, JS / CSS, font files, and template files. If the target web page in the target application is not opened for the first time, that is, the html file corresponding to the target web page exists in the local files, the html file is obtained from the local storage space, and the resource information corresponding to the request instruction is obtained according to the html file. It should be noted that if the resource information in the html file is updated, the target web page can be partially updated according to the front end. Specifically, the resource information in the html file is compared with the corresponding tag labels rendered on the front-end page. The specific comparison method can be detected using the diff algorithm. If it is detected that the resource information is partially updated, the target web page is partially updated according to the detected updated resource information.
[0091] S206. Render and display the target web page according to the initialization information and the resource information.
[0092] Specifically, the terminal device generates a DOM tree and a rule tree corresponding to the target web page according to the resource information, calls the code execution engine, and generates a presentation tree corresponding to the target web page from the DOM tree and the rule tree; the initialization information after information injection is rendered according to the presentation tree to generate the target web page, and the target web page is displayed on the display interface.
[0093] Specifically, the terminal device parses the html file in the resource information to generate a tree-shaped data structure DOM tree, parses the CSS information in the resource information to generate a rule tree, and calls the code execution engine. The code execution engine is used to execute JS code, generates a presentation tree corresponding to the target web page from the DOM tree and the rule tree, renders the information of each node in the presentation tree and the initialization information after information injection to generate the target web page, and finally displays the target web page on the display interface of the user terminal. By introducing from the cache pool and asynchronously obtaining the resource information corresponding to the request instruction, the blank screen time during the web page display is reduced. Please refer to Table 1. When opening web pages in different applications, the blank screen time (unit: second) before and after optimizing with this solution is shown in the following table.
[0094] White screen time of Table 1 web page
[0095] Application A Application B Application C Application D Time before optimization / s 1.341s 0.675s 0.261s 0.335s Time after optimization / s 0.471s 0.358s 0.306s 0.213s
[0096] As can be seen from the above table, after the application is optimized by the method of this solution, the white screen time during the web page display process is significantly reduced compared to the white screen time before optimization. That is, by using this solution for web page rendering, the white screen time during the web page display process can be reduced.
[0097] S207. In response to an end instruction for a target web page in a target application, remove the extension information corresponding to the target web page from the target web page to obtain the information after the information removal, and use the information after the information removal as the initialization information corresponding to the target web page; when the number of initialization information in the cache pool is less than the number threshold, store the initialization information corresponding to the target web page in the cache pool.
[0098] Specifically, the terminal device responds to an end instruction for a target web page in a target application. The end instruction is a close instruction for the target web page. It should be noted that the target application can be in a running state. The terminal device removes the extension information corresponding to the target web page from the target web page to obtain the information after removal, and uses the information after removal as the initialization information corresponding to the target web page, that is, after removing the extension information corresponding to the target web page, the initialization information corresponding to the target web page is obtained again. The initialization information corresponding to the target web page can be used to render the target web page to generate the target web page. The above extension information includes cookie information, interface information, delegate functions, etc. Further, the initialization information of the target web page can be stored in a cache pool, and the initialization information in the cache pool can be reused. Specifically, when the target web page is opened again, that is, a request instruction corresponding to the target web page is obtained, the above initialization information corresponding to the target web page is obtained from the cache pool, the extension information corresponding to the target web page is obtained, and the initialization information is injected to obtain the initialization information after information injection. The request instruction is intercepted through an asynchronous information interception instruction, and an asynchronous sub-thread is generated. Further, the resource information corresponding to the request instruction is obtained through the asynchronous sub-thread. Finally, the target web page is rendered and displayed according to the initialization information after information injection and the resource information. When the web page is closed, that is, a close instruction for the target web page is obtained, the extension information corresponding to the target web page can be removed from the target web page to obtain the information after removal, and the information after removal is the initialization information corresponding to the target web page. Thus, the automatic recycling of the initialization information corresponding to the target web page is realized. Through the cache pool, the corresponding initialization information can be directly obtained when the target web page is opened next time, improving the web page opening efficiency and reducing the blank screen time during the web page display process. It should be noted that the number of initialization information in the cache pool can be set. Specifically, the number of initialization information in the cache pool is detected, and when the number is less than the number threshold, the initialization information is stored in the cache pool.
[0099] S208. When the number of initialization information in the cache pool is greater than or equal to the number threshold, the initialization information corresponding to the target application is destroyed according to the cache time of the initialization information in the cache pool.
[0100] When the quantity is greater than or equal to the quantity threshold, in response to a clearing instruction for the cache pool corresponding to the target application, the initialization information corresponding to the target application is destroyed according to the caching time of the initialization information in the cache pool. The caching time of the initialization information is the time when the initialization information is stored in the cache pool. Specifically, when the quantity of the initialization information in the cache pool is greater than or equal to the quantity threshold, the initialization information can be partially destroyed according to the caching time of the initialization information in the cache pool. For example, the initialization information with a caching time before a certain time point is destroyed. It should be noted that the clearing instruction of the cache pool can be actively triggered by the user. Through the above recycling process of the cache pool, the cache pool can be efficiently utilized while ensuring its stable operation.
[0101] Please refer to Figure 4 , which provides a schematic structural diagram of a terminal device according to an embodiment of the present application. As Figure 4 shown, the user terminal obtains a startup instruction for the target application, further initializes the kernel corresponding to the target web page in the target application to generate initialization information, stores the initialization information in the cache pool, obtains a request instruction for the target web page in the target application, obtains the initialization information corresponding to the target web page from the cache pool corresponding to the target application, and injects the cookie information and interface information corresponding to the target web page into the initialization information. The request instruction is intercepted in an Ajax manner, and an asynchronous sub-thread is generated. The user terminal obtains the resource information corresponding to the request instruction according to the request instruction and the asynchronous sub-thread, renders and displays the target web page according to the initialization information and the resource information after information injection, obtains an end instruction for the target web page in the target application, removes the cookie information and interface information corresponding to the target web page from the target web page, generates the initialization information corresponding to the target web page, and stores the initialization information in the cache pool. The web page display in the above user terminal can be WKWebView display. The existing optimization of web page display is mainly for UIWebView display. During the initialization process of WebView, the page is loaded from the server in parallel at the same time to achieve the display of WebView. However, since WKWebView is an independent process, the above method cannot be directly used for asynchronous interception and processing, resulting in a longer white screen time during the web page display process. Therefore, by using the method in this solution, the display of WKWebView is achieved by obtaining the initialization information corresponding to the target web page from the cache pool and obtaining the resource information corresponding to the request instruction through an asynchronous information interception instruction, reducing the white screen time during the web page display process.
[0102] In an embodiment of the present application, in response to a request instruction for a target web page in a target application, initialization information corresponding to the target web page is obtained from a cache pool corresponding to the target application. Further, the request instruction is intercepted by an asynchronous information interception instruction, and an asynchronous sub-thread is generated. The resource information corresponding to the request instruction is obtained through the asynchronous sub-thread. Finally, the target web page is rendered and displayed according to the initialization information and the resource information. By introducing a cache pool and asynchronously obtaining the resource information corresponding to the request instruction to render the target web page, the white screen time during the web page display process is reduced.
[0103] Please refer to Figure 5 , which is a schematic structural diagram of a data processing device provided by an embodiment of the present application. The data processing device may be a computer program (including program code) running in a computer device. For example, the data processing device is an application software; the device may be used to execute the corresponding steps in the method provided by the embodiment of the present application. As Figure 5 shown, the data processing device 1 in the embodiment of the present application may include: a request instruction response unit 11, a thread generation unit 12, an information acquisition unit 13, and a web page display unit 14.
[0104] The request instruction response unit 11 is configured to, in response to a request instruction for a target web page in a target application, obtain initialization information corresponding to the target web page from a cache pool corresponding to the target application;
[0105] The thread generation unit 12 is configured to intercept the request instruction by an asynchronous information interception instruction and generate an asynchronous sub-thread;
[0106] The information acquisition unit 13 is configured to obtain resource information corresponding to the request instruction through the asynchronous sub-thread;
[0107] The web page display unit 14 is configured to render and display the target web page according to the initialization information and the resource information.
[0108] Please refer to Figure 5 , the thread generation unit 12 in the embodiment of the present application may include: an instruction interception subunit 121 and a thread generation subunit 122.
[0109] The instruction interception subunit 121 is configured to generate the asynchronous information interception instruction by an Ajax method;
[0110] The thread generation subunit 122 is configured to intercept the request instruction by the asynchronous information interception instruction and generate an asynchronous sub-thread.
[0111] In a feasible implementation manner, the thread generation subunit 122 is specifically configured to:
[0112] Through the asynchronous sub-thread, determine the local files stored by the target application in the local storage space according to the request instruction;
[0113] If there is a HyperText Markup Language file corresponding to the target web page in the local files, obtain the resource information corresponding to the request instruction according to the HyperText Markup Language file.
[0114] In a feasible implementation manner, the thread generation subunit 122 is specifically configured to:
[0115] Through the asynchronous sub-thread, determine the local files stored by the target application in the local storage space according to the request instruction;
[0116] If there is no HyperText Markup Language file corresponding to the target web page in the local files, obtain the Uniform Resource Locator corresponding to the target web page according to the request instruction; obtain the resource information corresponding to the Uniform Resource Locator as the resource information corresponding to the request instruction.
[0117] Please refer to Figure 5 , the data processing device 1 according to the embodiment of the present application may include: an initialization information generation unit 15.
[0118] The initialization information generation unit 15 is configured to initialize the kernel corresponding to the target web page in the target application in response to a startup instruction for the target application, and generate initialization information;
[0119] Store the initialization information in the cache pool.
[0120] Please refer to Figure 5 , the data processing device 1 according to the embodiment of the present application may include: an information injection unit 16.
[0121] The information injection unit 15 is configured to obtain the extension information corresponding to the target web page, where the extension information is used to render the target web page;
[0122] Inject the extension information into the initialization information to obtain the initialization information after information injection.
[0123] Please refer to Figure 5 , the data processing device 1 according to the embodiment of the present application may include: an information storage unit 17.
[0124] An information storage unit 17, configured to, in response to an end instruction for a target web page in a target application, remove the extension information corresponding to the target web page from the target web page to obtain information after removal, use the information after removal as the information after removal, and use the information after removal as the initialization information corresponding to the target web page;
[0125] When the number of initialization information in the cache pool is less than a quantity threshold, store the initialization information corresponding to the target web page in the cache pool.
[0126] Please refer to Figure 5 , the data processing device 1 according to the embodiment of the present application may include: an information storage unit 18.
[0127] An information destruction unit 18, configured to, when the number of initialization information in the cache pool is greater than or equal to the quantity threshold, destroy the initialization information corresponding to the target application according to the cache time of the initialization information in the cache pool.
[0128] In the embodiment of the present application, by responding to a request instruction for a target web page in a target application, obtaining the initialization information corresponding to the target web page from the cache pool corresponding to the target application, further intercepting the request instruction through an asynchronous information interception instruction and generating an asynchronous sub-thread, obtaining the resource information corresponding to the request instruction through the asynchronous sub-thread, and finally rendering and displaying the target web page according to the initialization information and the resource information. Through the introduction of the cache pool and asynchronously obtaining the resource information corresponding to the request instruction to render the target web page, the white screen time during the web page display process is reduced.
[0129] Please refer to Figure 6 , which is a schematic structural diagram of a computer device provided by an embodiment of the present application. As Figure 6As shown in the figure, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), and optionally the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a random access memory (Random Access Memory, RAM), or a non-volatile memory (non-volatile memory, NVM), such as at least one disk memory. The memory 1005 may optionally be at least one storage device located far from the aforementioned processor 1001. As Figure 6 shown, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a data processing application program.
[0130] In Figure 6 the computer device 1000 shown in the figure, the network interface 1004 can provide network communication functions, and the user interface 1003 is mainly used to provide an input interface for users; while the processor 1001 can be used to call the data processing application program stored in the memory 1005 to implement the above Figures 2 - 4 description of the data processing method in any one of the corresponding embodiments, which will not be elaborated here.
[0131] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method in any one of the previous Figures 2 - 4 corresponding embodiments, and can also execute the description of the data processing device in the previous Figure 5 corresponding embodiments, which will not be elaborated here. In addition, the description of the beneficial effects of adopting the same method will not be elaborated either.
[0132] In addition, it should be pointed out here that: the embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the aforementioned data processing device, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the previous Figures 2 - 4Any description of the data processing method in the corresponding embodiments will not be repeated here. In addition, the beneficial effects of using the same method will not be described again. For the technical details not disclosed in the embodiments of the computer-readable storage medium involved in this application, please refer to the description of the method embodiments of this application. As an example, the program instructions can be deployed to be executed on one computing device, or on multiple computing devices located at one location, or, on multiple computing devices distributed at multiple locations and interconnected through a communication network. The multiple computing devices distributed at multiple locations and interconnected through a communication network can form a blockchain system.
[0133] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, NVM or RAM, etc.
[0134] The foregoing disclosure is only for the preferred embodiments of this application, and of course cannot be used to limit the scope of rights of this application. Therefore, equivalent changes made according to the claims of this application still fall within the scope covered by this application.
Claims
1. A data processing method, characterized in that, Including: In response to a request instruction for a target web page in a target application, obtain initialization information corresponding to the target web page from a cache pool corresponding to the target application, where the initialization information is an initialization web page template corresponding to the target web page; Obtain extension information corresponding to the target web page, where the extension information is used to render the target web page, inject the extension information into the initialization information to obtain the initialization information after information injection, and the extension information includes the user's account information, channel information for communication between the web page in the target application and the target application client, and a function for implementing information processing of the target web page in the target application; Intercept the request instruction through an asynchronous information interception instruction and generate an asynchronous sub-thread; Obtain resource information corresponding to the request instruction through the asynchronous sub-thread, where the resource information includes a hypertext markup language file, JS / CSS, a font file, or a template file; Parse the hypertext markup language file in the resource information to generate a tree-shaped data structure DOM tree, parse the CSS information in the resource information to generate a rule tree, call a code execution engine to execute JS code, generate a presentation tree corresponding to the target web page from the DOM tree and the rule tree, perform page rendering on the information of each node in the presentation tree and the initialization information after information injection to generate the target web page, and display the target web page.
2. The method according to claim 1, wherein The intercepting the request instruction through the asynchronous information interception instruction and generating an asynchronous sub-thread includes: Generate the asynchronous information interception instruction in an Ajax manner; Intercept the request instruction through the asynchronous information interception instruction and generate an asynchronous sub-thread.
3. The method according to claim 1 or 2, characterized in that, The obtaining the resource information corresponding to the request instruction through the asynchronous sub-thread includes: Through the asynchronous sub-thread, determine a local file stored in the local storage space of the target application according to the request instruction; If a hypertext markup language file corresponding to the target web page exists in the local file, obtain the resource information corresponding to the request instruction according to the hypertext markup language file.
4. The method according to claim 1 or 2, characterized in that, The obtaining the resource information corresponding to the request instruction through the asynchronous sub-thread includes: Through the asynchronous sub-thread, determine a local file stored in the local storage space of the target application according to the request instruction; If a hypertext markup language file corresponding to the target web page does not exist in the local file, obtain a uniform resource locator corresponding to the target web page according to the request instruction; obtain the resource information corresponding to the uniform resource locator as the resource information corresponding to the request instruction.
5. The method according to claim 1, characterized in that, Also including: In response to a start instruction for a target application, initialize a kernel corresponding to a target web page in the target application to generate initialization information; Store the initialization information in a cache pool.
6. The method according to claim 1, characterized in that, Also including: In response to an end instruction for a target web page in a target application, remove the extension information corresponding to the target web page from the target web page to obtain the information after the information removal, and use the information after the information removal as the initialization information corresponding to the target web page; When the number of initialization information in the cache pool is less than the number threshold, store the initialization information corresponding to the target web page in the cache pool.
7. A data processing device, characterized in that, It includes: A request instruction response unit, configured to, in response to a request instruction for a target web page in a target application, obtain the initialization information corresponding to the target web page from the cache pool corresponding to the target application, where the initialization information is an initialization web page template corresponding to the target web page; An information injection unit, configured to obtain the extension information corresponding to the target web page, where the extension information is used to render the target web page, inject the extension information into the initialization information to obtain the initialization information after the information injection, and the extension information includes the user's account information, the channel information for communication between the web page in the target application and the target application client, and a function for implementing information processing on the target web page in the target application; A thread generation unit, configured to intercept the request instruction through an asynchronous information interception instruction and generate an asynchronous sub-thread; An information acquisition unit, configured to obtain the resource information corresponding to the request instruction through the asynchronous sub-thread, where the resource information includes a hypertext markup language file, a JS / CSS, a font file, or a template file; A web page display unit, configured to parse the hypertext markup language file in the resource information to generate a tree-shaped data structure DOM tree, parse the CSS information in the resource information to generate a rule tree, call a code execution engine to execute JS code, generate a presentation tree corresponding to the target web page from the DOM tree and the rule tree, perform page rendering on the information of each node in the presentation tree and the initialization information after the information injection to generate the target web page, and display the target web page.
8. A computer device, characterized in that, It is characterized in that it includes: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and the computer program is adapted to be loaded and executed by a processor to perform the method according to any one of claims 1-6.
Citation Information
Patent Citations
Page display method and device, electronic equipment and storage medium
CN110221889A