Page display methods, devices, computer equipment, media and program products
By storing rich text data in a preset storage area as a reference canvas or parsing rich text data, and utilizing the main thread and asynchronous threads for parallel processing, the problem of slow page display speed in mobile applications is solved, improving page display speed and user experience.
Patent Information
- Application Number
- CN202210645360.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-06-09
AI Technical Summary
In existing technologies, mobile applications have slow page display speeds, especially due to the long processing time for rich text data, which slows down page display and affects user experience.
By storing a reference canvas or parsing rich text data for the target rich text data in a preset storage area, and directly retrieving the corresponding data from that area for display when a data display requirement is detected, the main thread and asynchronous thread can process the data in parallel, reducing the data processing pressure on the main thread.
It improves the display speed of rich text data, reduces page display time, enhances user experience, and reduces scrolling lag.
Smart Images

Figure CN117009010B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computing technology, and in particular to a page display method, apparatus, computer equipment, medium, and program product. Background Technology
[0002] With the development of computer technology, mobile applications are becoming increasingly numerous. Currently, many applications feature increasingly complex page designs and richer content, including large amounts of text and images. For example, news and comment pages typically contain a large amount of rich text data. Within the short time it takes for this rich text data to be displayed on the screen, it needs to be processed. However, processing large amounts of rich text data takes a considerable amount of time, potentially slowing down the display speed and consequently slowing down the overall page loading speed. Therefore, improving page loading speed has become a pressing issue. Summary of the Invention
[0003] This application provides a page display method, apparatus, computer device, medium, and program product that can improve the display speed of rich text data and the display speed of the page.
[0004] The first aspect of this application discloses a page display method, the method comprising:
[0005] When a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, the reference canvas for the target rich text data is retrieved from the preset storage area and displayed on the screen using the reference canvas for the target rich text data.
[0006] If the reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data of the target rich text data exists, then the parsed rich text data of the target rich text data is obtained from the preset storage area and displayed on the screen using the parsed rich text data of the target rich text data.
[0007] A second aspect of this application discloses a page display device, the device comprising:
[0008] The first display unit is configured to, when a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, retrieve the reference canvas for the target rich text data from the preset storage area and display it on the screen using the reference canvas for the target rich text data.
[0009] The second display unit is configured to, if there is no reference canvas for the target rich text data in the preset storage area, but there is parsed rich text data for the target rich text data, then obtain the parsed rich text data for the target rich text data from the preset storage area and display it on the screen using the parsed rich text data for the target rich text data.
[0010] A third aspect of this application discloses a computer device including a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to execute the method described in the first aspect.
[0011] A fourth aspect of this application discloses a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in the first aspect.
[0012] The fifth aspect of this application discloses a computer program product or computer program, which includes computer instructions that, when executed by a processor, implement the method of the first aspect described above.
[0013] In this embodiment, when a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, the reference canvas can be retrieved from the preset storage area and used for display. If a reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data for the target rich text data exists, the parsed rich text data for the target rich text data can be retrieved from the preset storage area and used for display. By implementing the above method, the data required for displaying rich text data can be directly retrieved from the preset storage area, reducing the processing time of the current main thread for rich text data during page display. This reduces the overall data processing time when displaying page data, thereby improving the display speed of rich text data, page display speed, and user experience. It also reduces scrolling lag on pages with a large amount of rich text data. Attached Figure Description
[0014] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 This is a schematic diagram of the architecture of a page display system provided in an embodiment of this application;
[0016] Figure 2 This is a flowchart illustrating a page display method provided in an embodiment of this application;
[0017] Figure 3 This is a data illustration of rich text data provided in an embodiment of this application;
[0018] Figure 4 This is a flowchart illustrating another page display method provided in an embodiment of this application;
[0019] Figure 5a This is a flowchart illustrating a preprocessing operation stage provided in an embodiment of this application;
[0020] Figure 5b This is a flowchart illustrating a screen display stage provided in an embodiment of this application;
[0021] Figure 5c This is a flowchart illustrating another page display method provided in an embodiment of this application;
[0022] Figure 6 This is a schematic diagram of the structure of a page display device provided in an embodiment of this application;
[0023] Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0024] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0025] In this application embodiment, rich text data can refer to data that includes not only text but also emoticons, tags, @ tags, links, etc.; displaying on screen can be understood as displaying the data on the terminal screen. To improve page display speed, this application embodiment provides a page display scheme. The general principle of this page display scheme is as follows: when a data display requirement for target rich text data is detected, the display is performed based on the data retrieval status in a preset storage area. For example, if a reference canvas for the target rich text data exists in the preset storage area, the reference canvas for the target rich text data is retrieved from the preset storage area and used for displaying on screen; if a reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data for the target rich text data exists, the parsed rich text data for the target rich text data is retrieved from the preset storage area and used for displaying on screen.
[0026] By implementing the above method, the data required for displaying rich text data can be directly obtained from the preset storage area, thereby reducing the processing time of the current thread on the rich text data. This reduces the overall data processing time when displaying page data, thus improving the display speed of rich text data, the page display speed, and the user experience. It also reduces the feeling of lag when scrolling through pages with a large amount of rich text data.
[0027] In one implementation, when a page display requirement exists, the main thread is typically invoked to process the raw page data returned from the backend to achieve page display. This involves numerous operations such as overall page layout, smaller page layouts, and rich text data layout. The main thread generally follows a specific processing order, with rich text data processing occurring later. In this application, page display can be achieved by combining the processing of the main thread and an asynchronous thread. This asynchronous thread can refer to a separate thread distinct from the main thread. For example, rich text data processing can be implemented using an asynchronous thread, reducing the amount of rich text data processing in the main thread and thus alleviating its processing load. Furthermore, by invoking the asynchronous thread for rich text data processing (such as parsing and canvas rendering), the processing of rich text data can be advanced, reducing the overall data loading process and improving page display speed. Advancing the processing of rich text data also improves its display speed.
[0028] In specific implementations, the execution entity of the page display scheme mentioned above can be a computer device, which includes, but is not limited to, a terminal or a server. In other words, the computer device can be a server or a terminal, or a system composed of a server and a terminal. The terminal mentioned above can be an electronic device, including but not limited to mobile phones, tablets, desktop computers, laptops, PDAs, in-vehicle devices, intelligent voice interaction devices, augmented reality / virtual reality (AR / VR) devices, head-mounted displays, wearable devices, smart speakers, smart home appliances, aircraft, digital cameras, webcams, and other mobile internet devices (MIDs) with network access capabilities. The server mentioned above can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, vehicle-to-everything (V2X) communication, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0029] In one implementation, when the computer device is a server, embodiments of this application provide a page display system. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram of the architecture of a page display system provided in an embodiment of this application. This application relates to a terminal 101 and a server 102.
[0030] Taking terminal 101 as an example, terminal 101 can obtain a page display request and send the page display request to server 102. Server 102 can respond to the page display request and obtain the original page data for the page display request. The original page data may refer to the background data used to load the current page, and may include one or more rich text data. Furthermore, server 102 can call the current main thread to process the non-rich text data in the original page data, and call an asynchronous thread to process the rich text data in the original page data to obtain the data used for page display.
[0031] When server 102 detects a data display requirement for the target rich text data, if a reference canvas for the target rich text data exists in the preset storage area, server 102 can call the main thread to retrieve the reference canvas for the target rich text data from the preset storage area and display it on the screen using the reference canvas. If a reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data for the target rich text data exists, server 102 can call the main thread to retrieve the parsed rich text data for the target rich text data from the preset storage area and display it on the screen using the parsed rich text data for the target rich text data.
[0032] In one implementation, this application can be applied to applications with page display requirements, such as scenarios where a lot of rich text data is displayed on the page, like feed stream (message stream) style (such as news recommendation pages, user comment pages, etc.), multi-list style (such as instant messaging communication windows), and pages that can be scrolled infinitely. In such multi-list pages, if each list item contains rich text data (a mixture of text, images, emoticons, tags, @ text, links, etc.), and if the main thread is directly called for processing during continuous scrolling, this rich text data needs to be parsed and the canvas drawn in the main thread, resulting in time consumption. A large amount of rich text data may cause a lot of time consumption, resulting in page lag, unsmooth scrolling, and a poor user experience. This application allows for the use of asynchronous threads to parse rich text data and draw on the canvas, thereby reducing the data processing pressure on the main thread. This reduces the overall time spent processing the original page data for display, thus improving page display speed. Furthermore, asynchronous processing of rich text data, i.e., using asynchronous threads, can significantly improve the display speed of rich text data, effectively reducing scrolling lag and enhancing user experience.
[0033] Based on the page display scheme provided above, this application embodiment provides a page display method, which can be executed by the aforementioned computer device. Please refer to... Figure 2 The methods for displaying this page include, but are not limited to, the following steps:
[0034] S201, when a data display requirement for the target rich text data is detected, if a reference canvas for the target rich text data exists in the preset storage area, the reference canvas for the target rich text data is obtained from the preset storage area and displayed on the screen using the reference canvas for the target rich text data.
[0035] Target rich text data can refer to data in both text and non-text formats. Text data can be simply text, while non-text data can be data in other formats besides text, such as emoticons, tags, @mentions, and links. In other words, target rich text data can contain not only text but also one or more of these formats. For example, target rich text data can include both text and emoticons; or it can include text, emoticons, and links.
[0036] For example, feed-style and multi-list styles of pages can typically contain large amounts of rich text data. Feed-style pages might include news recommendation pages or user comment pages; list-style pages might include instant messaging windows. These pages can usually contain a large amount of rich text data; for example, a comment on a user comment page can be a piece of rich text data. See, for example... Figure 3 As shown, this page could refer to a user comments page, where each user's comment can refer to rich text data. For example, Figure 3 The data displayed in the area marked with a 301 redirect can refer to rich text data, which contains text, emoticons, etc. For example, Figure 3 The data displayed in the area marked with 302 can also refer to rich text data, which contains text, @ tags, emoticons, etc.
[0037] The requirement for data display can refer to the display of data on the screen, that is, displaying the target rich text data on the terminal screen. For example, when a user scrolls through a page, certain data on the page needs to be displayed on the terminal screen. For instance, on a user comments page, as the page is scrolled, user comments (which can be understood as rich text data) continuously need to be displayed on the terminal screen. In this application, "display on screen" can be understood as displaying the reference canvas corresponding to the target rich text data on the terminal screen.
[0038] In one implementation, when a computer device receives a page display request, it can respond to the request and obtain the original page data required for the request. This original page data may refer to background data used to load the current page, and may include one or more rich text data sets. Optionally, the computer device can invoke the current main thread and perform numerous operations such as large and small page layouts using the original page data. The operations of the current main thread do not include operations on the rich text data within the original page data; instead, it can invoke an asynchronous thread to process the rich text data to obtain the canvas for display. That is, the processing of the current main thread and the processing of the asynchronous thread can be parallel.
[0039] Understandably, in traditional page display, the main thread performs numerous operations such as overall page layout, smaller page layout, and rich text data layout. The main thread typically follows a specific processing order to display the page data on the terminal screen. In this application, rich text data processing is implemented using a separate thread (i.e., an asynchronous thread). Therefore, when the main thread needs to process the rich text data (e.g., parsing, canvas drawing), it can directly obtain the processing results from the asynchronous thread (e.g., parsing the rich text data or referencing the canvas), thus reducing the main thread's processing load on the rich text data. In summary, the requirement to display the target rich text data on the screen can be detected when the main thread needs to process it; or, the requirement can be detected when the main thread needs to display the target rich text data on the terminal screen.
[0040] In one implementation, the target rich text data, specifically the data required for on-screen display (such as a reference canvas or parsed rich text data), can be stored in a preset storage area for later retrieval. For example, an asynchronous thread can be invoked to process the target rich text data asynchronously, and the resulting data can be stored in the preset storage area. In another possible implementation, an asynchronous thread can be created to asynchronously process the rich text data within the original page data after obtaining it, yielding the data needed for subsequent rich text data display (such as parsed rich text data or a reference canvas). This asynchronous thread processing reduces the data processing load on the main thread, preventing it from processing large amounts of data during the short time of page display (i.e., data loading). This reduces the computational process for display data, improving the speed of data loading and reducing visual lag.
[0041] Optionally, asynchronous processing may include parsing and canvas drawing. Correspondingly, the data obtained from asynchronous processing may include parsed rich text data obtained from parsing and a reference canvas obtained from canvas drawing. Alternatively, asynchronous processing may also include parsing; correspondingly, the data obtained from asynchronous processing may include parsed rich text data obtained from parsing. Considering that when displaying on-screen, the reference canvas can be directly used, and using an asynchronous thread to complete canvas drawing can further reduce the pressure on the main thread, this application mainly uses asynchronous processing including parsing and canvas drawing as an example for illustration.
[0042] In one implementation, since parsing and canvas rendering can both succeed or fail, the data used for displaying the target rich text data in the preset storage area will differ depending on the situation. For example, for a given rich text data, if both parsing and canvas rendering are successful, the preset storage area can contain the parsed rich text data and the reference canvas. If parsing is successful but canvas rendering fails, the preset storage area can contain the parsed rich text data but not the reference canvas. If parsing fails, neither the parsed rich text data nor the reference canvas is obtained, so neither the parsed rich text data nor the reference canvas exists in the preset storage area.
[0043] It should be noted that, considering that rich text data can be displayed directly using a reference canvas, while using parsed rich text data requires canvas drawing operations on the parsed rich text data, it is advisable to first obtain the reference canvas of the target rich text data. If the reference canvas cannot be obtained, then consider obtaining the parsed rich text data of the target rich text data.
[0044] In one implementation, when a data display requirement for target rich text data is detected, it can be checked whether a reference canvas corresponding to the target rich text data exists in a preset storage area. If a corresponding reference canvas is detected in the preset storage area, the reference canvas of the target rich text data can be retrieved from the preset storage area for display on the screen. For example, the current main thread can be invoked to display the reference canvas of the target rich text data on the terminal screen.
[0045] S202, if there is no reference canvas for the target rich text data in the preset storage area, but there is parsed rich text data for the target rich text data, then the parsed rich text data for the target rich text data is obtained from the preset storage area and displayed on the screen using the parsed rich text data for the target rich text data.
[0046] In one implementation, if a corresponding reference canvas is detected not to exist in a preset storage area, it can be further checked whether parsed rich text data corresponding to the target rich text data exists in the preset storage area. If parsed rich text data corresponding to the target rich text data is detected in the preset storage area, the parsed rich text data of the target rich text data can be obtained from the preset storage area and used for on-screen display. For example, the main thread can be called and the parsed rich text data can be used for on-screen display.
[0047] In one implementation, the specific method for displaying the parsed rich text data of the target rich text data can be as follows: After obtaining the parsed rich text data, a canvas can be drawn using the parsed rich text data to obtain a reference canvas corresponding to the target rich text data. After obtaining the reference canvas corresponding to the target rich text data, the display is then performed based on the reference canvas corresponding to the target rich text data. Here, the canvas drawing can be performed by calling the current main thread. For example, the main thread can obtain the layout configuration information corresponding to the target rich text data, and use this layout configuration information to draw the canvas of the parsed rich text data corresponding to the target rich text data, thus obtaining the reference canvas of the target rich text data.
[0048] The layout configuration information may include configuration information for page layout of the target rich text data, such as the font, font size, emoticon size, and the distance between the rich text data as a whole and the edge of the page display interface (such as left edge distance, right edge distance, top edge distance, bottom edge distance), etc.
[0049] In one implementation, if neither a reference canvas nor parsed rich text data corresponding to the target rich text data exists in the preset storage area, the target rich text data can be used for on-screen display. Specifically, the main thread can be called to process the target rich text data to obtain a reference canvas for on-screen display, and then the target rich text data can be used for on-screen display. Optionally, the main thread can perform the following operations: first, parse the target rich text data to obtain the corresponding parsed rich text data; after obtaining the parsed rich text data, a canvas can be drawn on the parsed rich text data to obtain a reference canvas for the target rich text data; then, the reference canvas corresponding to the target rich text data can be used for on-screen display.
[0050] In one implementation, the detection of whether a reference canvas exists in the preset storage area, or the detection of whether parsed rich text data exists in the preset storage area, can be achieved using the identification information corresponding to the rich text data. Optionally, when storing a reference canvas in the preset storage area, the identification information corresponding to the reference canvas can be associated with the reference canvas and stored in the preset storage area. This identification information can be used to indicate the rich text data corresponding to the reference canvas, so that each reference canvas can be distinguished based on the identification information. Similarly, when storing parsed rich text data in the preset storage area, the identification information corresponding to the parsed rich text data can also be associated with the parsed rich text data and stored in the preset storage area. This identification information can be used to indicate the rich text data corresponding to the parsed rich text data, so that each parsed rich text data can be distinguished based on the identification information. Wherein, for the parsed rich text data and the reference canvas corresponding to the same rich text data, the identification information used during storage can be the same or different. This application mainly uses the same identification information as an example for explanation.
[0051] The identification information can be layout configuration information. Different rich text data can typically have different layouts when displayed on the screen, meaning each piece of rich text data can have different layout configuration information. This layout configuration information can then be used to distinguish between different pieces of rich text data. Alternatively, the identification information can also be other information used to uniquely identify a piece of rich text data. For example, the identification information can be a number, such as each piece of rich text data corresponding to a unique number.
[0052] The specific implementation of determining whether a reference canvas corresponding to the target rich text data exists in a preset storage area can be as follows: Match the identifier information corresponding to the target rich text data with the identifier information in the preset storage area, where any reference canvas in the preset storage area is stored in association with its corresponding identifier information. If the identifier information corresponding to the target rich text data is matched in the preset storage area, it can be determined that a reference canvas corresponding to the target rich text data exists in the preset storage area. If the identifier information corresponding to the target rich text data is not matched in the preset storage area, it can be determined that a reference canvas corresponding to the target rich text data does not exist in the preset storage area. The matching operation can involve comparing the identifier information of the target rich text data with any identifier information in the preset storage area. If the identifier information of the target rich text data is consistent with any identifier information in the preset storage area, a match is determined; if the identifier information of the target rich text data is inconsistent with all identifier information in the preset storage area, a match is determined not to exist.
[0053] Similarly, the specific implementation method for determining whether parsed rich text data corresponding to the target rich text data exists in the preset storage area can be similar to the method for determining whether a reference canvas exists, as mentioned above.
[0054] For example, a specific implementation for determining whether parsed rich text data exists in a preset storage area can be: matching the identification information corresponding to the target rich text data with the identification information in the preset storage area, where any parsed rich text data in the preset storage area is stored in association with its corresponding identification information. If a match is found with the identification information corresponding to the target rich text data, it can be determined that parsed rich text data corresponding to the target rich text data exists. If no match is found with the identification information corresponding to the target rich text data, it can be determined that parsed rich text data corresponding to the target rich text data does not exist.
[0055] In this embodiment, when a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, the reference canvas can be retrieved from the preset storage area and used for display. If a reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data for the target rich text data exists, the parsed rich text data for the target rich text data can be retrieved from the preset storage area and used for display. By implementing the above method, the data required for displaying rich text data can be directly retrieved from the preset storage area, reducing the processing time of the current thread on the rich text data. This reduces the overall data processing during display, thereby improving the display speed of rich text data, page display speed, and user experience. It also reduces scrolling lag on pages with a large amount of rich text data.
[0056] Based on the above description, this application further proposes another page display method; in this application embodiment, the method is mainly described using a computer device executing the page display method as an example. Figure 4 As shown, the method for displaying this page includes, but is not limited to, the following steps:
[0057] S401, retrieve the original page data, which includes one or more rich text data.
[0058] The original page data can refer to the backend data used to load the frontend page. This original page data may include one or more rich text data sets. Rich text data can contain both text and non-text data. Text data can refer to text itself, while non-text data can refer to data in other forms besides text, such as emoticons, tags, @mentions, links, etc. In other words, rich text data can contain not only text but also one or more of emoticons, tags, @mentions, links, etc. The target rich text data mentioned below can be contained within one or more rich text data sets.
[0059] For example, feed-style pages and multi-list pages can typically contain large amounts of rich text data. Feed-style pages might include news recommendation pages or user comment pages; list-style pages might include instant messaging windows. These pages can usually contain a large amount of rich text data; for example, a comment on a user comment page can be a piece of rich text data. Figure 3 The data displayed in the area marked by 301 and the data displayed in the area marked by 302 can both refer to rich text data.
[0060] In one implementation, the original page data can be obtained when a page display requirement exists. Optionally, a page display requirement is determined to exist when the computer device receives a page display request. For example, a user can send a page display request to the computer device, causing the computer device to receive the request. After the computer device receives the page display request, it is determined that a page display requirement exists, such as when the user can trigger the page display request through actions like clicking or pressing.
[0061] For example, a user can trigger the display of an application's comment page, causing the computer device to receive a request to display the comments. For instance, this comment page may contain a large number of comments, and the page display request can be used to request that the comments be displayed on the terminal's current screen, or in other words, to make the comments appear on the screen. Triggering the display of the comment page can be achieved by the user clicking (or pressing, etc.) a control within the application. After the computer device receives the page display request, it can retrieve the data used to load the comment page from the background; this data can also be referred to as the raw page data.
[0062] S402 calls an asynchronous thread to parse and process each rich text data.
[0063] In one implementation, an asynchronous thread can be invoked to process each piece of rich text data asynchronously, and the data corresponding to each piece of rich text data obtained from the asynchronous processing can be stored in a preset storage area. Optionally, the asynchronous processing may include parsing and canvas drawing.
[0064] In one implementation, an asynchronous thread can be invoked to perform preprocessing operations on the rich text data. This preprocessing operation can be understood as the asynchronous processing mentioned above, meaning it can include parsing and canvas drawing. The execution order of the preprocessing operations can be parsing first, followed by canvas drawing. Therefore, for any rich text data set, the asynchronous thread can be invoked to parse the rich text data first, obtaining the corresponding parsed rich text data. Considering that the preprocessing operation is the same for any rich text data set, the following explanation of the preprocessing operation will primarily use a single rich text data set as an example.
[0065] In one implementation, parsing rich text data can involve processing non-textual data within the rich text data, such as emoticons, tags, @mentions, and links. Optionally, this parsing can specifically be regular expression matching, i.e., parsing using regular expressions. Specifically, the parsing process can involve obtaining target indication information from the rich text data, which can be used to indicate non-textual data within the rich text data. Typically, when storing rich text data in the background, non-textual data can be stored according to a predetermined pattern. This predetermined pattern might refer to using characters or strings to represent non-textual data, rather than storing it in the actual data format corresponding to the non-textual data. For example, emoticons in rich text data can be represented and stored using characters from a to z; for instance, emoticon 1 in rich text data is stored using 'a'. Similarly, links in rich text data can be represented using characters from A to Z; for instance, link 1 in rich text data is stored using 'A'. The correspondence between these characters (or strings) and their corresponding non-text data can be predefined, such as by understanding them as regular expression matching rules. Therefore, after obtaining the target indication information from the rich text data, the corresponding non-text data can be determined based on the regular expression matching rules, and this non-text data can be obtained. Furthermore, the target indication information in the rich text data can be replaced with this non-text data to obtain the parsed rich text data.
[0066] For example, in a regular expression matching rule, A1 represents emoticon 1 and A2 represents emoticon 2. If A1 and A2 exist in a certain rich text data, then based on the regular expression matching rule, it can be determined that A1 in the rich text data is used to indicate emoticon 1 and A2 is used to indicate emoticon 2. Thus, emoticon 1 and emoticon 2 can be obtained. Emoticons can be obtained by loading locally or downloading from the network. After obtaining emoticon 1 and emoticon 2, A1 in the rich text data can be replaced with emoticon 1 and A2 can be replaced with emoticon 2. The rich text data after the replacement can be parsed.
[0067] In one implementation, a single asynchronous thread can be used to preprocess the rich text data in the original page data, or multiple asynchronous threads can be used to preprocess the rich text data in the original page data; this application does not impose a specific limitation. For example, an asynchronous thread pool can be created to utilize one or more asynchronous threads in the asynchronous thread pool to perform rich text data preprocessing operations, thereby improving the speed of preprocessing large amounts of rich text data.
[0068] In one implementation, when the number of asynchronous threads in the asynchronous thread pool is greater than or equal to the number of rich text data items, a one-to-one processing model can be achieved between asynchronous threads and rich text data. This means that one asynchronous thread can be used to preprocess one piece of rich text data, thereby improving the speed of preprocessing large amounts of rich text data. Optionally, when the number of asynchronous threads exceeds the number of rich text data items, when selecting a number of threads equal to the number of rich text data items, the number of asynchronous threads can be randomly selected from multiple asynchronous threads, or a preset selection rule can be used. For example, the preset selection rule could be based on the performance of the asynchronous threads. For instance, the asynchronous threads with the highest performance (ranked in the top H) can be selected from multiple asynchronous threads, where H is the number of rich text data items.
[0069] For example, assuming the number of asynchronous threads is 5 and the number of rich text data is 3, then 3 asynchronous threads can be used to perform preprocessing operations on the 3 rich text data. For example, 1 asynchronous thread can be used to perform preprocessing operations on 1 of the 3 rich text data, that is, 3 asynchronous threads can be used to achieve one-to-one processing of the 3 rich text data.
[0070] In an implementation, when the number of asynchronous threads in the asynchronous thread pool is less than the number of rich text data pieces, each asynchronous thread in the asynchronous thread pool may first be used to perform a preprocessing operation on one piece of rich text data respectively. After the preprocessing operation of one asynchronous thread on one piece of rich text data is completed, the asynchronous thread may perform a preprocessing operation on the remaining rich text data again. Optionally, assuming that the number of asynchronous threads is N, the number of rich text data pieces is M, and N < M, N pieces of rich text data may be selected from the M pieces of rich text data first, so that the N asynchronous threads are used to perform preprocessing operations on the N pieces of rich text data, that is, one asynchronous thread performs a preprocessing operation on one piece of rich text data. After any one of the N asynchronous threads completes the preprocessing operation on the rich text data, one piece of rich text data may be selected from the remaining rich text data (such as M-N pieces of rich text data) to continue the preprocessing operation, until all the M pieces of rich text data complete the preprocessing operation.
[0071] In other words, N pieces of rich text data may be selected from the M pieces of rich text data, and the N asynchronous threads are used to perform parsing processing on the N pieces of rich text data. When any one of the N asynchronous threads completes the parsing processing and canvas drawing of the corresponding rich text data, the asynchronous thread is invoked to select one piece of rich text data from the remaining rich text data to perform asynchronous processing and parsing processing.
[0072] Wherein, when selecting N pieces of rich text data from the M pieces of rich text data, the N pieces of rich text data may be randomly selected from the M pieces of rich text data, or the N pieces of rich text data may be selected from the M pieces of rich text data according to a preset selection rule. For subsequently selecting one piece of rich text data from the remaining rich text data, the selection may also be performed randomly, or may also be performed according to the same preset selection rule. For example, the preset selection rule may be determined based on features such as the data volume of the rich text data, the distance between the rich text data and the top edge of the page display interface, and the like. Wherein, the preset selection rule may be determined based on one feature, or may be determined based on a plurality of features.
[0073] In one implementation, the preset selection rule can be determined based on the amount of rich text data. Specifically, this can be achieved by first obtaining the amount of data for each of the M rich text data sets, then sorting these M sets in descending order of data size to obtain a sorting result based on data size. After obtaining this sorting result, the top N rich text data sets can be identified; these N selected rich text data sets are the N rich text data sets chosen from the M sets. It's understandable that preprocessing larger amounts of rich text data takes longer, so this selection method prioritizes processing larger amounts of rich text data. It should be noted that if a rich text data set needs to be displayed on screen but hasn't undergone preprocessing, the main thread will need to be called for further processing (such as parsing and canvas rendering). Therefore, prioritizing the processing of large amounts of rich text data can reduce the need for subsequent calls to the main thread to process large amounts of rich text data, thereby minimizing the time spent by the main thread in processing rich text data.
[0074] Similarly, when an asynchronous thread finishes preprocessing a rich text dataset and needs to select another rich text dataset for preprocessing, it can prioritize selecting the largest rich text dataset from the remaining datasets. For example, if an asynchronous thread is the first to finish preprocessing a rich text dataset, it can select the largest rich text dataset from MN datasets for further preprocessing.
[0075] In one implementation, the preset selection rule can be determined based on the distance between the rich text data and the top edge of the page display interface. Specifically, this preset selection rule can be implemented as follows: First, the top edge distance of each of the M rich text data sets can be obtained. This top edge distance can be obtained from the layout configuration information corresponding to the rich text data. This layout configuration information includes parameters required for page layout of the rich text data, such as the font, font size, emoticon size, and the distance between the rich text data as a whole and the edges of the page display interface (e.g., left edge distance, right edge distance, top edge distance, bottom edge distance), etc. After obtaining the top edge distance of each rich text data set, the M rich text data sets are sorted sequentially from shortest to longest top edge distance to obtain a rich text sorting result based on the length of the top edge distance. After obtaining this rich text sorting result, the top N rich text data sets can be determined. These N rich text data sets are the N rich text data sets selected from the M rich text data sets. It is understandable that rich text data with shorter top edge distances is displayed at the top of the screen, while rich text data with longer top edge distances is displayed at the bottom. This selection method prioritizes rich text data with shorter top edge distances, ensuring that information in the upper part of the screen is displayed first when it is subsequently displayed.
[0076] Similarly, when an asynchronous thread finishes preprocessing a piece of rich text data and needs to select another piece of rich text data for preprocessing, it can prioritize selecting the rich text data with the shortest top edge distance from the remaining rich text data. For example, assuming an asynchronous thread is the first to finish preprocessing a piece of rich text data, it can select the rich text data with the shortest top edge distance from MN rich text data for further preprocessing.
[0077] In one implementation, the preset selection rule can be determined based on the size of the rich text data and the distance between the rich text data and the top edge of the page display interface. Specifically, the implementation using this preset selection rule can be as follows: First, the rich text data can be sorted by size and by top edge distance. The methods for determining these two sorting results are described above and will not be repeated here. After obtaining these two sorting results, N rich text data can be selected from the M rich text data. For example, the selection priority of each rich text data in the M rich text data can be determined based on these two sorting results, where rich text data with higher selection priority can be selected first for preprocessing. For instance, the M rich text data can be sorted sequentially from highest to lowest selection priority to obtain a rich text sorting result based on selection priority. After obtaining this rich text sorting result, the top N rich text data in the rich text sorting result can be selected as the N rich text data. By utilizing the selection methods described above, multiple features can be combined to select rich text data, thereby enhancing the rationality of the selection.
[0078] Similarly, when an asynchronous thread finishes preprocessing a rich text dataset and needs to select another rich text dataset for preprocessing, it can prioritize selecting the rich text dataset with the highest selection priority from the remaining datasets. For example, if an asynchronous thread is the first to finish preprocessing a rich text dataset, it can select the rich text dataset with the highest selection priority from MN rich text datasets for further preprocessing.
[0079] The specific implementation of determining the selection priority of each rich text data point among M rich text data points based on two rich text sorting results (rich text sorting results based on data volume and rich text sorting results based on top edge distance) can be as follows: First, for the rich text sorting result based on data volume, the priority of each rich text data point in terms of data volume can be determined according to this rich text sorting result (e.g., it can be called the first priority). For example, the order of each rich text data point can be used as the corresponding first priority. For instance, the first priority corresponding to the rich text data point ranked 1 in the rich text sorting result can be set to 1, and the first priority corresponding to the rich text data point ranked 2 can be set to 2. Similarly, for the rich text sorting result based on top edge distance, the priority of each rich text data point in terms of top edge distance can also be determined according to this rich text sorting result (e.g., it can be called the second priority). For instance, the order of each rich text data point can be used as the corresponding second priority. For instance, the second priority corresponding to the rich text data point ranked 1 in the rich text sorting result can be set to 1, and the second priority corresponding to the rich text data point ranked 2 can be set to 2. The priority (such as first priority, second priority and selection priority) can be represented by numerical value, bit value, etc. This application mainly uses numerical value to represent the priority. The smaller the numerical value corresponding to the priority, the higher the priority can be understood.
[0080] By using the above method, the first priority and second priority corresponding to each rich text data can be determined. After determining the first priority and second priority, the selection priority corresponding to each rich text data can be determined based on these two priorities. Optionally, for a rich text data, the sum of the first priority and second priority corresponding to the rich text data can be used as the selection priority of the rich text data. Optionally, the first priority and second priority can also have corresponding weight coefficients, which can be preset. For example, the weight coefficients of the first priority and the second priority can be 0.7 and 0.3, respectively. For a rich text data, the first priority and second priority of the rich text data can be weighted with their corresponding weight coefficients, and then the two weighted results can be summed. The sum can be used as the selection priority of the rich text data. For example, the first priority is represented by A1, the second priority is represented by A2, the weight coefficient corresponding to the first priority is represented by q1, and the weight coefficient corresponding to the second priority is represented by q2. For a rich text data, the selection priority of the rich text data can be determined according to the following formula (1).
[0081] V=A1×q1+A2×q2(1)
[0082] Where V represents the selection priority.
[0083] S403: For any rich text data in one or more rich text data sets, if the parsing process yields parsed rich text data corresponding to the rich text data, then the parsed rich text data corresponding to the rich text data is stored in a preset storage area, and an asynchronous thread is called to draw the canvas on the parsed rich text data.
[0084] S404 If the canvas draws a reference canvas for the rich text data, then the reference canvas corresponding to the rich text data is stored in a preset storage area.
[0085] In steps S403 and S404, for any rich text data in one or more rich text data sets, if the rich text data is successfully parsed and the corresponding parsed rich text data is obtained, an asynchronous thread can be further called and a canvas can be drawn based on the parsed rich text data to obtain the canvas corresponding to the rich text data (or it can also be called a reference canvas or temporary canvas).
[0086] In one implementation, after successful parsing, the parsed rich text data can be stored, for example, in a preset storage area. Similarly, after successful canvas drawing, the reference canvas can also be stored, for example, in a preset storage area. Optionally, when storing the parsed rich text data and reference canvas in the preset storage area, either regional storage or associative storage can be used. For example, with regional storage, the parsed rich text data corresponding to each piece of rich text data can be stored in one region of the preset storage area (e.g., the first region), and the reference canvas corresponding to each piece of rich text data can be stored in another region (e.g., the second region). Alternatively, with associative storage, the parsed rich text data and reference canvas corresponding to a piece of rich text data can be associatively stored in the preset storage area; that is, for a single piece of rich text data, the parsed rich text data and reference canvas corresponding to that rich text data are stored in the same region, rather than in different regions as described above.
[0087] In one implementation, if the parsing of the rich text data fails, the preprocessing operation on the rich text data can be terminated, meaning there are no subsequent canvas drawing operations. This is because if parsing fails, there is no corresponding parsed rich text data, and canvas drawing requires this parsed rich text data; therefore, there are no subsequent canvas drawing operations. Consequently, there is no corresponding parsed rich text data or reference canvas for this rich text data, and similarly, there is no corresponding parsed rich text data or reference canvas in the preset storage area.
[0088] In one implementation, if the rich text data is successfully parsed and the corresponding parsed rich text data is obtained, an asynchronous thread is then called to draw the canvas based on the parsed rich text data. If the canvas drawing fails, the preprocessing operation on the rich text data can be terminated. In this case, the rich text data has corresponding parsed rich text data, but no corresponding reference canvas. When storing the data, the parsed rich text data can be stored in a preset storage area. That is, the preset storage area contains the parsed rich text data corresponding to the rich text data, but does not contain the corresponding reference canvas.
[0089] In summary, for a given set of rich text data, if the rich text data is successfully parsed and the canvas is successfully drawn, then since both the parsed rich text data and the reference canvas are obtained, the corresponding parsed rich text data and the reference canvas can exist in the preset storage area. If the parsing process is successful but the canvas drawing fails, then since only the parsed rich text data is obtained, the corresponding parsed rich text data can exist in the preset storage area, but the corresponding reference canvas does not exist. If the parsing fails, then since neither the parsed rich text data nor the reference canvas is obtained, neither the corresponding parsed rich text data nor the reference canvas exists in the preset storage area.
[0090] In one implementation, if a processing failure occurs during the parsing or canvas rendering of rich text data using an asynchronous thread (such as failure to parse or render the rich text data), subsequent preprocessing operations on that rich text data can be terminated. Alternatively, the asynchronous thread corresponding to the failed operation can be stopped to prevent the same failure or exception from occurring when using the same thread again for preprocessing. After the exception in the asynchronous thread is resolved, preprocessing operations can resume using that thread.
[0091] In one implementation, the aforementioned method of calling an asynchronous thread to draw the rich text data on a canvas can be implemented as follows: First, an asynchronous thread can be called to obtain the layout configuration information corresponding to the rich text data. After obtaining this layout configuration information, it can be further used to draw the rich text data on a canvas to obtain a reference canvas for the rich text data. The layout configuration information can include the font, font size, emoticon size, image size, and edge distance between the rich text data as a whole and the page display interface, etc., of the text in the rich text data. Canvas drawing can include measurement, layout, and drawing operations. In one possible implementation, the main function of the measurement operation is to determine the size of each element included in the rich text data, such as measuring the height and width of each element. Here, the elements can be understood as images, emoticons, etc., included in the rich text data. The main function of the layout operation is to determine the position of each element included in the rich text data, such as the position of the text, the position of the emoticons, etc. The main function of the drawing operation is to draw each element onto the canvas, and the resulting canvas can be called the reference canvas. For example, the layout configuration of each element in the layout configuration information can be used to determine the layout of each element in the canvas, and each element can be drawn on the canvas. This canvas can be a temporary canvas, which can be obtained for display when rich text data needs to be displayed on the screen. Therefore, the reference canvas in this application can also be called a temporary canvas.
[0092] In one implementation, considering the storage space limitations of the preset storage area, the data stored in the preset storage area (such as reference canvas and parsed rich text data) can be updated to prevent the memory occupied from continuously expanding without limit. For example, some data in the preset storage space can be deleted, such as by using features like the number of times the data is used or the usage time. For instance, the LRU (Least Recently Used) algorithm can be used for expiration eviction, that is, data that has been used less frequently in the recent past can be deleted; or, some data can be deleted according to the usage time, such as deleting data with an earlier usage time. Other methods can also be used to reduce the storage space in the preset storage area, which are not specifically limited in this application.
[0093] Optionally, for a specific rich text data, if a reference canvas and parsed rich text data exist in the preset storage area, the parsed rich text data can be deleted. Considering that rich text data can be directly displayed using the reference canvas, and if a reference canvas exists in the preset storage area, there is no need to use parsed rich text data for display, then if both parsed rich text data and a reference canvas exist, the parsed rich text data can be deleted.
[0094] Optionally, a specific implementation method for deleting partial data based on usage counts can be as follows: When the storage space of a preset storage area meets preset conditions, the usage counts of page display data corresponding to each rich text data in the preset storage area can be counted to delete partial page display data based on usage counts. Here, page display data can refer to parsed rich text data or a reference canvas. For example, for a certain rich text data, if the preset storage area only stores the corresponding parsed rich text data, then the page display data can refer to the parsed rich text data; if the preset storage area stores the corresponding reference canvas, then the page display data can refer to the reference canvas. For instance, page display data with fewer usage counts can be deleted. In a specific implementation, each page display data can be sorted sequentially in ascending order of usage counts to obtain a sorting result for the page display data; then, the page display data in the top L positions of the sorting result can be deleted from the preset storage area. It can be understood that the page display data in the top L positions are those with fewer usage counts, and therefore, these less frequently used page display data can be deleted.
[0095] In one implementation, partial data can be deleted based on the usage time of the page display data. For example, data with earlier usage times can be deleted. A specific implementation of deleting partial data based on usage time can be as follows: when the storage space of a preset storage area meets preset conditions, the page display data can be sorted sequentially from earliest to latest usage time to obtain a sorting result for the page display data; then, the page display data in the top K positions of the sorting result can be deleted from the preset storage area. It can be understood that the page display data in the top K positions are the page display data with earlier usage times, and therefore, the page data with earlier usage times can be deleted.
[0096] In one implementation, multiple features can be combined to delete partial data. For example, the parsed rich text data that exists in both parsed rich text data and reference canvas rich text data can be deleted first. If, after deleting partial data using the previous method, the storage space in the preset storage area still needs to be deleted, further deletion can be performed based on usage count or usage time, in addition to the partial data deletion using the previous method.
[0097] Among them, the preset conditions can be set in advance, such as the current storage space reaching the upper limit of the storage space, or the current remaining storage space reaching the upper limit of the remaining storage space, or other conditions, which are not specifically limited in this application; the L value can be any value, such as 2, 3, etc., or the L value can be determined according to other determination methods; the K value can also be any value, such as 1, 3, etc., or the K value can be determined according to other determination methods.
[0098] To better understand the preprocessing stages described above, the following will combine... Figure 5a The process shown will be further explained. Preprocessing operations may include parsing, canvas drawing, and data storage.
[0099] like Figure 5a As shown, the preprocessing stage of rich text data may include the following steps:
[0100] S501, after receiving the data request response for the page, the original page data can be obtained, which may include one or more rich text data.
[0101] S502 can parse and process rich text data. For example, the parsing and processing can include processing non-text data in the rich text data, such as parsing and processing images, emoticons, tags, @ text, links, etc. in the rich text data.
[0102] S503, Check if the rich text data parsing process was successful. If the rich text data parsing process fails, the preprocessing operation can be terminated directly, or the preprocessing operation can be exited abnormally. If the rich text data parsing process is successful, the following steps S504 and S505 can be executed.
[0103] S504: If the rich text data parsing is successful, the parsing result can be stored, which is the parsed rich text data.
[0104] S505, if the rich text data parsing is successful, a temporary canvas (i.e., the reference canvas mentioned above) can be drawn on the parsed rich text data according to the layout configuration information. The drawing of the canvas can include measurement, layout and drawing operations to obtain the temporary canvas.
[0105] S506, Check whether the canvas for parsing the rich text data was drawn successfully. If the temporary canvas drawing fails, the preprocessing operation can be terminated directly, or the preprocessing operation can be exited abnormally. If the temporary canvas drawing is successful, the following step S507 can be executed.
[0106] S507 allows saving the temporary canvas if it is successfully drawn.
[0107] In one implementation, as described above, when preprocessing rich text data, if parsing is successful, the stored operation of the parsed rich text data can be performed; if the canvas is successfully drawn, the stored operation of the reference canvas can also be performed. In another implementation, if the canvas is successfully drawn, the stored operation of the reference canvas can be performed; if parsing is successful, the stored operation of the parsed rich text data is not performed. That is, only the reference canvas is stored in the preset storage area, and the parsed rich text data is not stored. Considering that the entire process of completing the page display requires first determining the parsed rich text data and then using the parsed rich text data to obtain the reference canvas, i.e., both the parsed rich text data and the reference canvas play a certain role in the process of displaying the page, it is advisable to prioritize storing both the parsed rich text data and the reference canvas. This application mainly describes the method of storing both the parsed rich text data and the reference canvas.
[0108] S405, when a data display requirement for the target rich text data is detected, if a reference canvas for the target rich text data exists in the preset storage area, the reference canvas for the target rich text data is obtained from the preset storage area and displayed on the screen using the reference canvas for the target rich text data.
[0109] S406 If there is no reference canvas for the target rich text data in the preset storage area, but there is parsed rich text data for the target rich text data, then the parsed rich text data for the target rich text data is obtained from the preset storage area and displayed on the screen using the parsed rich text data for the target rich text data.
[0110] The relevant descriptions of steps S405-S406 can be found in the descriptions of steps S201-S202 in the above embodiments, and will not be repeated here.
[0111] To better understand the above-mentioned on-screen display stage (i.e., the specific implementation in steps S405-S406), the following will be combined with... Figure 5b The process shown will be further explained. For example... Figure 5b As shown, the rich text data display stage may include the following steps:
[0112] S511, when the view is slid to be ready to be displayed, the view may refer to the target rich text data in this application, that is, when a data display requirement for the target rich text data is detected, step S512 can be executed.
[0113] S512, Detect that there is a temporary canvas cache corresponding to the target rich text data in the preset storage area. If a temporary canvas cache corresponding to the target rich text data is detected in the preset storage area, proceed to step S513; if no temporary canvas cache corresponding to the target rich text data is detected in the preset storage area, proceed to step S515.
[0114] S513, if a temporary canvas cache corresponding to the target rich text data is detected in a preset storage area, the temporary canvas is obtained.
[0115] S514 utilizes a temporary canvas to display target rich text data on the screen.
[0116] S515, if it is detected that there is no temporary canvas cache corresponding to the target rich text data in the preset storage area, further detect whether there is a parsed rich text data cache corresponding to the target rich text data in the preset storage area. If it is detected that there is a parsed rich text data cache corresponding to the target rich text data in the preset storage area, then proceed to step S516; if it is detected that there is no parsed rich text data cache corresponding to the target rich text data in the preset storage area, then proceed to step S517.
[0117] S516, if the cached rich text data is detected in the preset storage area, the rich text data can be obtained, and the main program can be called to draw the canvas (such as performing measurement, layout, drawing, etc.) on the rich text data to obtain the temporary canvas corresponding to the target rich text data; then step S514 is executed, that is, the target rich text data is displayed on the screen using the temporary canvas.
[0118] S517 If it is detected that there is no cached rich text data in the preset storage area, the main program can be directly called to parse and process the target rich text data and draw the canvas to obtain the corresponding temporary canvas, and then step S514 is executed, that is, the temporary canvas is used to display the target rich text data on the screen.
[0119] As can be seen, in asynchronous processing including parsing, after the raw page data returned from the background, the rich text data in the raw page data can be pre-parsed using regular expressions via an asynchronous thread. This includes local loading or network downloading of emoticons, images, etc., and customizing tag styles. When there is a need to display the page view, it can be checked whether the view (e.g., the view can be rich text data) has been parsed and cached. If it is cached, it can be used directly; otherwise, the main thread can be called to continue parsing and loading. It can be seen that by pre-parsing the rich text data, that is, by using regular expression parsing and other processing after the data is returned from the background, the calculation process when displaying the page data can be reduced.
[0120] In asynchronous processing, which includes parsing and canvas rendering, not only can rich text data be pre-parsed and cached, but canvas rendering can also be asynchronously pre-prepared. After the raw page data returned from the background, an asynchronous thread can be created to render a canvas for each piece of rich text data. For example, after parsing the rich text data, it can be measured and laid out according to the interface settings in the current scenario, and then drawn on this temporary canvas, which is cached simultaneously. When the page view (such as the rich text data) is displayed, it checks whether the rich text data already has a canvas cache. If a canvas cache exists, the canvas can be directly applied to the View, reducing performance overhead. If no canvas cache exists, it checks whether the parsed rich text data is cached. If it is, the parsed rich text data can be used to continue measurement, layout, and rendering. If no parsed rich text data is cached, the main thread can be called to perform parsing and rendering. It is evident that pre-processing the rich text data can reduce the computational process when displaying the entire page data on the screen; measuring, laying out, and drawing the already parsed rich text data can further reduce the view calculation and rendering process when displaying the data on the screen, thereby achieving rapid display.
[0121] To better understand the page display method proposed in the embodiments of this application, the following is combined with... Figure 5c The process shown further explains the method of displaying this page, such as... Figure 5c As shown, the page display method may include the following steps:
[0122] S521, after entering the page and displaying the requested original page data response packet, i.e. after obtaining the original page data, an asynchronous thread pool can be created to pass the rich text data in the original page data into the asynchronous thread pool so that the asynchronous threads in the asynchronous thread pool can be used to parse and process the rich text data later.
[0123] S522 can invoke an asynchronous thread to parse and process rich text data, such as regular expression matching. This parsing process can include parsing non-text data within the rich text data, such as images, emoticons, tags, @mentions, and links. The successfully parsed rich text data is then used for canvas rendering; that is, the parsed rich text data is measured, laid out, and drawn for the on-screen scenario to obtain a temporary canvas.
[0124] S523 allows for data storage during preprocessing operations. For example, the parsed rich text data and temporary canvas obtained from preprocessing operations (i.e., parsing and canvas drawing) can be stored in a pre-defined storage area. Optionally, an LRU algorithm can be used to evict expired data in the pre-defined storage area, preventing the memory usage from continuously expanding without limit.
[0125] S524, when a View (such as target rich text data) is scrolled by the user and needs to be displayed on the screen, a temporary canvas for the target rich text data can be retrieved from the preset storage area first. If the temporary canvas exists in the preset storage area, it can be retrieved and displayed directly on the screen. If there is no temporary canvas, it is further determined whether there is parsed rich text data in the preset storage area. If there is parsed rich text data, the main thread is called to perform canvas drawing (such as measurement, layout, drawing, etc.) on the parsed rich text data to obtain a temporary canvas for display on the screen. If neither a temporary canvas nor parsed rich text data can be retrieved in the preset storage area, parsing, measurement, layout, and drawing are performed in the current thread (i.e., the main thread) to obtain a temporary canvas and finally display it on the screen.
[0126] By implementing the above methods, two-level caching capabilities can be provided for rich text data parsing and canvas rendering, thereby improving page display speed and the display speed of rich text data, and ultimately enhancing the user experience. It also reduces scrolling lag when scrolling pages with large amounts of rich text data. The first-level caching capability refers to the pre-parsing and processing of rich text data. During background data transmission, regular expressions and other rules can be used for parsing and processing, reducing the computational process when the rich text data is displayed on screen. The second-level caching capability, based on the first-level caching, involves measuring, laying out, and drawing the View (canvas rendering) of the already parsed and processed rich text data, reducing the View calculation and rendering process when displaying the data on screen, thus achieving a faster display. These two levels of caching reduce the pressure on the main thread to process large amounts of data during the short time of display, thereby reducing the overall data calculation process when displaying the data on screen, improving page display speed and the display speed of rich text data, and ultimately enhancing the user experience.
[0127] Please see Figure 6 This is a schematic diagram of a page display device provided in an embodiment of this application. Optionally, this device can run on a computer device; for example, it can be a computer program running on the computer device. It is understood that this device can be used to execute corresponding steps in the methods provided in the embodiments of this application. Figure 6 As shown, the page display device described in this embodiment includes:
[0128] The first display unit 601 is used to, when a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, retrieve the reference canvas for the target rich text data from the preset storage area and display it on the screen using the reference canvas for the target rich text data.
[0129] The second display unit 602 is configured to, if there is no reference canvas for the target rich text data in the preset storage area, but there is parsed rich text data for the target rich text data, then obtain the parsed rich text data for the target rich text data from the preset storage area and display it on the screen using the parsed rich text data for the target rich text data.
[0130] In one implementation, the first display unit 601 is specifically used for:
[0131] Obtain the layout configuration information corresponding to the target rich text data;
[0132] Using the layout configuration information, a canvas is drawn on the parsed rich text data corresponding to the target rich text data to obtain the reference canvas of the target rich text data.
[0133] The target rich text data is displayed on the screen based on the reference canvas corresponding to it.
[0134] In one implementation, the second display unit 602 is specifically used for:
[0135] The identification information corresponding to the target rich text data is matched with the identification information in the preset storage area; any reference canvas in the preset storage area is associated with and stored with the corresponding identification information.
[0136] If the identifier information corresponding to the target rich text data is matched, it is determined that the preset storage area contains a reference canvas corresponding to the target rich text data.
[0137] In one implementation, the apparatus further includes a preprocessing unit 603, which is specifically used for:
[0138] Obtain the original page data, which includes one or more rich text data, and the target rich text data is contained in the one or more rich text data.
[0139] An asynchronous thread is invoked to parse and process each piece of rich text data;
[0140] For any rich text data in the one or more rich text data, if parsing and processing yields parsed rich text data corresponding to the rich text data, then the parsed rich text data corresponding to the rich text data is stored in the preset storage area, and the asynchronous thread is called to draw the canvas on the parsed rich text data.
[0141] If a reference canvas for the rich text data is drawn on the canvas, then the reference canvas corresponding to the rich text data is stored in the preset storage area.
[0142] In one implementation, the preprocessing unit 603 is specifically used for:
[0143] Obtain target indication information from the rich text data, wherein the target indication information is used to indicate non-textual data in the rich text data;
[0144] The non-text data corresponding to the target indication information is obtained based on regular expression matching rules;
[0145] The target indication information in the rich text data is replaced with the non-text data to obtain the parsed rich text data corresponding to the rich text data.
[0146] Obtain target indication information from the rich text data, wherein the target indication information is used to indicate non-textual data in the rich text data;
[0147] The non-text data corresponding to the target indication information is obtained based on regular expression matching rules;
[0148] The target indication information in the rich text data is replaced with the non-text data to obtain the parsed rich text data corresponding to the rich text data.
[0149] In one implementation, the preprocessing unit 603 is specifically used for:
[0150] When the storage space of the preset storage area meets the preset conditions, the number of times each reference canvas in the preset storage area is used is counted.
[0151] The reference canvases are sorted in ascending order of usage frequency to obtain the canvas sorting result;
[0152] The reference canvases that are in the top L positions of the canvas sorting result are deleted from the preset storage area, where L is a positive integer.
[0153] In one implementation, the number of asynchronous threads is N, the number of rich text data is M, and N is less than M, where N and M are both positive integers; the preprocessing unit 603 is specifically used for:
[0154] Select N rich text data from M rich text data, and parse and process the N rich text data according to N asynchronous threads;
[0155] When any one of the N asynchronous threads finishes parsing and processing the corresponding rich text data and drawing the canvas, the asynchronous thread is called to select a rich text data from the remaining rich text data for asynchronous parsing.
[0156] In one implementation, the device further includes a third display unit 604, which is specifically used for:
[0157] If there is no reference canvas for the target rich text data in the preset storage area, and there is no parsed rich text data for the target rich text data, then the target rich text data will be used for on-screen display.
[0158] It is understood that the division of units in this embodiment is illustrative and merely a logical functional division; in actual implementation, there may be other division methods. The functional units in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units can be implemented in hardware or as software functional units.
[0159] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device described in this embodiment can be a terminal or a server, and includes a processor 701 and a memory 702. Optionally, the computer device may also include a network interface 703. The processor 701, memory 702, and network interface 703 can exchange data.
[0160] The processor 701 described above can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0161] The aforementioned memory 702 may include read-only memory and random access memory, and provides program instructions and data to the processor 701. A portion of the memory 702 may also include non-volatile random access memory. The processor 701 executes the program instructions by calling them.
[0162] When a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, the reference canvas for the target rich text data is retrieved from the preset storage area and displayed on the screen using the reference canvas for the target rich text data.
[0163] If the reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data of the target rich text data exists, then the parsed rich text data of the target rich text data is obtained from the preset storage area and displayed on the screen using the parsed rich text data of the target rich text data.
[0164] In one implementation, the processor 701 is specifically used for:
[0165] Obtain the layout configuration information corresponding to the target rich text data;
[0166] Using the layout configuration information, a canvas is drawn on the parsed rich text data corresponding to the target rich text data to obtain the reference canvas of the target rich text data.
[0167] The target rich text data is displayed on the screen based on the reference canvas corresponding to it.
[0168] In one implementation, the processor 701 is specifically used for:
[0169] The identification information corresponding to the target rich text data is matched with the identification information in the preset storage area; any reference canvas in the preset storage area is associated with and stored with the corresponding identification information.
[0170] If the identifier information corresponding to the target rich text data is matched, it is determined that the preset storage area contains a reference canvas corresponding to the target rich text data.
[0171] In one implementation, the processor 701 is further configured to:
[0172] Obtain the original page data, which includes one or more rich text data, and the target rich text data is contained in the one or more rich text data.
[0173] An asynchronous thread is invoked to parse and process each piece of rich text data;
[0174] For any rich text data in the one or more rich text data, if parsing and processing yields parsed rich text data corresponding to the rich text data, then the parsed rich text data corresponding to the rich text data is stored in the preset storage area, and the asynchronous thread is called to draw the canvas on the parsed rich text data.
[0175] If a reference canvas for the rich text data is drawn on the canvas, then the reference canvas corresponding to the rich text data is stored in the preset storage area.
[0176] In one implementation, the processor 701 is specifically used for:
[0177] Obtain target indication information from the rich text data, wherein the target indication information is used to indicate non-textual data in the rich text data;
[0178] The non-text data corresponding to the target indication information is obtained based on regular expression matching rules;
[0179] The target indication information in the rich text data is replaced with the non-text data to obtain the parsed rich text data corresponding to the rich text data.
[0180] Obtain target indication information from the rich text data, wherein the target indication information is used to indicate non-textual data in the rich text data;
[0181] The non-text data corresponding to the target indication information is obtained based on regular expression matching rules;
[0182] The target indication information in the rich text data is replaced with the non-text data to obtain the parsed rich text data corresponding to the rich text data.
[0183] In one implementation, the processor 701 is specifically used for:
[0184] When the storage space of the preset storage area meets the preset conditions, the number of times each reference canvas in the preset storage area is used is counted.
[0185] The reference canvases are sorted in ascending order of usage frequency to obtain the canvas sorting result;
[0186] The reference canvases that are in the top L positions of the canvas sorting result are deleted from the preset storage area, where L is a positive integer.
[0187] In one implementation, the number of asynchronous threads is N, the number of rich text data is M, and N is less than M, where N and M are both positive integers; the processor 701 is specifically used for:
[0188] Select N rich text data from M rich text data, and parse and process the N rich text data according to N asynchronous threads;
[0189] When any one of the N asynchronous threads finishes parsing and processing the corresponding rich text data and drawing the canvas, the asynchronous thread is called to select a rich text data from the remaining rich text data for asynchronous parsing.
[0190] In one implementation, the processor 701 is further configured to:
[0191] If there is no reference canvas for the target rich text data in the preset storage area, and there is no parsed rich text data for the target rich text data, then the target rich text data will be used for on-screen display.
[0192] This application also provides a computer storage medium storing program instructions, which, when executed, may include, for example... Figure 2 or Figure 4 Some or all of the steps of the page display method in the corresponding embodiment.
[0193] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0194] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0195] This application also provides a computer program product or computer program that includes computer instructions that, when executed by a processor, can implement some or all of the steps in the methods described above. For example, the computer instructions are 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 in the embodiments of the methods described above.
[0196] The foregoing has provided a detailed description of a page display method, apparatus, computer device, medium, and program product provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A page display method, characterized in that, include: Obtain the original page data, which includes one or more rich text data, and the rich text data contains text data and non-text data. The main thread is invoked to process the non-rich text data in the original data of the page, and an asynchronous thread is invoked to parse and process each rich text data. For any rich text data in the one or more rich text data, if parsing and processing yields parsed rich text data corresponding to the rich text data, then the parsed rich text data corresponding to the rich text data is stored in a preset storage area, and the asynchronous thread is called to draw the canvas on the parsed rich text data. If a reference canvas for the rich text data is drawn on the canvas, then the reference canvas corresponding to the rich text data is stored in the preset storage area. When a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, the reference canvas for the target rich text data is retrieved from the preset storage area and displayed on the screen using the reference canvas for the target rich text data. The target rich text data is the rich text data in one or more rich text data; If the reference canvas for the target rich text data does not exist in the preset storage area, but parsed rich text data of the target rich text data exists, then the parsed rich text data of the target rich text data is obtained from the preset storage area and displayed on the screen using the parsed rich text data of the target rich text data.
2. The method according to claim 1, characterized in that, The step of parsing and displaying the rich text data using the target rich text data includes: Obtain the layout configuration information corresponding to the target rich text data; Using the layout configuration information, a canvas is drawn on the parsed rich text data corresponding to the target rich text data to obtain the reference canvas of the target rich text data. The target rich text data is displayed on the screen based on the reference canvas corresponding to it.
3. The method according to claim 1, characterized in that, Also includes: The identification information corresponding to the target rich text data is matched with the identification information in the preset storage area; any reference canvas in the preset storage area is associated with and stored with the corresponding identification information. If the identifier information corresponding to the target rich text data is matched, it is determined that the preset storage area contains a reference canvas corresponding to the target rich text data.
4. The method according to claim 1, characterized in that, The process of calling an asynchronous thread to parse and process the rich text data includes: Obtain target indication information from the rich text data, the target indication information being used to indicate non-textual data within the rich text data; The non-text data corresponding to the target indication information is obtained based on regular expression matching rules; The target indication information in the rich text data is replaced with the non-text data to obtain the parsed rich text data corresponding to the rich text data.
5. The method according to claim 1, further comprising: When the storage space of the preset storage area meets the preset conditions, the number of times each reference canvas in the preset storage area is used is counted. The reference canvases are sorted in ascending order of usage frequency to obtain the canvas sorting result; The reference canvases that are in the top L positions of the canvas sorting result are deleted from the preset storage area, where L is a positive integer.
6. The method according to claim 1, wherein the number of asynchronous threads is N, the number of rich text data is M, and N is less than M, wherein N and M are both positive integers; The process of calling an asynchronous thread to parse and process each piece of rich text data includes: Select N rich text data from M rich text data, and parse and process the N rich text data according to N asynchronous threads; When any one of the N asynchronous threads finishes parsing and processing the corresponding rich text data and drawing the canvas, the asynchronous thread is called to select a rich text data from the remaining rich text data for asynchronous parsing.
7. The method according to claim 1, characterized in that, Also includes: If there is no reference canvas for the target rich text data in the preset storage area, and there is no parsed rich text data for the target rich text data, then the target rich text data will be used for on-screen display.
8. A page display device, characterized in that, include: A preprocessing unit is used to obtain the original page data, which includes one or more rich text data, and the rich text data contains text data and non-text data. The main thread is invoked to process the non-rich text data in the original data of the page, and an asynchronous thread is invoked to parse and process each rich text data. The preprocessing unit is further configured to, for any rich text data in the one or more rich text data, if parsing and processing yields parsed rich text data corresponding to the rich text data, store the parsed rich text data corresponding to the rich text data in a preset storage area, and call the asynchronous thread to draw the parsed rich text data on a canvas. If a reference canvas for the rich text data is drawn on the canvas, then the reference canvas corresponding to the rich text data is stored in the preset storage area. The first display unit is configured to, when a data display requirement for target rich text data is detected, if a reference canvas for the target rich text data exists in a preset storage area, retrieve the reference canvas for the target rich text data from the preset storage area and display it on the screen using the reference canvas for the target rich text data. The target rich text data is the rich text data in one or more rich text data; The second display unit is configured to, if there is no reference canvas for the target rich text data in the preset storage area, but there is parsed rich text data for the target rich text data, then obtain the parsed rich text data for the target rich text data from the preset storage area and display it on the screen using the parsed rich text data for the target rich text data.
9. A computer device, characterized in that, The system includes a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1-7.
11. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the method of any one of claims 1-7.
Citation Information
Patent Citations
Page display method and page display device
CN106470351A
