Browser subpage creation method, device, computer equipment and storage medium

By creating a subpage instance in the main thread of the browser component and creating a window interface in the user interface thread, the thread safety problem when creating browser subpages is solved, and efficient and stable subpage generation is achieved.

CN111783019BActive Publication Date: 2025-09-05TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010772290.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-04
Publication Date
2025-09-05
Estimated Expiration
2040-08-04

AI Technical Summary

Technical Problem

In the prior art, thread safety issues are easily caused when creating browser subpages, especially when synchronously creating subpage windows in the Cef main thread, which may cause deadlock and multi-threaded access problems.

Method used

By calling the sub-page callback interface in the main thread of the browser component to create a sub-page instance, and creating the sub-page window interface in the user interface thread, it is avoided to operate the user interface elements in the main thread, and the sub-page instance and window are created separately.

Benefits of technology

It effectively ensures thread safety when creating browser subpages, improves generation efficiency and stability, and avoids deadlock and multi-threaded access problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111783019B_ABST
    Figure CN111783019B_ABST
Patent Text Reader

Abstract

The present application relates to a method, apparatus, computer equipment and storage medium for creating a browser subpage. The method obtains a subpage creation request corresponding to a browser component in an application; based on the subpage creation request, calls a subpage callback interface in the main thread of the browser component to create a page instance of the subpage; when the page instance of the subpage is created, creates a window interface of the subpage through the user interface thread of the application; and creates a browser subpage based on the page instance of the subpage and the window interface of the subpage. The present application directly generates the required subpage instance of the browser subpage in the main thread of the browser component only through the subpage callback interface, but does not operate the interface elements of the user interface. Instead, it operates the interface elements of the user interface in the user interface thread, separates the subpage instance and the subpage window to create the browser subpage, and can effectively ensure thread safety when creating the browser subpage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for creating a browser subpage. Background Art

[0002] With the development of computer technology, browser component technology has emerged. Browsers are applications used to retrieve, display, and deliver information resources on the World Wide Web (WWW). Browser components are used to add browser functionality to applications. Currently, most desktop applications use Cef (Chromium Embedded Framework) as their browser components. Cef is an open source browser control based on the Google Chromium project. Using this component, developers can add web browsing capabilities to their applications.

[0003] When Cef pops up a child window, it triggers a callback function in the Cef main thread. The client parameter, as the child window instance, must be synchronously returned to the parent window in this callback function; otherwise, the parent and child pages will be unable to communicate. However, if the application's UI (User Interface) thread and Cef's main thread are different threads, and the interface windows are maintained on the UI thread, synchronously popping up the window in the callback function will cause a series of thread safety issues.

[0004] In the existing technology, the sub-page window can be created and displayed synchronously in the Cef main thread. This solution requires operating the UI object in the Cef main thread, but the Cef main thread may throw messages to the UI thread for processing, and the UI thread may also wait for the Cef main thread to process certain logic, which may cause deadlock security issues. Summary of the Invention

[0005] Based on this, it is necessary to provide a browser subpage creation method, device, computer equipment and storage medium that can effectively ensure thread safety when creating browser subpages to address the above technical problems.

[0006] A method for creating a browser subpage, the method comprising:

[0007] Get the sub-page creation request corresponding to the browser component in the application;

[0008] According to the sub-page creation request, calling the sub-page callback interface in the main thread of the browser component to create a page instance of the sub-page;

[0009] When the page instance of the sub-page is created, a window interface of the sub-page is created through the user interface thread of the application;

[0010] A browser subpage is created based on the page instance of the subpage and the window interface of the subpage.

[0011] A browser subpage creation device, characterized in that the device comprises:

[0012] The request acquisition module is used to obtain the sub-page creation request corresponding to the browser component in the application;

[0013] An instance creation module is used to call the sub-page callback interface in the main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page;

[0014] A window creation module, configured to create a window interface of the sub-page through the user interface thread of the application when the page instance of the sub-page is created;

[0015] The sub-page creation module is used to create a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page.

[0016] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0017] Get the sub-page creation request corresponding to the browser component in the application;

[0018] According to the sub-page creation request, calling the sub-page callback interface in the main thread of the browser component to create a page instance of the sub-page;

[0019] When the page instance of the sub-page is created, a window interface of the sub-page is created through the user interface thread of the application;

