Data playing method and device, electronic equipment and storage medium
By adaptively adjusting the rendered data volume, the page lag caused by the large amount of data sensor of the intelligent traffic vehicle is solved, and the smoothness of data playback is achieved.
Patent Information
- Application Number
- CN202510052676.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-06-06
Smart Images

Figure CN120104902A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of browser technology, and in particular to a method, device, electronic device and storage medium for playing data. Background Art
[0002] The sensors in the intelligent transportation vehicles will collect signal data during their driving process and report it to the cloud. When there is a need to detect the intelligent transportation vehicles, the above signal data can be presented in a visual manner.
[0003] In the related art, the terminal obtains the signal data reported by the sensors in the intelligent transportation vehicle from the cloud, and then renders and displays the signal data. However, the amount of signal data collected by each sensor during the driving of the intelligent transportation vehicle is huge, which causes page freezes during the data playback process. Summary of the invention
[0004] The present application proposes a method, device, electronic device and storage medium for playing data.
[0005] In a first aspect, an embodiment of the present application provides a method for playing data, the method comprising: obtaining data of a target task; determining a rendering data volume, the rendering data volume being negatively correlated with a historical rendering time of data of a preset data volume rendered by a browser in a terminal; obtaining data of the rendering data volume from the data of the target task for rendering to obtain rendering data; and playing the rendering data.
[0006] In a second aspect, an embodiment of the present application provides a device for playing data, the device comprising: a data acquisition module, used to acquire data of a target task; a quantity determination module, used to determine the amount of rendering data, the amount of rendering data is negatively correlated with the historical rendering time of data of a preset amount of data rendered by a browser in a terminal; a data rendering module, used to acquire the data of the rendering data amount from the data of the target task for rendering to obtain rendering data; and a playback module, used to play the rendering data.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory; one or more processors coupled to the memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method described in the first aspect.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer program instructions are stored. The computer program instructions can be called by a processor to execute the method described in the first aspect.
[0009] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when instructions in the computer program product are executed, is used to implement the method described in the first aspect.
[0010] Compared with the prior art, the technical solution provided in the embodiment of the present application, after obtaining the data of the target task, will determine the amount of rendering data required to be rendered for this rendering task, and then render and play the data of the rendering data obtained in the data of the target task, wherein the amount of rendering data is negatively correlated with the historical rendering time of the browser rendering the preset data amount in the terminal, the longer the historical rendering time of the browser rendering the preset data amount, the smaller the rendering data amount, and the shorter the historical rendering time of the browser rendering the preset data amount, the larger the rendering data amount. That is, in each rendering task, the terminal will adaptively adjust the amount of rendering data required to be rendered this time based on the historical rendering time of the browser rendering the preset data amount. When the data amount of the target task is large, the browser can also select an appropriate amount of data for rendering to avoid page freezes due to excessive data volume. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0012] Figure 1 It is a schematic diagram of an implementation environment provided by an embodiment of the present application.
[0013] Figure 2 This is a flowchart of a method for playing data provided by an embodiment of the present application.
[0014] Figure 3 This is a flowchart of a method for playing data provided by another embodiment of the present application.
[0015] Figure 4 This is a flowchart of a method for playing data provided by another embodiment of the present application.
[0016] Figure 5 This is a flowchart of a method for playing data provided by another embodiment of the present application.
[0017] Figure 6 It is a block diagram of a device for playing data provided by an embodiment of the present application.
[0018] Figure 7 It is a structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0019] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0020] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0021] Please refer to Figure 1 , which shows a schematic diagram of an implementation environment provided by an embodiment of the present application. The implementation environment includes a terminal 110.
[0022] The terminal 110 is used to realize the visualization display of data. The terminal 110 can be a personal computer, a tablet computer, etc. The terminal 110 includes a player, through which the above signal data is played. In addition, the terminal 110 also includes a wireless communication module for realizing data transmission between other electronic devices. Optionally, the terminal 110 is installed with a browser, and the browser can realize two-way, real-time communication with the server based on the Websocket protocol. Optionally, the browser includes a database that can store a large amount of data, and the database is an indexedDB database.
[0023] In some embodiments, the implementation environment further includes a server 120 and a transportation vehicle 130. In this embodiment, the terminal 110 is used to realize the visual display of signal data collected by the transportation vehicle 130 during driving.
[0024] The transportation vehicle 130 may be a vehicle or an aircraft. In the embodiment of the present application, the transportation vehicle 130 is only taken as a vehicle for example. The transportation vehicle 130 includes a variety of sensors, such as a wheel speed sensor, an angular velocity sensor, an acceleration sensor, a temperature sensor, etc. During the driving process of the transportation vehicle 130, the above sensors periodically collect corresponding signal data, and the transportation vehicle 130 reports the signal data collected by the above sensors to the server 120.
[0025] There is a wireless communication connection between the server 120 and the transportation vehicle 130 to receive and store the signal data reported by the transportation vehicle 130. There is also a wireless communication connection between the server 120 and the terminal 110 to send the signal data of the transportation vehicle 130 to the terminal 110. The server 120 can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center.
[0026] Please refer to Figure 2 , which shows a flow chart of a method for playing data provided by an embodiment of the present application. The method includes the following process.
[0027] S201, obtaining data of a target task.
[0028] The target task is a playback task, which is usually established by a user. The data of the target task is the data to be rendered, such as multimedia data, driving data of a transportation vehicle, etc. In the embodiment of the present application, only the driving data of the target transportation vehicle is used as an example for explanation.
[0029] The target vehicle can be any vehicle, which can be selected by the user. In some embodiments, the terminal includes a vehicle identification list, which includes multiple unique identifications of vehicles, and the terminal determines the vehicle corresponding to the unique identification of the selected signal as the target vehicle. The unique identification of the above-mentioned vehicle can be a license plate number or a frame number. In other embodiments, the terminal includes an input box, and the terminal determines the vehicle corresponding to the unique identification entered in the input box as the target vehicle.
[0030] Driving data refers to the signal data collected by sensors in a vehicle during its driving process, such as wheel speed collected by a wheel speed sensor, point cloud data collected by a radar, acceleration collected by an acceleration sensor, and so on.
[0031] In some embodiments, the browser in the terminal establishes a WebSocket connection with the server, and obtains the target data based on the WebSocket connection. In this embodiment, the terminal is in a real-time data playback scenario. WebSocket is a protocol for full-duplex communication on a single TCP connection. The browser and the server only need to complete a handshake, and a persistent connection can be directly created between the two, and two-way data transmission can be performed, making the data exchange between the client and the server easier. The process of establishing a WebSocket connection specifically includes: the browser creates a RealWebSocket object, then executes its connect() method to establish a connection, and then sends an HTTP request to the server. The server returns a response message based on the HTTP request, and the browser and the server successfully establish a WebSocket connection.
[0032] Optionally, before establishing a WebSocket connection with the server, the terminal further performs the following steps:
[0033] 1. Establish a data playback task (also known as the target task) for the target transportation vehicle and generate a unique identifier for the task; 2. Create an empty data set and a data set update record, where the empty data set is used to store data for rendering visual charts, and the data set update record is used to save the starting timestamp and data length of each inserted time series data; 3. Create a thread, which is used to decompress and render the driving data of the target transportation vehicle; 4. Create a task queue, and each time the terminal receives driving data, it pushes the received driving data into the task queue.
[0034] In other embodiments, the terminal reads the travel data of the target vehicle from the local cache data. In this embodiment, the terminal is in the historical data playback scene.
[0035] Prior to this, the terminal also performs the following steps: 1. Determine the target transportation vehicle, and determine the task to be played back in the playback record of the target transportation vehicle; 2. Create an empty data set and a data set update record, wherein the empty data set is used to store data for rendering visual charts, and the data set update record is used to save the starting timestamp and data length of each inserted time series data; 3. Create a thread, which is used to decompress and render the driving data of the target transportation vehicle.
[0036] S202: Determine the amount of rendering data.
[0037] The amount of data to be rendered is negatively correlated with the historical rendering time of the data of the preset amount of data rendered by the browser in the terminal, that is, the longer the historical rendering time of the data of the preset amount of data rendered by the browser, the smaller the amount of data to be rendered, and the shorter the historical rendering time of the data of the preset amount of data rendered by the browser, the larger the amount of data to be rendered. The preset amount of data can be a fixed value, for example, the preset amount of data is 1000. The preset amount of data can also be a dynamic value, for example, the preset amount of data is the amount of data rendered by the browser in the last rendering task.
[0038] S203, obtaining data of the rendering data volume from the data of the target task for rendering to obtain rendering data.
[0039] The terminal obtains the data of the rendering data amount from the data of the target task through the rendering engine for rendering to obtain the rendering data.
[0040] In an embodiment of the present application, the terminal dynamically adjusts the amount of rendering data according to the rendering time required for the browser to render a preset amount of data, and only obtains the data of the rendering data amount for rendering each time. When the amount of data of the target task is large, the browser can also select an appropriate amount of data for rendering, thereby avoiding page freezes due to excessive data volume.
[0041] S204, playing the rendering data.
[0042] The terminal plays the rendering data through the player.
[0043] To sum up, the technical solution provided by the embodiment of the present application, after obtaining the data of the target task, will determine the amount of rendering data that needs to be rendered for this rendering task, and then render and play the data of the rendering data obtained in the data of the target task, wherein the rendering data amount is negatively correlated with the historical rendering time of the browser rendering the preset data amount in the terminal, the longer the historical rendering time of the browser rendering the preset data amount, the smaller the rendering data amount, and the shorter the historical rendering time of the browser rendering the preset data amount, the larger the rendering data amount. That is, in each rendering task, the terminal will adaptively adjust the amount of rendering data that needs to be rendered this time based on the historical rendering time of the browser rendering the preset data amount. When the data amount of the target task is large, the browser can also select an appropriate amount of data for rendering, to avoid page freezes due to excessive data volume.
[0044] Please refer to Figure 3 , which shows a flow chart of a method for playing data provided by an embodiment of the present application. The method includes the following process.
[0045] S301, obtaining data of the target task.
[0046] S302: Obtain the rendering time required by the browser to render a preset amount of data in at least one most recent rendering task.
[0047] The terminal directly reads the preset data volume and rendering time from the local computer. The terminal's browser records the rendering start time and rendering end time through the application program interface performance.now, and uses the time interval between the two as the rendering time of the browser in this rendering task.
[0048] S303: When the rendering time is greater than the preset maximum rendering time, the preset data amount is reduced to obtain the rendering data amount.
[0049] In the case where the browser obtains the rendering time of the data rendered in multiple rendering tasks, the above rendering time is the average of the rendering time of the data rendered in multiple rendering tasks. The preset maximum rendering time is set according to experiments or experience. For example, the maximum rendering time is 100ms. It should be noted that when the preset data volume is a dynamic value, the maximum rendering times corresponding to different preset data volumes may be the same or different. The terminal can store the mapping relationship between different maximum rendering times corresponding to different preset data volumes for subsequent table lookup.
[0050] If the rendering time required for the browser to render a preset amount of data in at least one recent rendering task is greater than the maximum rendering time, it means that the amount of data rendered by the browser in the most recent rendering task may be large and the rendering time is long. Therefore, the amount of data rendered by the browser in this rendering task should be appropriately reduced to ensure that this rendering task can be completed as soon as possible.
[0051] The browser may subtract a fixed value from the preset data amount to obtain the rendering data amount, or may subtract a first dynamic value from the preset data amount to obtain the rendering data amount, wherein the first dynamic value is positively correlated with the difference between the rendering time and the maximum rendering time, that is, the greater the deviation between the two, the greater the first dynamic value that needs to be subtracted from the preset data amount. In some embodiments, S303 is specifically implemented as follows: when the rendering time is greater than the maximum rendering time, obtaining a first ratio of the maximum rendering time to the rendering time; and determining the product of the first ratio and the preset data amount as the rendering data amount.
[0052] The first ratio is less than 1. For example, the browser renders 1000 pieces of driving data in the most recent rendering task, and the rendering time spent is 200 ms, which is greater than the maximum rendering time of 100 ms, and the browser determines that the amount of rendering data is (100 / 200)*1000=500.
[0053] Further, S303 is specifically implemented as follows: when the rendering time is greater than the maximum rendering time and the difference between the two is greater than the first difference, a first ratio of the maximum rendering time to the rendering time is obtained; and the product of the first ratio and the preset data amount is determined as the rendering data amount. The first difference is set according to experiments or experience, for example, 10ms. That is, when the rendering time is greater than the maximum rendering time, but the deviation between the two is small, the amount of data to be rendered is temporarily not adjusted to avoid frequent adjustments to the amount of rendering data.
[0054] S304: When the rendering time is less than the preset maximum rendering time, the preset data amount is increased to obtain the rendering data amount.
[0055] If the rendering time required for the browser to render a preset amount of data in at least one recent rendering task is greater than the maximum rendering time, it means that the amount of data rendered by the browser in the most recent rendering task may be small and the rendering time is short. Therefore, the amount of data rendered by the browser in a rendering task should be appropriately increased to ensure that more data is rendered in this rendering task.
[0056] The browser may increase the preset data amount by a fixed value to obtain the rendering data amount, or may increase the preset data amount by a second dynamic value to obtain the rendering data amount, wherein the second dynamic value is positively correlated with the difference between the rendering time and the maximum rendering time, that is, the greater the deviation between the two, the greater the second dynamic value by which the preset data amount needs to be increased. In some embodiments, S304 is specifically implemented as follows: when the rendering time is less than the maximum rendering time, obtaining a second ratio of the maximum rendering time to the rendering time; and determining the rendering data amount as the product of the second ratio and the preset data amount.
[0057] The second ratio is greater than 1. For example, the browser renders 1000 pieces of driving data in the most recent rendering task, and the rendering time spent is 50 ms, which is greater than the maximum rendering time of 100 ms. Then the browser determines that the amount of rendering data is (100 / 50)*1000=2000.
[0058] Further, S303 is specifically implemented as follows: when the rendering time is less than the maximum rendering time and the difference between the two is greater than the second difference, a second ratio of the maximum rendering time to the rendering time is obtained; and the product of the second ratio and the preset data amount is determined as the rendering data amount. The second difference is set based on experiments or experience, for example, 10ms. That is, when the rendering time is less than the maximum rendering time, but the deviation between the two is small, the amount of data to be rendered is temporarily not adjusted to avoid frequent adjustments to the amount of rendering data.
[0059] In the embodiment of the present application, the browser calls the native application program interface requestAnimationFrame to perform the above steps S302-S304. requestAnimationFrame will automatically adjust the execution frequency of the callback function according to the refresh rate of the browser, which helps to optimize the rendering performance.
[0060] S305, obtaining data of the rendering data volume from the data of the target task, performing rendering processing, and obtaining rendering data.
[0061] In addition, in the first rendering task after the browser is started, the browser selects a preset amount of data for rendering processing to obtain rendering data.
[0062] S306, playing the rendering data.
[0063] To summarize, the technical solution provided by the embodiment of the present application is that after acquiring the data of the target task, if the rendering time required for the browser to render the preset data amount is greater than the preset maximum rendering time, the preset data amount is reduced to obtain the rendered data amount; if the rendering time required for the browser to render the preset data amount is less than the preset maximum rendering time, the preset data amount is increased to obtain the rendered data amount, and then the data of the rendered data amount is acquired from the data of the target task for rendering and playing; the rendered data amount is adaptively adjusted according to the historical rendering time required for the browser to render the preset data amount; when the data amount of the target task is large, the browser can also select an appropriate amount of data for rendering to avoid page freezes due to excessive data volume.
[0064] Please refer to Figure 4 , which shows a flow chart of a method for playing data shown in an embodiment of the present application. The method includes the following process.
[0065] S401, obtaining data of a target task.
[0066] After the terminal obtains the data of the target task, it pushes it into the task queue.
[0067] S402, establishing a preset number of threads.
[0068] The preset number is determined based on the number of cores included in the processor of the terminal. Specifically, the number of threads is the same as the number of cores included in the processor of the terminal. For example, if the processor of the terminal includes 4 cores, 4 threads are established. In this way, it can be ensured that the multi-core parallel processing performance of the processor is fully utilized. The above-mentioned preset number of threads includes a main thread for data rendering, and other threads for decompressing data.
[0069] S403, decompressing the data of the target task through a designated thread to obtain decompressed data.
[0070] The specified thread refers to a thread that is marked as idle. Optionally, the thread is a WebWorker thread. WebWorker provides a simple way for web content to run scripts in background threads, which allows background threads to be created and run in the browser to execute code in parallel with the main thread. This not only improves web page performance, but also prevents long-running tasks from blocking the user interface. In addition, WebWorker threads can share binary data with the main thread, so zero-copy transmission of compressed data in multiple threads can be achieved.
[0071] The designated thread obtains the target task data from the task queue and decompresses it. The designated thread is marked as working during the decompression process. When the designated thread completes the decompression of the acquired driving data, if there is new data in the task queue, it continues to obtain new data from the task queue and decompress it. If there is no new data in the task queue, it is marked as idle again.
[0072] S404, passing the decompressed data to the main thread through the designated thread.
[0073] The decompressed data is binary data. Since the designated thread and the main thread can share binary data, the main thread directly reads the decompressed data from the designated location, thereby realizing the transfer of the decompressed data between the designated thread and the main thread.
[0074] The main thread obtains the timestamp of the decompressed data and determines whether it is the latest data based on the dataset update record. If the decompressed data is the latest data, it is directly pushed into the dataset. If the decompressed data is not the latest data, an insertable index is found in the dataset update record, and the decompressed data is inserted at the corresponding position of the dataset according to the above index, and the timestamp and data length of this update are inserted into the dataset update record at the index.
[0075] S405, obtaining the data of the rendering data amount from the decompressed data through the main thread for rendering processing to obtain rendering data.
[0076] The terminal obtains the working status of the player. If the working status of the player is the playing status, S405 is executed. If the working status of the player is the paused status, S405 is not executed for the time being, and it is monitored whether a resume playing instruction is received. If a resume playing instruction is received, S405 is executed. If the working status of the player is the stopped status, the current task is ended and the specified wireless communication connection with the server is disconnected.
[0077] S406, playing the rendering data.
[0078] When a user starts a real-time playback task, if he quits and returns midway, he will get the cached task ID and start time from IndexedDB, and determine whether the task is finished. If the task is not finished, the current task is still valid. At this time, the terminal browser re-establishes a wireless communication connection with the server and executes subsequent steps to achieve breakpoint resumption.
[0079] In summary, the technical solution provided in the embodiment of the present application can ensure that the multi-core parallel processing performance of the processor is fully utilized by establishing a corresponding number of threads based on the number of cores included in the processor of the terminal.
[0080] Please refer to Figure 5 , which shows a flow chart of a method for playing data provided by an embodiment of the present application. The method includes the following process.
[0081] S501, obtaining data of a target task.
[0082] S502, storing the data of the target task and the start timestamp in the buffer of the terminal.
[0083] In some embodiments, the terminal also uses IndexedDB technology to create a real-time task database to cache the task identifier and start timestamp of the target task. During the real-time playback process, each time new data is received, after being parsed and processed by the designated thread, a parsed cached message data is generated in IndexedDB.
[0084] S503: Determine the amount of rendering data.
[0085] There is a negative correlation between the amount of rendered data and the historical rendering time of the data of the preset amount of data rendered by the browser in the terminal.
[0086] S504, obtaining data of the rendering data volume from the data of the target task, performing rendering, and obtaining rendering data.
[0087] S505, start playing the rendering data.
[0088] S506, during the process of playing the rendering data, if an exit playback instruction corresponding to the target task is obtained, the WebSocket connection between the browser and the server is disconnected based on the end playback instruction of the target task, and the subsequent rendering playback process is stopped.
[0089] The exit play instruction is used to instruct the browser to exit the play process of the target task. The play page of the browser includes an exit control. After obtaining a trigger signal corresponding to the exit control, the browser obtains the exit play instruction corresponding to the target task. At this time, the browser disconnects the WebSocket connection with the server and stops executing the steps in the method for playing data.
[0090] S507, obtaining a continue playing instruction corresponding to the target task, and detecting whether the data in the cache is complete data of the target task based on the data in the cache and the start timestamp.
[0091] The continue play instruction is used to instruct the browser to continue the play process of the target task. The complete data of the target task refers to all the data required for the target task to finish playing. The browser's play list includes the identifier of the target task. After obtaining the trigger signal corresponding to the identifier of the target task, the browser obtains the continue play instruction of the target task. The browser determines the play duration of the received data based on the timestamp and start timestamp of the data in the cache. If the play duration of the received data is equal to the total play duration of the target task, the data in the cache is the complete data of the target task. If the play duration of the received data is less than the total play duration of the target task, the data in the cache is not the complete data of the target task.
[0092] S508: If the data in the cache is not the complete data of the target task, the WebSocket connection between the browser and the server is re-established, and the remaining data of the target task is obtained based on the WebSocket connection, and the subsequent rendering and playback process is restarted.
[0093] If the data in the cache is complete data for the target task, the subsequent rendering and playback process is restarted.
[0094] To sum up, the technical solution provided by the embodiment of the present application stores the start timestamp and data of the target task in a cache. After the user triggers the browser to exit the playback process of the target task and then restarts the playback process, it can be determined based on the data in the cache whether the complete data of the target task is obtained. If the complete data of the target task is not obtained, the WebSocket connection between the browser and the server is re-established to realize the data subscription recovery of the target task, thereby realizing breakpoint resumption.
[0095] Please refer to Figure 6 , which shows a structural diagram of a device for playing data shown in an embodiment of the present application. The device includes: a data acquisition module 610, a quantity determination module 620, a data rendering module 620 and a playing module 630.
[0096] The data acquisition module 610 is used to acquire data of the target task.
[0097] The quantity determination module 620 is used to determine the amount of rendering data, and the amount of rendering data is negatively correlated with the historical rendering time of the data of the preset amount of data rendered by the browser in the terminal. The data rendering module 630 is used to obtain the data of the rendering data amount from the data of the target task for rendering to obtain rendering data.
[0098] The playing module 640 is used to play the rendering data.
[0099] In some embodiments, the quantity determination module 620 is used to obtain the rendering time required for the browser to render a preset data volume in at least one most recent rendering task; when the rendering time is greater than the preset maximum rendering time, the preset data volume is reduced to obtain the rendering data volume; when the rendering time is less than the preset maximum rendering time, the preset data volume is increased to obtain the rendering data volume.
[0101] In some embodiments, the quantity determination module 620 is used to obtain a first ratio of the maximum rendering time to the rendering time when the rendering time is greater than the maximum rendering time; determine the product of the first ratio and the preset data amount as the rendering data amount; wherein the first ratio is less than one; and when the rendering time is less than the maximum rendering time, obtain a second ratio of the maximum rendering time to the rendering time; determine the product of the second ratio and the preset data amount as the rendering data amount; wherein the second ratio is greater than one.
[0102] In some embodiments, the data acquisition module 610 is used to establish a WebSocket connection with the server through the browser of the terminal; and acquire the data of the target task based on the WebSocket connection.
[0103] In some embodiments, the device further includes: a data processing module (not shown in the figure). The data processing module is used to decompress the data of the target task through a designated thread to obtain decompressed data, the designated thread refers to a thread marked as idle, and the designated thread is marked as working during the decompression process; the decompressed data is passed to the main thread through the designated thread. The data rendering module 620 is used to obtain the data of the rendering data amount from the decompressed data through the main thread for rendering to obtain rendering data.
[0104] In some embodiments, the device further includes: a storage module and a breakpoint resume module (not shown in the figure). The storage module is used to store the data of the target task and the start timestamp in the cache of the terminal. The breakpoint resume module is used to: in the process of playing the rendering data, if the exit playback instruction corresponding to the target task is obtained, the WebSocket connection between the browser and the server is disconnected based on the end playback instruction of the target task, and the subsequent rendering and playback process is stopped; the continue playback instruction corresponding to the target task is obtained, and based on the data in the cache and the start timestamp, the data in the cache is detected to be the complete data of the target task; if the data in the cache is not the complete data of the target task, the WebSocket connection between the browser and the server is re-established, and the remaining data of the target task is obtained based on the WebSocket connection, and the subsequent rendering and playback process is started.
[0105] To sum up, the technical solution provided by the embodiment of the present application, after obtaining the data of the target task, will determine the amount of rendering data that needs to be rendered for this rendering task, and then render and play the data of the rendering data obtained in the data of the target task, wherein the rendering data amount is negatively correlated with the historical rendering time of the browser rendering the preset data amount in the terminal, the longer the historical rendering time of the browser rendering the preset data amount, the smaller the rendering data amount, and the shorter the historical rendering time of the browser rendering the preset data amount, the larger the rendering data amount. That is, in each rendering task, the terminal will adaptively adjust the amount of rendering data that needs to be rendered this time based on the historical rendering time of the browser rendering the preset data amount. When the data amount of the target task is large, the browser can also select an appropriate amount of data for rendering, to avoid page freezes due to excessive data volume.
[0106] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0107] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0108] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0109] See also Figure 7 , which shows that the embodiment of the present application also provides an electronic device 700, which can be Figure 1The terminal in the embodiment, the electronic device 700 includes: one or more processors 710, a memory 720 and one or more applications. Among them, the one or more applications are stored in the memory 720 and are configured to be executed by the one or more processors 710, and the one or more applications are configured to execute the method described in the above embodiment.
[0110] The processor 710 may include one or more processing cores. The processor 710 uses various interfaces and lines to connect various parts of the entire battery management system, and executes various functions and processes data of the battery management system by running or executing instructions, programs, code sets or instruction sets stored in the memory 720, and calling data stored in the memory 720. Optionally, the processor 710 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 710 can integrate one or more combinations of a central processing unit 710 (CPU), a graphics processing unit 710 (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 710, but may be implemented separately through a communication chip.
[0111] The memory 720 may include a random access memory 720 (Random Access Memory, RAM), and may also include a read-only memory 720 (Read-Only Memory). The memory 720 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the various method embodiments described below, etc. The data storage area may also store data created by the traffic vehicle map during use (such as a phone book, audio and video data, chat record data), etc.
[0112] An embodiment of the present application further provides a computer-readable storage medium, in which computer program instructions are stored. The computer program instructions can be called by a processor to execute the method described in the above embodiment.
[0113] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for computer program instructions for executing any method step of the above method. These computer program instructions may be read from or written to one or more computer program products. The computer program instructions may be compressed in an appropriate form.
[0114] The present application also provides a computer program product. When the instructions in the computer program product are executed, it is used to implement Figure 2-Figure 5 The method described in any embodiment.
[0115] The above are only preferred embodiments of the present application, and are not intended to limit the present application in any form. Although the present application has been disclosed as above with preferred embodiments, it is not intended to limit the present application. Any technical personnel in the field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present application. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present application without departing from the content of the technical solution of the present application are still within the scope of the technical solution of the present application.
Claims
1. A method for playing data, characterized in that: The method comprises: Get the data of the target task; Determine the amount of rendering data, where the amount of rendering data is negatively correlated with the historical rendering time of data of the browser in the terminal that renders a preset amount of data; Obtaining the data of the rendering data amount from the data of the target task for rendering to obtain rendering data; The rendering data is played.
2. The method according to claim 1, characterized in that The determining of the amount of rendering data further includes: Obtaining a rendering time required by the browser to render the preset data volume in at least one most recent rendering task; When the rendering time is longer than a preset maximum rendering time, reducing the preset data amount to obtain the rendering data amount; When the rendering duration is less than a preset maximum rendering duration, the preset data amount is increased to obtain the rendering data amount.
3. The method according to claim 2, characterized in that When the rendering time is longer than a preset maximum rendering time, reducing the preset data amount to obtain the rendering data amount includes: When the rendering time is greater than the maximum rendering time, obtaining a first ratio of the maximum rendering time to the rendering time; and determining the rendering data amount by multiplying the first ratio by the preset data amount; wherein the first ratio is less than one; When the rendering duration is less than a preset maximum rendering duration, increasing the preset data amount to obtain the rendering data amount includes: When the rendering time is less than the maximum rendering time, obtain a second ratio of the maximum rendering time to the rendering time; and determine the rendering data amount by multiplying the second ratio by the preset data amount; wherein the second ratio is greater than one.
4. The method according to any one of claims 1 to 3, characterized in that The step of obtaining target task data includes: Establishing a WebSocket connection with the server through the browser of the terminal; The data of the target task is obtained based on the WebSocket connection.
5. The method according to any one of claims 1 to 3, characterized in that: The data of the target task is compressed data, and the data of the rendering data volume is obtained from the data of the target task for rendering. Before obtaining the rendering data, the method further includes: Decompressing the data of the target task through a designated thread to obtain decompressed data, wherein the designated thread refers to a thread marked as being in an idle state, and the designated thread is marked as being in a working state during the decompression process; Passing the decompressed data to the main thread through the designated thread; The step of acquiring the amount of data for rendering from the data of the target task and rendering to obtain the rendering data includes: The main thread obtains the data of the rendering data amount from the decompressed data for rendering to obtain rendering data.
6. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: after acquiring the data of the target task, storing the data of the target task and a start timestamp in a cache of the terminal; During the process of playing the rendering data, if an exit playback instruction corresponding to the target task is obtained, the WebSocket connection between the browser and the server is disconnected based on the end playback instruction of the target task, and the subsequent rendering playback process is stopped; Obtaining a continue playing instruction corresponding to the target task, and detecting whether the data in the cache is complete data of the target task based on the data in the cache and the start timestamp; If the data in the cache is not the complete data of the target task, the WebSocket connection between the browser and the server is re-established, and the remaining data of the target task is obtained based on the WebSocket connection, and the subsequent rendering and playback process is started.
7. A device for playing data, characterized in that: The device comprises: Data acquisition module, used to acquire data of target tasks; A quantity determination module, used to determine the amount of rendering data, wherein the amount of rendering data is negatively correlated with the historical rendering time of data of a preset amount of data rendered by the browser in the terminal; A data rendering module, used for acquiring the data of the rendering data volume from the data of the target task for rendering to obtain rendering data; A playing module is used to play the rendering data.
8. An electronic device, characterized in that: include: Memory; One or more processors coupled to the memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and the computer program instructions can be called by a processor to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that When the instructions in the computer program product are executed, they are used to implement the method according to any one of claims 1 to 6.