Asynchronous page recording method based on HTML5 Canvas and medium

By using the asynchronous recording method in HTML5 Canvas page, combined with the collaborative work of the main thread and the worker thread, the problem of browser listening for Canvas changes is solved, the compatibility and stability of page recording is improved, and the storage cost is reduced.

CN118964770APending Publication Date: 2024-11-15TAIPING LIFE INSURANCE
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411003547.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

The prior art is difficult to monitor changes in Canvas tags in HTML5 pages, resulting in reduced page recording performance, poor compatibility and unstable pages.

Method used

Using the asynchronous page recording method based on HTML5 Canvas, by obtaining page recording tasks, analyzing the total number of samples, determining whether the browser supports the OffscreenCanvas interface, using the main thread and worker thread for Canvas conversion and data compression processing, ensuring the stability of the recording results and compatibility.

Benefits of technology

Improves the compatibility and stability of page recording, reduces storage costs, and avoids page performance degradation and lag problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964770A_ABST
    Figure CN118964770A_ABST
Patent Text Reader

Abstract

The invention discloses an asynchronous page recording method based on HTML5Canvas (hypertext markup language 5) and a medium. The method comprises the following steps: obtaining and analyzing a page recording task of a target browser to obtain a total frame number of page recording sampling; indicating the main thread to periodically acquire each current sampling page, judging whether the target browser supports an Offscene Canvas interface tool or not, obtaining a judgment result, and obtaining a Canvas conversion result; indicating a worker thread to carry out data conversion and compression processing on the current sampling asynchronous recording page to obtain each current sampling asynchronous recording page, and counting and updating the total frame number of the current sampling page; and judging whether the total frame number of the current sampling pages meets the total frame number of page recording sampling, if so, combining the current sampling asynchronous recording pages, and determining and feeding back a current sampling asynchronous recording page result corresponding to the page recording task. The problems of poor compatibility and instability of page recording are solved, and the compatibility and stability of page recording are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to an asynchronous page recording method and medium based on HTML5 Canvas. Background Art

[0002] As the requirements for page security become higher and higher, page recording has emerged, and the stability and compatibility of page recording are required to be high.

[0003] In the process of implementing the present invention, the inventors found that the prior art has the following defects: Currently, customer operations can be recorded imperceptibly in HTML5 pages, and the page recording images can be uploaded to the system at the same time. However, changes in Canvas tags are difficult to monitor, and they are usually recorded by generating snapshot images through timed sampling. This method will lead to reduced performance of HTML5 pages, affect user experience, and the page recording has poor compatibility and is unstable. Summary of the invention

[0004] The present invention provides an asynchronous page recording method and medium based on HTML5 Canvas, so as to improve the compatibility and stability of page recording and reduce storage costs.

[0005] According to one aspect of the present invention, there is provided an asynchronous page recording method based on HTML5 Canvas, which includes:

[0006] Obtaining a page recording task of a target browser, and parsing the page recording task to obtain a total number of page recording sampling frames;

[0007] Instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool, and obtain and match the corresponding Canvas conversion method according to the determination result to obtain the corresponding Canvas conversion result;

[0008] Instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each of the current sampling pages, and count and update the total number of frames of the current sampling page;

[0009] Determine whether the total number of frames of the current sampled page meets the total number of frames for page recording sampling. If so, combine the current sampled asynchronous recording pages, determine the current sampled asynchronous recording page result corresponding to the page recording task, and feed back the current sampled asynchronous recording page result to the user.

[0010] According to another aspect of the present invention, there is provided an asynchronous page recording device based on HTML5 Canvas, which includes:

[0011] A page recording sampling total frame number determination module is used to obtain the page recording task of the target browser, and parse the page recording task to obtain the page recording sampling total frame number;

[0012] A Canvas conversion result determination module is used to instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool, and obtain and match the corresponding Canvas conversion method according to the determination result to obtain the corresponding Canvas conversion result;

[0013] The current sampling asynchronous recording page determination module is used to instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each current sampling page, and count and update the total number of frames of the current sampling page;