[0020] A browser subpage is created based on the page instance of the subpage and the window interface of the subpage.

[0021] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0022] Get the sub-page creation request corresponding to the browser component in the application;

[0023] According to the sub-page creation request, calling the sub-page callback interface in the main thread of the browser component to create a page instance of the sub-page;

[0024] When the page instance of the sub-page is created, a window interface of the sub-page is created through the user interface thread of the application;

[0025] A browser subpage is created based on the page instance of the subpage and the window interface of the subpage.

[0026] The above-mentioned browser subpage creation method, device, computer equipment and storage medium obtain a subpage creation request corresponding to the browser component in the application; according to the subpage creation request, call the subpage callback interface in the main thread of the browser component to create a page instance of the subpage; when the page instance of the subpage is created, create the window interface of the subpage through the user interface thread of the application; and create a browser subpage based on the page instance of the subpage and the window interface of the subpage. The present application directly generates the required subpage instance of the browser subpage in the main thread of the browser component only through the subpage callback interface, but does not operate the interface elements of the user interface. Instead, it operates the interface elements of the user interface in the user interface thread, separates the subpage instance and the subpage window to create the browser subpage, and can effectively ensure thread safety when creating the browser subpage. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A schematic diagram of a process for creating a browser subpage in one embodiment;

[0028] Figure 2 A schematic flow chart of a method for creating a browser subpage in another embodiment;

[0029] Figure 3 A schematic diagram of a flow chart of steps for creating a sub-page window interface in one embodiment;

[0030] Figure 4 A schematic diagram of a flow chart of steps for generating a browser subpage in one embodiment;

[0031] Figure 5 A schematic flow chart of the steps of pre-generating a browser subpage corresponding to a target subpage link in one embodiment;

[0032] Figure 6 A flowchart illustrating the steps of destroying a generated browser subpage in one embodiment;

[0033] Figure 7 A flowchart of a method for creating a browser subpage in another embodiment is shown;

[0034] Figure 8 A structural block diagram of a browser subpage creation device in one embodiment;

[0035] Figure 9FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0037] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0038] The browser subpage creation method provided in this application can be applied to a terminal. The terminal obtains a subpage creation request corresponding to a browser component in an application; based on the subpage creation request, the terminal calls the subpage callback interface in the main thread of the browser component to create a page instance of the subpage; when the page instance of the subpage is created, the window interface of the subpage is created through the user interface thread of the application; and based on the page instance of the subpage and the window interface of the subpage, a browser subpage is created. Among them, the terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. It is understood that this method can also be applied to servers, and can also be applied to systems including terminals and servers, and is implemented through the interaction between the terminal and the server.

[0039] In one embodiment, Figure 1 As shown, a method for creating a browser subpage is provided, which is described by taking the method applied to a terminal as an example. The method includes the following steps:

[0040] Step 102: Obtain a sub-page creation request corresponding to the browser component in the application.

[0041] Applications specifically include desktop applications. A browser component refers to a plug-in used to implement browser functionality on a desktop application. It is used to implement web browsing functionality on desktop applications. Currently, most desktop applications use Cef as their browser component. Cef is an open-source web browser control based on the Google Chromium project. Using this component, developers can add web browsing functionality to their applications and create the application's user interface using HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JS (JavaScript). A subpage creation request is a request to create a subpage corresponding to the main page on the browser. The browser's main page has many links pointing to new web pages. The web pages generated through the links on these main pages are the subpages corresponding to the main page. The request to create these pages is a subpage creation request.

[0042] Specifically, in one embodiment, a user can browse a web page through a browser component in an application. When a user clicks a web link on a page, it can be considered that the user has initiated a sub-page creation request on the current web page. At this time, the terminal operated by the user can send a sub-page creation request corresponding to the browser component to create the corresponding browser sub-page. When applied to a terminal, the processor on the terminal will sense the user's click operation on the web link and, after the click operation, it will be considered that the sub-page creation request corresponding to the browser component in the application has been received.

[0043] Step 104: Based on the sub-page creation request, the sub-page callback interface in the main thread of the browser component is called to create a page instance of the sub-page.

[0044] The main thread of the browser component specifically refers to the main running thread of the browser, which is used to control the browser component's operations such as creating web pages, rendering pages, and closing pages. In one embodiment, the browser component is specifically implemented using Cef, and the main thread of the browser component specifically refers to the Cef main thread. The subpage callback interface refers to the callback interface used by the main thread of the browser component when creating a subpage. The page instance of a subpage is a component of the subpage to be constructed.

[0045] Specifically, when the browser component is implemented using Cef, the application must call the CefInitialize(CefSettings&settings) function to initialize the Cef runtime environment. The multi_threaded_message_loop field in CefSettings controls Cef's threading model. If this field is set to True, Cef will create a child thread as the browser's main thread. If it is set to False, Cef's main thread becomes the application's main thread. In this case, the application's main thread message loop must periodically execute the CefDoMessageLoopWork() function to drive Cef processing tasks. Generally, if the application doesn't use Cef to create its user interface, the multi_threaded_message_loop field should be set to True. When Cef pops up a child page window, it triggers the OnBeforePopup callback interface on the Cef main thread. The client parameter in OnBeforePopup is the child page window instance, which must be synchronously returned to the parent window in this callback interface; otherwise, communication between the parent and child pages will be disrupted. However, when multi_threaded_message_loop is set to true, the user interface thread of the application and the main thread of Cef are not the same thread, and since the interface windows of all pages in the browser are maintained by the user interface thread at this time, if the page window is popped up synchronously in OnBeforePopup, it will cause a series of thread safety issues. In the prior art, sub-page windows are generally created and displayed synchronously in the Cef main thread. It is necessary to operate the user interface object in the Cef main thread. At this time, since many interface interfaces of win32 need to be executed in the UI thread, it may cause many problems; for example, the data associated with the user interface needs to consider multi-threaded access issues, which brings challenges to maintaining data logic business; for example, the Cef main thread may throw messages to the user interface thread for processing, and the user interface thread may also wait for the Cef main thread to process certain logic, which may cause deadlock problems.

[0046] Therefore, in the solution of the present application, the page instance of the sub-page to be created and the sub-page window are created separately. When the sub-page creation request is received, the main thread of the browser component is called first, and the sub-page callback interface is called in the main thread of the browser component to directly create the required sub-page instance, but the user interface elements are not operated.

[0047] Step 106: When the creation of the page instance of the sub-page is completed, a window interface of the sub-page is created through the user interface thread of the application.

[0048] The user interface thread refers to the UI thread of the application. In the application, it is mainly responsible for controlling the display, update and control interaction of the application UI interface. The window interface of the sub-page is another component in addition to the page instance.

[0049] Specifically, when the page instance of the sub-page is created, the window interface corresponding to the sub-page can be created through the UI thread on the application at the same time. By operating the user interface elements in the UI thread to generate the window interface of the sub-page, it is possible to avoid operating the user interface elements in the main thread of the browser component. Instead, the page instance is only created in the main thread of the browser component. At the same time, when the page instance of the sub-page is created, the window interface of the sub-page is created through the user interface thread. The two are combined to obtain the required browser sub-page, thereby improving the security of the thread.

[0050] Step 108: Create a browser subpage based on the page instance of the subpage and the window interface of the subpage.

[0051] Specifically, after the page instance of the sub-page is created in the main thread of the browser component and the window interface of the sub-page is created in the user interface thread of the application, the two can be combined to obtain the browser sub-page, and the obtained browser sub-page can be pushed to the user. In this way, after the user clicks the main page link of the browser in the application, the corresponding sub-page can be obtained. In one embodiment, Figure 2 As shown, this application directly generates the required browser subpage instance CefClient through the subpage callback interface OnBeforePopup in the main thread of the browser component, but does not operate the interface elements of the user interface. Instead, it operates the interface elements of the user interface in the user interface thread, separates the subpage instance and the subpage window to create the browser subpage, which can effectively ensure thread safety when the browser subpage is created.

[0052] In the above-mentioned browser sub-page creation method, the terminal obtains the sub-page creation request corresponding to the browser component in the application; according to the sub-page creation request, the sub-page callback interface in the main thread of the browser component is called to create a page instance of the sub-page; when the page instance of the sub-page is created, the window interface of the sub-page is created through the user interface thread of the application; based on the page instance of the sub-page and the window interface of the sub-page, a browser sub-page is created. The present application generates the required sub-page instance of the browser sub-page directly through the sub-page callback interface in the main thread of the browser component, but does not operate the interface elements of the user interface. Instead, the interface elements of the user interface are operated in the user interface thread, and the sub-page instance and the sub-page window are separated to create the browser sub-page, which can effectively ensure the thread safety when the browser sub-page is created.