[0014] The current sampling asynchronous recording page result determination module is used to determine whether the total number of frames of the current sampling page meets the total number of frame sampling for page recording. If so, the current sampling asynchronous recording pages are combined to determine the current sampling asynchronous recording page result corresponding to the page recording task, and the current sampling asynchronous recording page result is fed back to the user.

[0015] According to another aspect of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the asynchronous page recording method based on HTML5 Canvas as described in any embodiment of the present invention is implemented.

[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the asynchronous page recording method based on HTML5 Canvas described in any embodiment of the present invention when executed.

[0017] The technical solution of the embodiment of the present invention obtains the page recording task of the target browser and parses the page recording task to obtain the total frame number of page recording sampling; instructs the main thread to periodically obtain at least one current sampling page, and judges whether the target browser supports the OffscreenCanvas interface tool, obtains and matches the corresponding Canvas conversion method according to the judgment result, and obtains the corresponding Canvas conversion result; instructs the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain the current sampling asynchronous recording page corresponding to each current sampling page, counts and updates the total frame number of the current sampling page; judges whether the total frame number of the current sampling page meets the total frame number of page recording sampling, and if so, combines each current sampling asynchronous recording page to determine the current sampling asynchronous recording page result corresponding to the page recording task, and feeds back the current sampling asynchronous recording page result to the user. The problem of poor compatibility and instability of page recording is solved, the compatibility and stability of page recording are improved, and the storage cost is reduced.

[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0020] Figure 1 This is a flowchart of an asynchronous page recording method based on HTML5 Canvas provided according to Embodiment 1 of the present invention;

[0021] Figure 2 is a flowchart of another asynchronous page recording method based on HTML5 Canvas provided according to Embodiment 2 of the present invention;

[0022] Figure 3 is a flowchart of another asynchronous page recording method based on HTML5 Canvas provided according to Embodiment 3 of the present invention;

[0023] Figure 4 It is a structural diagram of an asynchronous page recording device based on HTML5 Canvas provided according to Embodiment 4 of the present invention;

[0024] Figure 5It is a structural schematic diagram of an electronic device provided according to Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0026] It should be noted that the terms "target", "current", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0027] Embodiment 1

[0028] Figure 1 A flowchart of an asynchronous page recording method based on HTML5 Canvas is provided for Embodiment 1 of the present invention. This embodiment is applicable to the case of recording a page. The method can be executed by an asynchronous page recording device based on HTML5 Canvas. The asynchronous page recording device based on HTML5 Canvas can be implemented in the form of hardware and / or software.

[0029] Correspondingly, such as Figure 1 As shown, the method includes:

[0030] S110, obtaining a page recording task of a target browser, and parsing the page recording task to obtain a total number of page recording sampling frames.

[0031] The target browser may be a browser supported on a terminal device or a server, and different browsers may support the OffscreenCanvas interface tool or may not support the OffscreenCanvas interface tool.

[0032] The page recording task is a task for recording a page on a target browser. Specifically, different page recording tasks correspond to different total page recording sampling frames, and the page recording tasks can be parsed to obtain the total page recording sampling frames.

[0033] S120, instructing the main thread to periodically obtain at least one current sample page, and determining whether the target browser supports the OffscreenCanvas interface tool, obtaining and matching a corresponding Canvas conversion method according to the determination result, and obtaining a corresponding Canvas conversion result.

[0034] The Canvas conversion result may be a conversion result obtained by performing Canvas conversion on each current sample page.

[0035] In this embodiment, it is first necessary to determine whether the target browser supports the OffscreenCanvas interface tool, and the determination result may include a determination result of supporting the OffscreenCanvas interface tool and a determination result of not supporting the OffscreenCanvas interface tool.

[0036] Specifically, different judgment results correspond to different Canvas conversion methods, thereby obtaining different Canvas conversion results.

[0037] S130, instructing the worker thread to perform data conversion and compression processing on the Canvas conversion result, to obtain the current sampling asynchronous recording page corresponding to each of the current sampling pages, and to count and update the total number of frames of the current sampling page.

[0038] The current sampled asynchronous recording page may be an asynchronous recording page obtained after processing each current sampled page, and the total number of frames of the current sampled page may be the total number of frames describing the current sampled page.

[0039] In this embodiment, it is necessary to instruct the worker thread to perform data conversion and compression processing on the obtained Canvas conversion result, so as to obtain the current sampled asynchronous recording page, and after processing the current sampled page, it is also necessary to count and update the total number of frames of the current sampled page.

[0040] S140. Determine whether the total number of frames of the current sampled page meets the total number of frames of the page recording sampled. If so, combine the current sampled asynchronous recording pages to determine the current sampled asynchronous recording page result corresponding to the page recording task, and feed back the current sampled asynchronous recording page result to the user.

[0041] The current sampled asynchronous recording page result may be a result of the asynchronous recording page corresponding to the page recording task.

[0042] Optionally, after determining whether the total number of frames of the current sampled page meets the total number of sampled frames recorded for the page, it also includes: if not, returning to execute the operation of instructing the main thread to periodically obtain at least one current sampled page until the total number of frames of the current sampled page meets the total number of sampled frames recorded for the page.

[0043] In this embodiment, it is assumed that the total number of frames of the current sampled page is M, and the total number of frames of the page recording sample is N. Assuming M=N, it means that the total number of frames of the current sampled page meets the total number of frames of the page recording sample, and the current sampled asynchronous recording pages can be combined to determine the current sampled asynchronous recording page result corresponding to the page recording task, and the current sampled asynchronous recording page result is fed back to the user.

[0044] Further, assuming that M<N, it means that the total number of frames of the current sampled page does not meet the total number of sampled frames of the page recording, and it is necessary to return to execute the operation of instructing the main thread to periodically obtain at least one current sampled page until the total number of frames of the current sampled page meets the total number of sampled frames of the page recording.

[0045] The advantage of this setting is that the current page recording task can be completed more accurately and comprehensively.

[0046] The technical solution of the embodiment of the present invention obtains the page recording task of the target browser and parses the page recording task to obtain the total frame number of page recording sampling; instructs the main thread to periodically obtain at least one current sampling page, and judges whether the target browser supports the OffscreenCanvas interface tool, obtains and matches the corresponding Canvas conversion method according to the judgment result, and obtains the corresponding Canvas conversion result; instructs the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain the current sampling asynchronous recording page corresponding to each current sampling page, counts and updates the total frame number of the current sampling page; judges whether the total frame number of the current sampling page meets the total frame number of page recording sampling, and if so, combines each current sampling asynchronous recording page to determine the current sampling asynchronous recording page result corresponding to the page recording task, and feeds back the current sampling asynchronous recording page result to the user. The problem of poor compatibility and instability of page recording is solved, the compatibility and stability of page recording are improved, and the storage cost is reduced.

[0047] Embodiment 2

[0048] Figure 2A flowchart of another asynchronous page recording method based on HTML5 Canvas is provided for Embodiment 2 of the present invention. This embodiment is refined based on the above embodiments. In this embodiment, the corresponding Canvas conversion method is matched according to the judgment result to obtain the corresponding Canvas conversion result.

[0049] S210: Obtain a page recording task of a target browser, and parse the page recording task to obtain a total number of page recording sampling frames.

[0050] S220, instructing the main thread to periodically obtain at least one current sample page, and determining whether the target browser supports the OffscreenCanvas interface tool, and obtaining a determination result.

[0051] S230: If the judgment result is that the OffscreenCanvas interface tool judgment result is supported, instruct the main thread to obtain Canvas bitmap information corresponding to each of the current sampling pages by calling the CreateImageBitmap method.

[0052] S240, instructing the browser thread to perform data conversion on each Canvas bitmap information respectively through the Canvas conversion method to obtain each Canvas bitmap data.

[0053] S250 , instructing the main thread to determine a Canvas conversion result according to each Canvas bitmap data, and sending the Canvas conversion result to the worker thread.

[0054] In this embodiment, the amount of computation required to convert and compress the data of the Canvas conversion result is relatively large. If it is processed in the main thread, it may cause the main thread to be blocked. Therefore, the Canvas conversion result needs to be sent to the worker thread to reduce the computing load of the main thread.

[0055] S260, instructing the worker thread to perform data conversion and compression processing on the Canvas conversion result, to obtain the current sampling asynchronous recording page corresponding to each of the current sampling pages, and to count and update the total number of frames of the current sampling page.