[0053] In one embodiment, Figure 3 As shown, step 106 includes:

[0054] Step 302: asynchronously send a window creation instruction to the user interface thread of the application through the main thread of the browser component.

[0055] Step 304: When the user interface thread of the application receives the window creation instruction, the user interface thread of the application is controlled to create a window interface of the sub-page according to the window creation instruction.

[0056] The window creation instruction is used to notify the user interface thread that the page instance of the subpage has been created, and at the same time instruct the user interface thread to create the window interface of the subpage. At the same time, the window creation instruction can also include information such as page elements required for the window interface of the subpage.

[0057] Specifically, when the page instance of a subpage is created, the task of creating the subpage's window interface can be asynchronously passed to the user interface thread in the main thread of the browser component. When the application's user interface thread receives the window creation instruction asynchronously sent by the main thread of the browser component, the user interface thread can create the subpage's window interface based on the window creation instruction, eliminating the need for the main thread of the browser component to create the subpage, thereby improving the security of the subpage creation process. In this embodiment, by asynchronously sending the window creation instruction to the user interface thread to create the subpage's window interface, it is possible to achieve the effect of ensuring thread safety during the subpage creation process while ensuring the efficiency of subpage generation.

[0058] In one embodiment, the window creation instruction includes a page instance of the subpage; Figure 4 As shown, step 108 includes:

[0059] Step 401: extracting a page instance of a sub-page contained in a window creation instruction in a user interface thread.

[0060] Step 403: mount the page instance of the sub-page on the window interface of the sub-page to obtain the browser sub-page.

[0061] The window creation instruction also includes the page instance of the subpage that has been created in the main thread of the browser component. After the window creation instruction is asynchronously sent to the user interface thread of the application via the main thread of the browser component, the window creation instruction can be parsed within the user interface thread to obtain the complete page instance of the subpage. Then, after the window interface of the subpage is generated, the page instance of the subpage obtained by parsing can be directly mounted on the newly generated window interface in the user interface thread. The browser subpage is directly obtained by mounting the page instance of the subpage obtained by parsing on the newly generated window interface. No subsequent thread communication is required. In this embodiment, by sending the page instance of the subpage to the user interface thread and directly mounting it on the generated browser subpage, the efficiency of generating the browser subpage can be effectively guaranteed.

[0062] In one embodiment, after step 108, it also includes: obtaining the sub-page input content corresponding to the sub-page; generating a content update instruction based on the sub-page input content; sending the content update instruction to the browser component, and the main thread of the browser component forwards the content update instruction to the user interface thread; calling the user interface thread to modify the input content of the browser sub-page.

[0063] The sub-page input content refers to the content entered by the user on the sub-page. For example, the sub-page contains a text box. When the user types in the text box of the sub-page, the words typed by the user can be regarded as the sub-page input content.

[0064] Specifically, when a user enters content in a text box, in order to update the input content on the browser subpage, the server can first obtain the subpage input content; then generate a content update instruction based on the subpage input content; and send the content update instruction to the browser component, which will complete the update of the input content, because this is an update of the content displayed in the browser. The main thread of the browser component will forward the content update instruction to the user interface thread, and call the user interface thread to modify the input content of the browser subpage. The subpage with the changed input content is then presented to the user. In this embodiment, the content update instruction can be used to update the displayed content on the created browser subpage, ensuring the update efficiency of the newly generated browser subpage content.

[0065] In one embodiment, after creating a browser subpage based on the page instance of the subpage and the window interface of the subpage, it also includes: obtaining a subpage attribute modification message corresponding to the subpage; generating an attribute update instruction based on the subpage attribute modification message; sending the attribute update instruction to the browser component, and the main thread of the browser component forwards the attribute update instruction to the user interface thread; calling the user interface thread to modify the page attributes in the browser subpage.

[0066] The sub-page attribute modification message is a message used to modify the content presented in the browser. When a user sees a sub-page in the browser, they may not be satisfied with the page attributes set in the sub-page, such as changing the font size or image clarity. In this case, the page attributes on the sub-page can be modified by submitting the corresponding sub-page attribute modification message to the browser.