[0056] Optionally, the instructing the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain a current sampling asynchronous recording page corresponding to each current sampling page, including: instructing the worker thread to perform data conversion on each Canvas bitmap data in the Canvas conversion result through the OffscreenCanvas interface tool to obtain each first Blob data; instructing the worker thread to convert each first Blob data into first ArrayBuffer format data through the Blob.ArrayBuffer method; instructing the worker thread to perform base64 encoding on each first ArrayBuffer format data to obtain each first base64 encoded data; instructing the worker thread to perform compression processing on each first base64 encoded data through the Huffman algorithm to obtain a current sampling asynchronous recording page corresponding to each current sampling page.

[0057] In this embodiment, the binary data of each Canvas bitmap data needs to be converted into a data format to obtain a Blob data format, that is, to obtain each first Blob data, and further converted into a first ArrayBuffer format data and base64 encoded to obtain first base64 encoded data.

[0058] Correspondingly, each first base64 encoded data is compressed to obtain the current sample asynchronous recording page.

[0059] Optionally, the instructing worker thread to compress each first base64 encoded data through the Huffman algorithm to obtain a current sampling asynchronous recording page corresponding to each current sampling page, including: instructing the worker thread to compress each first base64 encoded data through the Huffman algorithm to obtain each first base64 encoded compressed data; instructing the worker thread to transfer each first base64 encoded compressed data to the main thread; instructing the main thread to generate a current sampling asynchronous recording page corresponding to each current sampling page according to each first base64 encoded compressed data.

[0060] In this embodiment, the worker thread performs compression processing through the Huffman algorithm to obtain each first base64 encoded compressed data and transmits it to the main thread. Further, the current sample asynchronous recording page can be generated through each received first base64 encoded compressed data.

[0061] S270. Determine whether the total number of frames of the current sampled page meets the total number of frames of the page recording sampled. If so, combine the current sampled asynchronous recording pages to determine the current sampled asynchronous recording page result corresponding to the page recording task, and feed back the current sampled asynchronous recording page result to the user.

[0062] The technical solution of the embodiment of the present invention obtains the page recording task of the target browser and parses the page recording task to obtain the total frame number of the page recording sampling; instructs the main thread to periodically obtain at least one current sampling page, and judges whether the target browser supports the OffscreenCanvas interface tool to obtain the judgment result; if the judgment result is that the OffscreenCanvas interface tool is supported, instructs the main thread to obtain the Canvas bitmap information corresponding to each of the current sampling pages by calling the CreatelmageBitmap method; instructs the browser thread to convert the data of each Canvas bitmap information by using the Canvas conversion method. Convert to obtain each Canvas bitmap data; instruct the main thread to determine the Canvas conversion result according to each Canvas bitmap data, and send the Canvas conversion result to the worker thread; instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain the current sampling asynchronous recording page corresponding to each current sampling page, count and update the total number of frames of the current sampling page; determine whether the total number of frames of the current sampling page meets the total number of frames of page recording sampling, and if so, combine the current sampling asynchronous recording pages to determine the current sampling asynchronous recording page result corresponding to the page recording task, and feedback the current sampling asynchronous recording page result to the user. Improve the compatibility and stability of page recording, reduce storage costs, improve image processing performance, and avoid page jams.

[0063] Embodiment 3

[0064] Figure 3 A flowchart of another asynchronous page recording method based on HTML5 Canvas is provided for Embodiment 2 of the present invention. This embodiment is refined based on the above embodiments. In this embodiment, the corresponding Canvas conversion method is matched according to the judgment result to obtain the corresponding Canvas conversion result.

[0065] S310: Obtain a page recording task of a target browser, and parse the page recording task to obtain a total number of page recording sampling frames.

[0066] S320: Instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool to obtain a determination result.

[0067] S330: If the judgment result is that the OffscreenCanvas interface tool judgment result is not supported, instruct the main thread to convert the Canvas content corresponding to each of the current sampled pages into Blob content by calling the Canvas.toBlob method.

[0068] In this embodiment, the Canvas.toBlob method is an asynchronous method. By calling the Canvas.toBlob asynchronous method, the blocking problem of the main thread can be avoided.

[0069] S340, instructing the browser thread to perform data conversion on each Blob content respectively through the Canvas conversion method to obtain each second Blob data.