[0067] Specifically, after the user sends a sub-page attribute modification message corresponding to a browser sub-page, the server can receive the sub-page attribute modification message; then generate an attribute update instruction based on the sub-page attribute modification message; and send the attribute update instruction to the browser component, which completes the modification of the browser page attributes, since this is an update of the sub-page in the browser. The main thread of the browser component will forward the attribute update instruction to the user interface thread; and call the user interface thread to modify the page attributes of the browser sub-page. The sub-page with the changed page attributes is then presented to the user. In this embodiment, the attributes of the created browser sub-page can be modified through the attribute update instruction, ensuring the modification efficiency of the newly generated browser sub-page attributes.

[0068] In one embodiment, Figure 5 As shown, after step 108, the following steps are further included:

[0069] Step 502: Identify the sub-page link in the browser sub-page, and search for the target sub-page link. The page attribute of the browser sub-page corresponding to the target sub-page link is invisible.

[0070] Step 504: Generate a browser subpage corresponding to the target subpage link.

[0071] Step 506: When an access request corresponding to the target sub-page link is received, the page attribute of the browser sub-page corresponding to the target sub-page link is converted from invisible to visible.

[0072] A subpage link within a browser subpage refers to a link that can generate a new subpage within the subpage. A subpage typically has multiple new subpage links. When a user clicks one of these links, the browser's main thread controls the generation of the corresponding subpages, i.e., the subpages of the subpages.

[0073] Specifically, after creating a browser subpage, to ensure the efficiency of browser subpage creation in subsequent processes, the server can directly identify the subpage links within the browser subpage and search for target subpage links. At this point, the page attributes of the browser subpages corresponding to these target subpage links are set to invisible. The server can then directly generate the browser subpages corresponding to these target subpage links, i.e., generate the invisible browser subpages before the user clicks the subpage links. When the user clicks the subpage link within the browser subpage, the server receives an access request corresponding to the subpage link. At this point, the server can directly convert the page attribute of the browser subpage corresponding to the subpage link from invisible to visible. The user can then directly browse the content on the browser subpage corresponding to the clicked target subpage link without waiting. In one embodiment, the page tags and page attributes corresponding to the subpage links within the browser subpage can be first identified. Then, based on the user's browsing history, the recommendation levels of different web links can be determined. The recommendation levels are used to identify which webpage links the user is most likely to click. Browser subpages corresponding to the webpage links are then generated based on the recommendation rankings, ensuring the reliability and efficiency of the generation process. In this embodiment, by generating the browser subpage corresponding to the subpage link in the browser subpage in advance, the browser subpage can be directly displayed to the user after the user performs a click operation, thereby improving the real-time generation efficiency of the browser subpage.

[0074] In one embodiment, Figure 6 As shown, after step 108, the following steps are further included:

[0075] Step 601: Get a sub-page destroy instruction.

[0076] Step 603: destroy the rendering process corresponding to the browser sub-page in the main thread of the browser component and the browser sub-page in the user interface thread according to the sub-page destruction instruction.

[0077] The sub-page destruction instruction is used to destroy the newly generated browser sub-page.

[0078] Specifically, when a user wishes to close a browser subpage, they can do so by sending a subpage destruction instruction to the server. Specifically, upon receiving the subpage destruction instruction, the server will simultaneously destroy the rendering process corresponding to the browser subpage within the main thread of the browser component and the browser subpage within the user interface thread in accordance with the subpage destruction instruction. In this embodiment, the rendering thread corresponding to the generated browser subpage and the browser subpage within the user interface thread can be destroyed based on the subpage destruction instruction, ensuring thread safety during the generation and use of the browser subpage.

[0079] In one embodiment, the browser subpage creation method of the present application specifically includes the following steps: obtaining a subpage creation request corresponding to a browser component in an application; calling a subpage callback interface in the main thread of the browser component according to the subpage creation request to create a page instance of the subpage; when the page instance of the subpage is created, asynchronously sending a window creation instruction to the user interface thread of the application through the main thread of the browser component;