[0070] S350 , instructing the main thread to determine a Canvas conversion result according to each second Blob data, and sending the Canvas conversion result to the worker thread.

[0071] In this embodiment, the amount of computation required to convert and compress the data of the Canvas conversion result is relatively large. If it is processed in the main thread, it may cause the main thread to be blocked. Therefore, the Canvas conversion result needs to be sent to the worker thread to reduce the computing load of the main thread.

[0072] S360, instructing the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each of the current sampling pages, and count and update the total number of frames of the current sampling page.

[0073] Optionally, the instructing the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain a current sampling asynchronous recording page corresponding to each of the current sampling pages, including: instructing the worker thread to convert each of the second Blob data into second ArrayBuffer format data through the Blob.ArrayBuffer method; instructing the worker thread to perform base64 encoding on each of the second ArrayBuffer format data to obtain each second base64 encoded data; instructing the worker thread to perform compression processing on each of the second base64 encoded data through the Huffman algorithm to obtain a current sampling asynchronous recording page corresponding to each of the current sampling pages.

[0074] In this embodiment, the worker thread converts each second Blob data into second ArrayBuffer format data through the Blob.ArrayBuffer method, and performs base64 encoding and compression processing to obtain each second base64 encoded compressed data, and transmits each second base64 encoded compressed data to the main thread.

[0075] Furthermore, the main thread generates current sampling asynchronous recording pages corresponding to each current sampling page according to each first base64 encoded compressed data.

[0076] S370. Determine whether the total number of frames of the current sampled page meets the total number of frames of the page recording sampled. If so, combine the current sampled asynchronous recording pages, determine the current sampled asynchronous recording page result corresponding to the page recording task, and feed back the current sampled asynchronous recording page result to the user.

[0077] The technical solution of the embodiment of the present invention obtains the page recording task of the target browser and parses the page recording task to obtain the total frame number of the page recording sampling; instructs the main thread to periodically obtain at least one current sampling page, and judges whether the target browser supports the OffscreenCanvas interface tool to obtain a judgment result; if the judgment result is that the OffscreenCanvas interface tool is not supported, instructs the main thread to convert the Canvas content corresponding to each of the current sampling pages into Blob content by calling the Canvas.toBlob method; instructs the browser thread to convert each Blob content into a digital Blob content by using the Canvas conversion method. According to the conversion, the second Blob data is obtained; the main thread is instructed to determine the Canvas conversion result according to the second Blob data, and the Canvas conversion result is sent to the worker thread; the worker thread is instructed to perform data conversion and compression processing on the Canvas conversion result to obtain the current sampling asynchronous recording page corresponding to each current sampling page, and the total number of frames of the current sampling page is counted and updated; it is determined whether the total number of frames of the current sampling page meets the total number of frames of the page recording sampling, and if so, the current sampling asynchronous recording pages are combined to determine the current sampling asynchronous recording page result corresponding to the page recording task, and the current sampling asynchronous recording page result is fed back to the user. The compatibility and stability of page recording are improved, the storage cost is reduced, the image processing performance is improved, and the page jamming is avoided.

[0078] Embodiment 4

[0079] Figure 4This is a schematic diagram of the structure of an asynchronous page recording device based on HTML5 Canvas provided in Embodiment 4 of the present invention. The asynchronous page recording device based on HTML5 Canvas provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal device or a server to implement an asynchronous page recording method based on HTML5 Canvas in an embodiment of the present invention. Figure 4 As shown, the device includes: a page recording sampling total frame number determination module 410, a Canvas conversion result determination module 420, a current sampling asynchronous recording page determination module 430 and a current sampling asynchronous recording page result determination module 440.

[0080] The page recording sampling total frame number determination module 410 is used to obtain the page recording task of the target browser, and parse the page recording task to obtain the page recording sampling total frame number;

[0081] The Canvas conversion result determination module 420 is used to instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool, and obtain and match the corresponding Canvas conversion method according to the determination result to obtain the corresponding Canvas conversion result;

[0082] The current sampling asynchronous recording page determination module 430 is used to instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each current sampling page, and count and update the total number of frames of the current sampling page;