[0080] When the application's user interface thread receives a window creation instruction, it controls the application's user interface thread to create a subpage window interface based on the window creation instruction. The user interface thread extracts the subpage page instance contained in the window creation instruction; mounts the subpage page instance on the subpage window interface to obtain the browser subpage. The subpage input content corresponding to the subpage is obtained; a content update instruction is generated based on the subpage input content; the content update instruction is sent to the browser component, which has its main thread forward the content update instruction to the user interface thread; and the user interface thread is invoked to modify the browser subpage input content. A subpage attribute modification message corresponding to the subpage is obtained; a attribute update instruction is generated based on the subpage attribute modification message; the attribute update instruction is sent to the browser component, which has its main thread forward the attribute update instruction to the user interface thread; and the user interface thread is invoked to modify the page attributes within the browser subpage. The subpage link within the browser subpage is identified, and the target subpage link is searched for. The page attribute of the browser subpage corresponding to the target subpage link is invisible. A browser subpage corresponding to the target subpage link is generated; and upon receiving an access request corresponding to the target subpage link, the page attribute of the browser subpage corresponding to the target subpage link is changed from invisible to visible. Obtain a sub-page destruction instruction; and destroy the rendering process corresponding to the browser sub-page in the main thread of the browser component and the browser sub-page in the user interface thread according to the sub-page destruction instruction.

[0081] This application also provides an application scenario, which applies the above-mentioned browser subpage creation method. Specifically, the application of the browser subpage creation method in this application scenario is as follows:

[0082] When a user uses an application installed on a PC (Personal Computer), if the application has a built-in browser component, the user can browse the target web page through the browser component on the application. For example, the user enters a portal website through the browser component, and the portal website contains several web links, each of which points to a different target page. When the user clicks on a web link, such as clicking on a web link corresponding to a news article, the processor on the PC will receive a sub-page creation request corresponding to the news web link. This sub-page creation request is the sub-page creation request corresponding to the browser component in the application in the browser sub-page creation method of this application. At this time, the processor needs to generate the sub-page corresponding to this news through the browser component. Specifically, the processor first calls the sub-page callback interface in the main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page. The browser component is implemented through Cef. In order to ensure the security of the Cef main thread, UI objects are not operated in Cef. This application first calls the sub-page callback interface in the main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page. When Cef pops up a subpage window, it triggers the OnBeforePopup callback interface in the Cef main thread and creates a subpage instance corresponding to the news page. After the subpage instance is created, the processor asynchronously sends a window creation instruction to the application's user interface thread through the browser component's main thread. The user interface thread then creates the subpage window interface. The processor then forwards the subpage window interface creation task to the user interface thread within the browser component's main thread. Upon receiving the window creation instruction, the application's user interface thread controls the application's user interface thread to create the subpage window interface based on the instruction. The window creation instruction also includes the subpage page instance. After the user interface thread creates the subpage window interface, the user interface thread can retrieve the subpage page instance contained in the window creation instruction. The processor then mounts the subpage page instance on the generated subpage window interface, directly creating a browser subpage for the user to browse. To comment on the news on the browser subpage, the user can first enter text in the corresponding input field and then click Submit. At this point, the processor can obtain the user's input content on the corresponding sub-page; generate a content update instruction based on the sub-page input content; send the content update instruction to the browser component, and the browser component's main thread forwards the content update instruction to the user interface thread; and call the user interface thread to modify the input content of the browser sub-page. The user can then see their comment information on the updated browser sub-page.When a user needs to modify the text size of a news item on a browser subpage, they can click the corresponding text size adjustment button to submit a corresponding subpage attribute modification message to the processor. Upon receiving the subpage attribute modification message, the processor generates an attribute update instruction based on the subpage attribute modification message. The instruction is sent to the browser component, which then forwards the instruction to the user interface thread through its main thread. The user interface thread is then invoked to modify the page attributes within the browser subpage. The user can now view the updated page with the adjusted font size on the updated browser subpage. Furthermore, the browser subpage associated with the news the user is browsing typically contains several related news links. After the user opens the browser subpage, the processor further identifies the subpage links within the browser subpage, searches for a target subpage link, and finds the browser subpage corresponding to the target subpage link whose page attribute is invisible. The processor generates a browser subpage corresponding to the target subpage link. Upon receiving an access request corresponding to the target subpage link, the processor changes the page attribute of the browser subpage corresponding to the target subpage link from invisible to visible. When the user clicks on the link corresponding to these related news items, the corresponding news interface is directly accessed without having to wait for the page to be generated. In addition, when the user clicks the close button corresponding to the browser subpage, the processor will receive the corresponding subpage destruction instruction. In order to close the browser subpage, the processor will destroy the rendering process corresponding to the browser subpage in the main thread of the browser component and the browser subpage in the user interface thread according to the subpage destruction instruction. In the present embodiment, the browser thread of the Cef specified component is used as an application program running as a separate thread. If the subpage window pops up directly in the browser thread, it may cause a series of stability problems. If the browser thread is set to the main thread of the application program to solve this problem, then because it is necessary to periodically execute the CefDoMessageLoopWork() function in the main thread message loop of the application program to drive the Cef processing task, the application program response performance will inevitably be reduced. In the present embodiment, the separate thread is used as the mode of the CEF browser thread, which does not affect the response performance of the application program and can avoid the stability problems caused by operating the interface elements of the application program in the Cef browser thread.