[0083] The current sampling asynchronous recording page result determination module 440 is used to determine whether the total number of frames of the current sampling page meets the total number of frame sampling of the page recording. If so, the current sampling asynchronous recording pages are combined to determine the current sampling asynchronous recording page result corresponding to the page recording task, and the current sampling asynchronous recording page result is fed back to the user.

[0084] The technical solution of the embodiment of the present invention obtains the page recording task of the target browser and parses the page recording task to obtain the total frame number of page recording sampling; instructs the main thread to periodically obtain at least one current sampling page, and judges whether the target browser supports the OffscreenCanvas interface tool, obtains and matches the corresponding Canvas conversion method according to the judgment result, and obtains the corresponding Canvas conversion result; instructs the worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain the current sampling asynchronous recording page corresponding to each current sampling page, counts and updates the total frame number of the current sampling page; judges whether the total frame number of the current sampling page meets the total frame number of page recording sampling, and if so, combines each current sampling asynchronous recording page to determine the current sampling asynchronous recording page result corresponding to the page recording task, and feeds back the current sampling asynchronous recording page result to the user. The problem of poor compatibility and instability of page recording is solved, the compatibility and stability of page recording are improved, and the storage cost is reduced.

[0085] On the basis of the above embodiments, it also includes a return execution module, which can be specifically used to: after judging whether the total number of frames of the current sampled page meets the total number of sampled frames of the page recording, if the total number of frames of the current sampled page does not meet the total number of sampled frames of the page recording, return to execute the operation of instructing the main thread to periodically obtain at least one current sampled page until the total number of frames of the current sampled page meets the total number of sampled frames of the page recording.

[0086] On the basis of the above embodiments, the Canvas conversion result determination module 420 can be specifically used to: if the judgment result is that the OffscreenCanvas interface tool judgment result is supported, instruct the main thread to obtain the Canvas bitmap information corresponding to each of the current sampling pages by calling the CreatelmageBitmap method; instruct the browser thread to perform data conversion on each Canvas bitmap information respectively through the Canvas conversion method to obtain each Canvas bitmap data; instruct the main thread to determine the Canvas conversion result according to each Canvas bitmap data, and send the Canvas conversion result to the worker thread.

[0087] On the basis of the above embodiments, the current sampling asynchronous recording page determination module 430 can be specifically used to: instruct the worker thread to perform data conversion on each Canvas bitmap data in the Canvas conversion result through the OffscreenCanvas interface tool to obtain each first Blob data; instruct the worker thread to convert each first Blob data into first ArrayBuffer format data through the Blob.ArrayBuffer method; instruct the worker thread to perform base64 encoding on each first ArrayBuffer format data to obtain each first base64 encoded data; instruct the worker thread to perform compression processing on each first base64 encoded data through the Huffman algorithm to obtain the current sampling asynchronous recording page corresponding to each current sampling page.

[0088] On the basis of the above embodiments, the current sampling asynchronous recording page determination module 430 can also be specifically used to: instruct the worker thread to compress each first base64 encoded data through the Huffman algorithm to obtain each first base64 encoded compressed data; instruct the worker thread to transfer each first base64 encoded compressed data to the main thread; instruct the main thread to generate a current sampling asynchronous recording page corresponding to each current sampling page according to each first base64 encoded compressed data.

[0089] On the basis of the above embodiments, the Canvas conversion result determination module 420 can be specifically used to: if the judgment result is that the OffscreenCanvas interface tool judgment result is not supported, instruct the main thread to convert the Canvas content corresponding to each of the current sampling pages into Blob content by calling the Canvas.toBlob method; instruct the browser thread to perform data conversion on each Blob content respectively through the Canvas conversion method to obtain each second Blob data; instruct the main thread to determine the Canvas conversion result according to each second Blob data, and send the Canvas conversion result to the worker thread.

[0090] On the basis of the above embodiments, the current sampling asynchronous recording page determination module 430 can be specifically used to: instruct the worker thread to convert each second Blob data into second ArrayBuffer format data through the Blob.ArrayBuffer method; instruct the worker thread to base64 encode each second ArrayBuffer format data to obtain each second base64 encoded data; instruct the worker thread to compress each second base64 encoded data through the Huffman algorithm to obtain the current sampling asynchronous recording page corresponding to each current sampling page.

[0091] The HTML5 Canvas-based asynchronous page recording device provided in the embodiment of the present invention can execute the HTML5 Canvas-based asynchronous page recording method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0092] Embodiment 5

[0093] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement the fifth embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0094] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0095] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0096] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as an asynchronous page recording method based on HTML5 Canvas.

[0097] In some embodiments, the asynchronous page recording method based on HTML5 Canvas can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the asynchronous page recording method based on HTML5 Canvas described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the asynchronous page recording method based on HTML5 Canvas in any other appropriate manner (for example, by means of firmware).

[0098] The method comprises: obtaining a page recording task of a target browser, parsing the page recording task, and obtaining a total frame number of page recording sampling; instructing a main thread to periodically obtain at least one current sampling page, and judging whether the target browser supports the OffscreenCanvas interface tool, obtaining and matching a corresponding Canvas conversion method according to the judgment result, and obtaining a corresponding Canvas conversion result; instructing a worker thread to perform data conversion and compression processing on the Canvas conversion result, and obtaining a current sampling asynchronous recording page corresponding to each of the current sampling pages, and counting and updating the total frame number of the current sampling page; judging whether the total frame number of the current sampling page meets the total frame number of page recording sampling, and if so, combining each of the current sampling asynchronous recording pages, determining a current sampling asynchronous recording page result corresponding to the page recording task, and feeding back the current sampling asynchronous recording page result to a user.

[0099] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0100] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0101] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0102] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0103] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0104] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0105] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0106] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

[0107] Embodiment 6

[0108] Embodiment 6 of the present invention also provides a computer-readable storage medium, wherein the computer-readable instructions are used to execute an asynchronous page recording method based on HTML5 Canvas when executed by a computer processor, the method comprising: obtaining a page recording task of a target browser, and parsing the page recording task to obtain a total frame number of page recording sampling; instructing a main thread to periodically obtain at least one current sampling page, and determine whether the target browser supports the OffscreenCanvas interface tool, obtain and match the corresponding Canvas conversion method according to the determination result, and obtain a corresponding Canvas conversion result; instructing a worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain a current sampling asynchronous recording page corresponding to each of the current sampling pages, and counting and updating the total frame number of the current sampling page; determining whether the total frame number of the current sampling page meets the total frame number of page recording sampling, and if so, combining the current sampling asynchronous recording pages to determine the current sampling asynchronous recording page result corresponding to the page recording task, and feeding back the current sampling asynchronous recording page result to the user.

[0109] Of course, the computer-readable storage medium provided in the embodiment of the present invention has computer-executable instructions that are not limited to the method operations described above, and can also execute related operations in the asynchronous page recording method based on HTML5 Canvas provided in any embodiment of the present invention.

[0110] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (FLASH), a hard disk or an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0111] It is worth noting that in the above-mentioned embodiment of the asynchronous page recording device based on HTML5 Canvas, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0112] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. An asynchronous page recording method based on HTML5 Canvas, It is characterized in that include: Obtaining a page recording task of a target browser, and parsing the page recording task to obtain a total number of page recording sampling frames; Instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool, and obtain and match the corresponding Canvas conversion method according to the determination result to obtain the corresponding Canvas conversion result; Instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each of the current sampling pages, and count and update the total number of frames of the current sampling page; Determine whether the total number of frames of the current sampled page meets the total number of frames for page recording sampling. If so, combine the current sampled asynchronous recording pages, determine the current sampled asynchronous recording page result corresponding to the page recording task, and feed back the current sampled asynchronous recording page result to the user.

2. The method according to claim 1, It is characterized in that After determining whether the total number of frames of the current sampled page meets the total number of frames of the page recording sampled, the method further includes: If not, the process returns to executing the operation of instructing the main thread to periodically obtain at least one current sampled page until the total number of frames of the current sampled page meets the total number of frames of the page recording sample.