[0083] Figure 7 FIG. 1 is a flow chart of a method for creating a browser subpage in one embodiment. Figure 1-Figure 7 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Figure 1-Figure 7At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0084] In one embodiment, Figure 8 As shown, a browser subpage creation device is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: a request acquisition module, an instance creation module, a window creation module and a subpage creation module, wherein:

[0085] The request acquisition module 801 is used to obtain the sub-page creation request corresponding to the browser component in the application;

[0086] The instance creation module 803 is used to call the sub-page callback interface in the main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page;

[0087] The window creation module 805 is used to create a window interface of the sub-page through the user interface thread of the application when the page instance of the sub-page is created;

[0088] The sub-page creation module 807 is used to create a browser sub-page based on the page instance of the sub-page and the window interface of the sub-page.

[0089] In one embodiment, the window creation module 805 is specifically used to: asynchronously send a window creation instruction to the user interface thread of the application through the main thread of the browser component; when the user interface thread of the application receives the window creation instruction, control the user interface thread of the application to create a window interface of the sub-page according to the window creation instruction.

[0090] In one embodiment, the window creation instruction includes a page instance of a sub-page; the sub-page creation module 807 is specifically used to: extract the page instance of the sub-page included in the window creation instruction in the user interface thread; mount the page instance of the sub-page on the window interface of the sub-page to obtain the browser sub-page.

[0091] In one embodiment, it also includes an input content update module, which is used to: obtain the sub-page input content corresponding to the sub-page; generate a content update instruction based on the sub-page input content; send the content update instruction to the browser component, and the main thread of the browser component forwards the content update instruction to the user interface thread; call the user interface thread to modify the input content of the browser sub-page.

[0092] In one embodiment, it also includes a page attribute modification module, which is used to: obtain a sub-page attribute modification message corresponding to the sub-page; generate an attribute update instruction based on the sub-page attribute modification message; send the attribute update instruction to the browser component, and the main thread of the browser component forwards the attribute update instruction to the user interface thread; call the user interface thread to modify the page attributes in the browser sub-page.

[0093] In one embodiment, it also includes a page pre-generation module, which is used to: identify the sub-page link in the browser sub-page, find the target sub-page link, and the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; generate the browser sub-page corresponding to the target sub-page link; when receiving an access request corresponding to the target sub-page link, convert the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible.

[0094] In one embodiment, a page destruction module is further included, which is used to: obtain a sub-page destruction instruction; and destroy the rendering process corresponding to the browser sub-page in the main thread of the browser component and the browser sub-page in the user interface thread according to the sub-page destruction instruction.

[0095] The specific limitations of the browser subpage creation device can be found in the limitations of the browser subpage creation method described above and will not be repeated here. Each module in the above-mentioned browser subpage creation device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a memory in the computer device in software form, so that the processor can call and execute the corresponding operations of each of the above modules.

[0096] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 9As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for creating a browser subpage is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.

[0097] Those skilled in the art will understand that Figure 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0098] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0099] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.

[0100] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of each of the above-described method embodiments.

[0101] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0102] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0103] The above embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A method for creating a browser subpage, characterized in that: The method comprises: Obtain a sub-page creation request corresponding to the browser component in the application, wherein the sub-page creation request is generated based on a link attached to the main page of the browser and is used to create a sub-page corresponding to the main page of the browser; According to the sub-page creation request, the sub-page callback interface in the main thread of the browser component is called to create a page instance of the sub-page, wherein the page instance of the sub-page and the window interface of the sub-page are created separately; When the page instance of the sub-page is created, a window creation instruction is asynchronously sent to the user interface thread of the application through the main thread of the browser component; when the user interface thread of the application receives the window creation instruction, the user interface thread of the application is controlled to create a window interface of the sub-page according to the window creation instruction, where the window creation instruction includes the page instance of the sub-page and page elements required to be used in the window interface of the sub-page; The page instance of the sub-page contained in the window creation instruction is extracted in the user interface thread; the page instance of the sub-page is mounted on the window interface of the sub-page to obtain the browser sub-page.

2. The method according to claim 1, characterized in that After creating the browser subpage based on the page instance of the subpage and the window interface of the subpage, the method further includes: Obtain the sub-page input content corresponding to the sub-page; Generate a content update instruction according to the sub-page input content; Sending the content update instruction to the browser component, and forwarding the content update instruction to the user interface thread by the main thread of the browser component; Call the user interface thread to modify the input content of the browser subpage.

3. The method according to claim 1, characterized in that After creating a browser subpage based on the page instance of the subpage and the window interface of the subpage, the method further includes: Obtaining a sub-page attribute modification message corresponding to the sub-page; Generate an attribute update instruction according to the sub-page attribute modification message; Sending the property update instruction to the browser component, and forwarding the property update instruction to the user interface thread by the main thread of the browser component; Call the user interface thread to modify the page properties within the browser subpage.

4. The method according to claim 3, characterized in that After creating the browser subpage based on the page instance of the subpage and the window interface of the subpage, the method further includes: Identify the sub-page link in the browser sub-page, and search for a target sub-page link, wherein the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; Generate a browser subpage corresponding to the target subpage link; When an access request corresponding to the target sub-page link is received, the page attribute of the browser sub-page corresponding to the target sub-page link is converted from invisible to visible.

5. The method according to claim 1, wherein Also includes: Get the sub-page destruction instruction; The rendering process corresponding to the browser sub-page in the main thread of the browser component and the browser sub-page in the user interface thread are destroyed according to the sub-page destruction instruction.

6. A browser subpage creation device, characterized in that: The device comprises: A request acquisition module is used to obtain a sub-page creation request corresponding to the browser component in the application. The sub-page creation request is generated based on the link attached to the main page of the browser and is used to create a sub-page corresponding to the main page of the browser; An instance creation module is used to call the sub-page callback interface in the main thread of the browser component according to the sub-page creation request to create a page instance of the sub-page, wherein the page instance of the sub-page and the window interface of the sub-page are created separately; a window creation module, configured to asynchronously send a window creation instruction to the user interface thread of the application via the main thread of the browser component when the page instance of the subpage is created; and when the user interface thread of the application receives the window creation instruction, control the user interface thread of the application to create a window interface of the subpage according to the window creation instruction, wherein the window creation instruction includes the page instance of the subpage and the page elements required to be used in the window interface of the subpage; The subpage creation module is used to extract the page instance of the subpage contained in the window creation instruction in the user interface thread; mount the page instance of the subpage on the window interface of the subpage, and obtain the browser subpage.

7. The device according to claim 6, characterized in that It also includes an input content update module, which is used to: obtain the sub-page input content corresponding to the sub-page; generate a content update instruction based on the sub-page input content; send the content update instruction to the browser component, and the main thread of the browser component forwards the content update instruction to the user interface thread; call the user interface thread to modify the input content of the browser sub-page.

8. The device according to claim 6, characterized in that It also includes an attribute modification module, which is used to: obtain the sub-page attribute modification message corresponding to the sub-page; generate an attribute update instruction based on the sub-page attribute modification message; send the attribute update instruction to the browser component, and the main thread of the browser component forwards the attribute update instruction to the user interface thread; call the user interface thread to modify the page attributes in the browser sub-page.

9. The device according to claim 8, characterized in that It also includes a page pre-generation module, which is used to: identify the sub-page link within the browser sub-page, search for the target sub-page link, and the page attribute of the browser sub-page corresponding to the target sub-page link is invisible; generate the browser sub-page corresponding to the target sub-page link; when receiving an access request corresponding to the target sub-page link, convert the page attribute of the browser sub-page corresponding to the target sub-page link from invisible to visible.

10. The device according to claim 6, characterized in that It also includes a page destruction module for: obtaining a sub-page destruction instruction; and destroying the rendering process corresponding to the browser sub-page in the main thread of the browser component and the browser sub-page in the user interface thread according to the sub-page destruction instruction.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and device for preventing apparent death of browser of mobile communication equipment

    CN102375758A

  • User interface implementation method, client and storage medium

    CN107992301A