3. The method according to claim 2, It is characterized in that According to the judgment result, the corresponding Canvas conversion method is matched to obtain the corresponding Canvas conversion result, including: If the judgment result is that the OffscreenCanvas interface tool judgment result is supported, instruct the main thread to obtain Canvas bitmap information corresponding to each of the current sampling pages by calling the CreateImageBitmap method; Instruct the browser thread to convert the bitmap information of each Canvas through the Canvas conversion method to obtain the bitmap data of each Canvas; Instruct the main thread to determine a Canvas conversion result according to each Canvas bitmap data, and send the Canvas conversion result to the worker thread.

4. The method according to claim 3, It is characterized in that The instructing worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain a current sampling asynchronous recording page corresponding to each current sampling page, including: Instructing the worker thread to perform data conversion on each Canvas bitmap data in the Canvas conversion result through the OffscreenCanvas interface tool to obtain each first Blob data; Instruct the worker thread to convert each of the first Blob data into first ArrayBuffer format data respectively through the Blob.ArrayBuffer method; Instruct the worker thread to perform base64 encoding on each first ArrayBuffer format data to obtain each first base64 encoded data; Instruct the worker thread to compress each first base64 encoded data through the Huffman algorithm to obtain the current sampling asynchronous recording page corresponding to each current sampling page.

5. The method according to claim 4, It is characterized in that The instructing worker thread to compress each first base64 encoded data by using the Huffman algorithm to obtain a current sample asynchronous recording page corresponding to each current sample page, including: Instruct the worker thread to compress each first base64 encoded data by using the Huffman algorithm to obtain each first base64 encoded compressed data; Instruct the worker thread to transfer each first base64 encoded compressed data to the main thread; Instruct the main thread to generate a current sampling asynchronous recording page corresponding to each current sampling page according to each first base64 encoded compressed data.

6. The method according to claim 2, It is characterized in that According to the judgment result, the corresponding Canvas conversion method is matched to obtain the corresponding Canvas conversion result, including: If the judgment result is that the OffscreenCanvas interface tool judgment result is not supported, instructing the main thread to convert the Canvas content corresponding to each of the current sampled pages into Blob content by calling the Canvas.toBlob method; Instruct the browser thread to perform data conversion on each Blob content through the Canvas conversion method to obtain each second Blob data; Instruct the main thread to determine a Canvas conversion result according to each second Blob data, and send the Canvas conversion result to the worker thread.

7. The method according to claim 6, It is characterized in that The instructing worker thread to perform data conversion and compression processing on the Canvas conversion result to obtain a current sampling asynchronous recording page corresponding to each current sampling page, including: Instruct the worker thread to convert each of the second Blob data into second ArrayBuffer format data respectively through the Blob.ArrayBuffer method; Instruct the worker thread to perform base64 encoding on each second ArrayBuffer format data to obtain each second base64 encoded data; Instruct the worker thread to compress each second base64 encoded data through the Huffman algorithm to obtain the current sampling asynchronous recording page corresponding to each current sampling page.

8. An asynchronous page recording device based on HTML5 Canvas, It is characterized in that include: A page recording sampling total frame number determination module is used to obtain the page recording task of the target browser, and parse the page recording task to obtain the page recording sampling total frame number; A Canvas conversion result determination module is used to instruct the main thread to periodically obtain at least one current sample page, and determine whether the target browser supports the OffscreenCanvas interface tool, and obtain and match the corresponding Canvas conversion method according to the determination result to obtain the corresponding Canvas conversion result; The current sampling asynchronous recording page determination module is used to instruct the worker thread to perform data conversion and compression processing on the Canvas conversion result, obtain the current sampling asynchronous recording page corresponding to each current sampling page, and count and update the total number of frames of the current sampling page; The current sampling asynchronous recording page result determination module is used to determine whether the total number of frames of the current sampling page meets the total number of frame sampling for page recording. If so, the current sampling asynchronous recording pages are combined to determine the current sampling asynchronous recording page result corresponding to the page recording task, and the current sampling asynchronous recording page result is fed back to the user.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the asynchronous page recording method based on HTML5 Canvas is implemented as described in any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement an asynchronous page recording method based on HTML5 Canvas as described in any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • Method for optimizing Canvas performance of HTML5 based on multiple threads

    CN107193952A

  • Recording system, method and equipment of browser and storage medium

    CN117632652A

  • Task processing method and apparatus, electronic device, storage medium, and computer program

    WO2023045207A1