A method and device for monitoring loading progress

By monitoring the call of loading task functions and the comparison of URL URLs, the loading progress is accurately calculated, which solves the problem of inaccurate loading progress in the existing technology, and achieves the transparency and visibility of the loading process and the improvement of user experience.

CN114328074BActive Publication Date: 2025-07-11WUHAN DOUYU NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011086235.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-12
Publication Date
2025-07-11
Estimated Expiration
2040-10-12

AI Technical Summary

Technical Problem

In the prior art, the page loading progress indicator is not accurate enough, resulting in the user being unable to understand the loading progress in real time, affecting the user experience.

Method used

By monitoring the call status of loading task functions, count the current loading number of tasks in real time, and use progress observers and URL comparisons to accurately calculate the loading progress, and use system functions to update the progress display control.

Benefits of technology

实现了对加载进度的实时准确监控,提高了用户体验,确保加载过程透明可见。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328074B_ABST
    Figure CN114328074B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of page loading, and particularly relates to a method and device for monitoring the loading progress. The present invention first obtains the current number of loading tasks to be executed for the current loading request, then obtains a more accurate current number of loading tasks according to the call situation of the page start loading function, and then determines the number of completed current loading tasks according to the call situation of the page end loading function. Finally, according to the current number of loading tasks to be executed for the current loading request and the number of completed current loading tasks, the real-time and accurate monitoring of the loading progress is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of page loading, and in particular to a method and device for monitoring loading progress. Background Art

[0002] During the development of a client, when a user browses a client or a web page, it is often necessary to load a page. When loading a page, if there are many resources to be loaded (such as pictures, texts, controls, etc.) or the network quality is poor, the loading process is relatively slow, making it impossible for users or developers to accurately know the current loading progress, thus bringing a poor user experience.

[0003] In the prior art, a progress indicator scheme is adopted to enable users or developers to know the current loading progress, but the data of the existing progress indicator is not accurate enough. For example, the data is 10% at the moment when it is just loaded and suddenly becomes 100%, which cannot accurately reflect the data loading process and also brings a poor user experience.

[0004] Therefore, how to monitor the loading progress in real time and accurately is a technical problem that needs to be solved urgently at present. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and device for monitoring loading progress to monitor the loading progress in real time and accurately.

[0006] To achieve the above purpose, the embodiments of the present invention provide the following solutions:

[0007] In a first aspect, an embodiment of the present invention provides a method for monitoring loading progress, including:

[0008] Step 1, obtaining the current number of loading tasks of the current loading request according to the function call situation of the loading task;

[0009] Step 2, determining whether the page start loading function is called;

[0010] Step 3, if so, increasing the current number of loading tasks and returning to Step 2;

[0011] Step 4, if not, starting to monitor the progress of the current loading request;

[0012] Step 5, continuing to determine whether the page end loading function is called according to the progress of the current loading request;

[0013] Step 6, if the page end loading function is called, reducing the current number of loading tasks;

[0014] Step 7, updating the progress displayed in the progress display control of the current page according to the reduced current number of loading tasks.

[0015] In a possible embodiment, before step 1, the method further includes:

[0016] Call the addObserver function to construct a progress observer; wherein, the callback processing parameter of the progress observer is the webView control, the KeyPath parameter of the progress observer is the estimatedProgress function, and the observed value parameter of the progress observer includes the old value and the new value of the estimatedProgress function.

[0017] In a possible embodiment, before step 1, the method further includes:

[0018] Obtain the URL of the current loading request;

[0019] Obtain the URL of the currently successfully loaded page;

[0020] Determine whether the URL of the current loading request is the same as the URL of the currently successfully loaded page;

[0021] If the URL of the current loading request is the same as the URL of the currently successfully loaded page, call the completeProgress function to end the current loading request;

[0022] Call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state;

[0023] If the URL of the current loading request is not the same as the URL of the currently successfully loaded page, perform step 1.

[0024] In a possible embodiment, after step 5, the method further includes:

[0025] Step 11, determine whether an exception occurs during the execution of the current loading request;

[0026] Step 12, if an exception occurs, subtract 1 from the current number of loading tasks to reduce the current number of loading tasks;

[0027] Step 13, according to the reduced current number of loading tasks in step 12, call the incrementProgress function to update the progress displayed in the progress display control.

[0028] In a possible embodiment, after step 13, the method further includes:

[0029] Obtain the first loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0030] Determine whether the first loading state is in an active state;

[0031] If the first loading state is not, construct the first waitForCompleteJS script;

[0032] Determine whether the readyState status of the first waitForCompleteJS script is the completed status;

[0033] If the readyState status of the first waitForCompleteJS script is the completed status, call the completeProgress function to end the current loading request;

[0034] Call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state.

[0035] In a possible embodiment, step 7 includes:

[0036] Call the setProgress function to obtain the current first progress value;

[0037] Call the incrementProgress function to obtain the current second progress value;

[0038] Determine whether the current first progress value is greater than the current second progress value;

[0039] If it is greater, update the current second progress value to the current first progress value;

[0040] According to the updated current second progress value, call the incrementProgress function to update the progress displayed in the progress display control.

[0041] In a possible embodiment, after step 7, the method further includes:

[0042] If the webViewDidFinishLoad function is not called, obtain the second loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0043] Determine whether the second loading state is in an active state;

[0044] If in a certain state, construct a second waitForCompleteJS script;

[0045] Determine whether the readyState of the second waitForCompleteJS script is in a completed state;

[0046] If the readyState of the second waitForCompleteJS script is in a completed state, call the completeProgress function to end the current loading request;

[0047] Call the incrementProgress function to update the progress displayed in the progress display control to the state where the loading is completed.

[0048] In a second aspect, an embodiment of the present invention provides a loading progress monitoring device, including:

[0049] A task number acquisition module, configured to acquire the current number of loading tasks of the current loading request according to the function call situation of the loading task;

[0050] A first judgment module, configured to judge whether the page start loading function is called;

[0051] A first task number update module, configured to increase the current number of loading tasks when the page start loading function is called, and return to the first judgment module;

[0052] A first control module, configured to start monitoring the progress of the current loading request when the page start loading function is not called;

[0053] A second judgment module, configured to continue to judge whether the page end loading function is called according to the progress of the current loading request;

[0054] A second task number update module, configured to reduce the current number of loading tasks when the page end loading function is called;

[0055] A first progress update module, configured to update the progress displayed in the progress display control of the current page according to the reduced current number of loading tasks output by the second task number update module.

[0056] In a possible embodiment, the device further includes:

[0057] An observer construction module, which is used to call the addObserver function to construct a progress observer before the first URL acquisition module works; wherein, the callback processing parameter of the progress observer is a webView control, the KeyPath parameter of the progress observer is the estimatedProgress function, and the observed value parameter of the progress observer includes the old value and the new value of the estimatedProgress function.

[0058] In a possible embodiment, the device further includes:

[0059] A first URL acquisition module, which is used to acquire the URL of the current loading request before the first URL acquisition module works;

[0060] A second URL acquisition module, which is used to acquire the URL of the currently successfully loaded page;

[0061] A third judgment module, which is used to judge whether the URL of the current loading request is the same as the URL of the currently successfully loaded page;

[0062] A second control module, which is used to call the completeProgress function to end the current loading request when the URL of the current loading request is the same as the URL of the currently successfully loaded page; and is also used to activate the task number acquisition module to work when the URL of the current loading request is different from the URL of the currently successfully loaded page;

[0063] A second progress update module, which is used to call the incrementProgress function to update the progress displayed in the progress display control to the state of loading completed.

[0064] In a possible embodiment, the device further includes:

[0065] A fourth judgment module, which is used to judge whether an exception handling occurs during the execution of the current loading request after the second judgment module works;

[0066] A third task number update module, which is used to subtract 1 from the current loading task number to reduce the current loading task number when an exception handling occurs during the execution of the current loading request;

[0067] A third progress update module, which is used to call the incrementProgress function according to the reduced current loading task number output by the third task number update module to update the progress displayed in the progress display control.

[0068] In a possible embodiment, the device further includes:

[0069] A first loading state acquisition module, configured to, after the third progress update module works, acquire the first loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0070] A fifth judgment module, configured to judge whether the first loading state is in an active state;

[0071] A first script construction module, configured to construct a first waitForCompleteJS script when the first loading state is not in an active state;

[0072] A sixth judgment module, configured to judge whether the readyState state of the first waitForCompleteJS script is a completed state;

[0073] A third control module, configured to call the completeProgress function to end the current loading request when the readyState state of the first waitForCompleteJS script is a completed state;

[0074] A fourth progress update module, configured to call the incrementProgress function to update the progress displayed in the progress display control to a loaded completed state.

[0075] In a possible embodiment, the first progress update module includes:

[0076] A first progress value acquisition module, configured to call the setProgress function to acquire the current first progress value;

[0077] A second progress value acquisition module, configured to call the incrementProgress function to acquire the current second progress value;

[0078] A seventh judgment module, configured to judge whether the current first progress value is greater than the current second progress value;

[0079] A progress value update module, configured to update the current second progress value to the current first progress value when the current first progress value is greater than the current second progress value;

[0080] A progress value display module, configured to call the incrementProgress function to update the progress displayed in the progress display control according to the updated current second progress value.

[0081] In a possible embodiment, the device further includes:

[0082] A second loading state acquisition module, configured to, after the first progress update module works and when the page end loading function is not called, acquire the second loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0083] An eighth determination module, configured to determine whether the second loading state is in an active state;

[0084] A second script construction module, configured to construct a second waitForCompleteJS script when the second loading state is in an active state;

[0085] A ninth determination module, configured to determine whether the readyState state of the second waitForCompleteJS script is a completed state;

[0086] A fourth control module, configured to call the completeProgress function to end the current loading request when the readyState state of the second waitForCompleteJS script is a completed state;

[0087] A fifth progress update module, configured to call the incrementProgress function to update the progress displayed in the progress display control to a state where the loading is completed.

[0088] In a third aspect, an embodiment of the present invention provides a computer device, including:

[0089] A memory, configured to store a computer program;

[0090] A processor, configured to execute the computer program to implement the steps of the method for encrypting data transmission according to any one of the above first aspects.

[0091] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for encrypting data transmission according to any one of the above first aspects are implemented.

[0092] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0093] The present invention first obtains the current number of loading tasks to be executed for the current loading request, then obtains a more accurate current number of loading tasks according to the invocation situation of the webViewDidStartLoad function, then determines the number of completed current loading tasks according to the invocation situation of the webViewDidFinishLoad function, and finally realizes real-time and accurate monitoring of the loading progress based on the current number of loading tasks to be executed for the current loading request and the number of completed current loading tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of this specification. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.

[0095] Figure 1 is a flowchart of a loading progress monitoring method provided by an embodiment of the present invention;

[0096] Figure 2 is a schematic structural diagram of a loading progress monitoring device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0097] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art belong to the scope protected by the embodiments of the present invention.

[0098] Please refer to Figure 1 , Figure 1 is a flowchart of a loading progress monitoring method provided by an embodiment of the present invention, specifically including steps 101 to 107. This method can be applied to the loading progress monitoring of conventional web pages and can also be used for the loading progress monitoring of client pages.

[0099] Step 101: Obtain the current number of loading tasks for the current loading request according to the function call situation of the loading tasks.

[0100] The function of this step is to initially obtain the current number of all loading tasks to be executed in the current loading request.

[0101] Specifically, the respondsToSelector function can be used to implement the operation of this step. The respondsToSelector function can throw out the task event that needs to start loading currently, so as to obtain the number of current loading tasks that need to be executed in this loading request.

[0102] Specifically, the respondsToSelector function can throw out the task event that needs to start loading currently, so as to obtain the number of current loading tasks that need to be executed in this loading request.

[0103] Specifically, the respondsToSelector function is a system function. In this step, when a task event of a certain loading starts, by calling this function, the event can be called back.

[0104] Step 102, determine whether the page start loading function is called.

[0105] The function of this step is: to calculate the call of the webView control in the tasks that need to be loaded in this loading request, so that the number of current loading tasks that need to be executed in this loading request is more accurate.

[0106] Specifically, the webViewDidStartLoad function can be used as the page start loading function. Since when the page is loaded, the webViewDidStartLoad function will be called frequently to complete the loading task by using the webView control in the webViewDidStartLoad function, this step counts the number of calls of the webViewDidStartLoad function to more accurately count the number of current loading tasks that need to be executed in this loading request.

[0107] Specifically, the webViewDidStartLoad function is a system function that will be called when the webview starts to load.

[0108] Step 103, if so, increase the number of the current loading tasks, and return to Step 103.

[0109] The function of this step is: to count the number of calls of the page start loading function, so that the number of current loading tasks that need to be executed in this loading request is more accurate.

[0110] Specifically, if the webViewDidStartLoad function is called, the number of the current loading tasks will be incremented by 1 to increase the number of current loading tasks. By repeatedly judging the call situation of the webViewDidStartLoad function, the total number of tasks that need to be loaded in this loading request can be accurately counted.

[0111] Step 104, if not, then start monitoring the progress of the current loading request.

[0112] The function of this step is: through this step, officially start monitoring the loading progress.

[0113] Specifically, when the webViewDidStartLoad function is not called, it means that the current number of loading tasks has reached the maximum value, and at this time, it can be regarded as completing the statistics of the current number of loading tasks.

[0114] Through the operations of Step 101 to Step 104, the total number of tasks to be loaded in the current loading request can be accurately counted. This process belongs to the preparatory work before starting to monitor the loading progress, and then, according to the completion situation of the specific loading tasks, the loading progress of the page can be obtained in real time.

[0115] Step 105, continue to judge whether the page stop loading function is called according to the progress of the current loading request.

[0116] The function of this step is: count the call situation of the page end loading function, accurately know the completion situation of the current loading task, so as to accurately obtain the current loading progress.

[0117] Specifically, the webViewDidFinishLoad function can be used as the page end loading function. Since the webViewDidFinishLoad function will be called after the webViewDidStartLoad function is called, by counting the number of calls of the webViewDidFinishLoad function, the completion situation of the current loading task can be accurately known, so as to accurately obtain the current loading progress.

[0118] Specifically, the webViewDidFinishLoad function is a system function, and this function will be called when the webview finishes loading.

[0119] Step 106, if the webViewDidFinishLoad function is called, then reduce the current number of loading tasks.

[0120] The function of this step is: through updating the current number of loading tasks, realize the real-time monitoring of the loading progress.

[0121] Specifically, if the webViewDidFinishLoad function is called, then subtract 1 from the current number of loading tasks to update the current number of loading tasks.

[0122] Step 107: Update the progress displayed in the progress display control of the current page according to the reduced current number of loading tasks in Step 106.

[0123] The function of this step is to display the current loading progress on the page and accurately inform the user of the current loading progress.

[0124] Specifically, this step of operation can be implemented through the incrementProgress function.

[0125] Specifically, the incrementProgress function is a system function. When called, it will increase the current progress value according to the requirements and visually display the increased current progress value. Depending on the control, it can be displayed as a percentage number or as an image of a progress bar, etc.

[0126] To facilitate the monitoring of the entire loading process, the present invention also provides the following solution:

[0127] Before the said Step 101, the method further includes:

[0128] Step 21: Call the addObserver function to construct a progress observer; wherein, the callback processing parameter of the progress observer is the webView control, the KeyPath parameter of the progress observer is the estimatedProgress function, and the observed value parameter of the progress observer includes the old value and the new value of the estimatedProgress function.

[0129] Specifically, the callback processing parameter of the progress observer is used to call back the current webView control to the webView control; the KeyPath parameter of the progress observer is the estimatedProgress function, and the estimatedProgress function can determine whether the loading progress may change and make a callback through KeyPath; the observed value parameter of the progress observer is a numerical value of a dictionary type (OptionNew|OptionOld), and this dictionary contains the monitored value of the estimatedProgress function, and this value includes the old value and the new value of the change. There will be a callback every time the estimatedProgress function changes, and the estimatedProgress of the webView can be obtained in this callback.

[0130] Of course, in practical applications, multiple identical loading requests may be received within a short period of time. If the execution progress monitoring is carried out without any recognition, a large amount of computing power will be wasted and useless work will be done. To avoid this situation and improve the efficiency of progress monitoring, before step 101, the present invention also adopts the following solution:

[0131] Step 31: Obtain the URL of this loading request.

[0132] The function of this step is to quickly determine whether this loading request has been executed by comparing the URLs.

[0133] Specifically, call the shouldStartLoadWithRequest function, obtain the request parameter in the shouldStartLoadWithRequest function, and then obtain the URL of this loading request according to the request parameter.

[0134] Specifically, the shouldStartLoadWithRequest function is a system function in the WebView mode, which can implement a proxy method. When loading an HTTP protocol request, by calling this function, the parameters related to the HTTP protocol request can be called back to obtain the request parameter.

[0135] Specifically, this loading request includes an HTTP protocol request, and the request parameter is a parameter of the shouldStartLoadWithRequest function. In this step, the shouldStartLoadWithRequest function is used to obtain the request parameter included in the HTTP protocol request, and the response URL of this loading request is recorded in this parameter; the URL (Uniform Resource Locator) is simply the address of a standard resource on the Internet, and through it we can obtain the resources we need (such as web pages, pictures, audio and video, services, files, etc.).

[0136] Step 32: Obtain the URL of the currently successfully loaded page.

[0137] The function of this step is to quickly determine whether this loading request has been executed by comparing the URLs.

[0138] Specifically, the URL of the currently successfully loaded page is the URL corresponding to the last successful load, indicating that all tasks of the last loading request in this URL have been completed.

[0139] Step 33: Determine whether the URL of the current loading request is the same as the URL of the currently successfully loaded page.

[0140] The purpose of this step is to accurately determine the tasks that really need to be loaded in the current loading request by comparing with the URL of the current loading request.

[0141] Specifically, when the page is loaded, resources set in advance need to be loaded at a fixed position. Therefore, there are loading tasks in the current loading request in the URL. However, if one or more loading tasks in the current loading request have been completed after the last successful load, there is no need to load them again during the actual task loading. By using the URL of the currently successfully loaded page, the tasks that really need to be loaded can be found, improving the efficiency of progress monitoring.

[0142] When the URL of the current loading request is the same as the URL of the currently successfully loaded page, it means that all tasks of the current loading request have been completed last time, and thus the current request can be resolved.

[0143] Step 34: If the URL of the current loading request is the same as the URL of the currently successfully loaded page, call the completeProgress function to end the current loading request.

[0144] The purpose of this step is to quickly end the current loading request by using the completeProgress function.

[0145] Specifically, the completeProgress function is a system function used to resolve the current loading request and display that the progress is completed by calling when the progress is finished.

[0146] Step 35: Call the incrementProgress function to update the progress displayed in the progress display control to the state where the loading is completed.

[0147] The purpose of this step is to visually display the result that the progress has been loaded by using the incrementProgress function, facilitating the user to know in time.

[0148] Step 36: If the URL of the current loading request is not the same as the URL of the currently successfully loaded page, proceed to step 101.

[0149] The purpose of this step is to avoid meaningless progress monitoring by adding steps 31 to 36 before step 101, thereby improving the efficiency of progress monitoring.

[0150] Of course, during the loading and execution process, loading errors may occur. The present invention also provides a processing solution for such situations to accurately obtain the real-time progress of each loading stage, specifically as follows:

[0151] After step 105, the method further includes:

[0152] Step 41, determine whether exception handling occurs during the execution of the current loading request.

[0153] The function of this step is to determine whether a loading exception occurs.

[0154] Step 42, if so, subtract 1 from the current loading task count to reduce the current loading task count.

[0155] The function of this step is to take the loading exception situation into account in the actual loading process to improve the accuracy of loading process monitoring.

[0156] Step 43, according to the reduced current loading task count in step 42, call the incrementProgress function to update the progress displayed in the progress display control.

[0157] The function of this step is to timely display the current process in a visual form to facilitate the user to know the current loading process in real time.

[0158] After that, if it is found that the page appears in an abnormal inactive loading state such as being stuck, it is necessary to end the current process monitoring in a timely manner. The specific solution is as follows:

[0159] After step 43, the method further includes:

[0160] Step 51, obtain the first loading state of the current page according to the stringByEvaluatingJavaScriptFromString function.

[0161] The function of this step is to determine the current loading state of the current page.

[0162] Specifically, the first loading state includes two states: active and inactive. The active state indicates that the current page is performing a loading task, and the inactive state indicates that the current page is in an abnormal situation such as being stuck or has completed all loading tasks.

[0163] Specifically, the stringByEvaluatingJavaScriptFromString function is a system function. Through this function, functions bound to the window by Html can be called. In this step, this function is used to obtain the loading status of the web page.

[0164] Step 52: Determine whether the first loading status is in an active state.

[0165] The function of this step is to determine whether to end the current loading request based on the first loading status.

[0166] Step 53: If the first loading status is not in the active state, then construct the first waitForCompleteJS script.

[0167] The function of this step is to facilitate the execution process of the completeProgress function through the first waitForCompleteJS script.

[0168] Step 54: Determine whether the readyState status of the first waitForCompleteJS script is in a completed state.

[0169] The function of this step is to efficiently obtain the moment when the execution of the completeProgress function starts through the readyState status.

[0170] Step 55: If the readyState status of the first waitForCompleteJS script is in a completed state, then call the completeProgress function to end the current loading request.

[0171] The function of this step is to quickly end the current loading request through the completeProgress function.

[0172] Step 56: Call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state.

[0173] The function of this step is to promptly display the current process in a visual form to facilitate the user to know the current loading process in real time.

[0174] Here, the present invention also provides a better solution for progress display and update. The specific solution is as follows:

[0175] Step 107 includes:

[0176] Step 61: Call the setProgress function to obtain the current first progress value.

[0177] The function of this step is to accurately know the current loading progress according to the setProgress function.

[0178] Specifically, the first progress value can be determined according to the ratio of the number of completed tasks to the total number of tasks.

[0179] Specifically, the setProgress function is a system function used to initialize and specifically assign values to the progress.

[0180] Step 62: Call the incrementProgress function to obtain the current second progress value.

[0181] The function of this step is to know the progress currently displayed in the display control according to the incrementProgress function.

[0182] Step 63: Determine whether the current first progress value is greater than the current second progress value.

[0183] The function of this step is to determine whether it is necessary to update the progress currently displayed in the display control through this step.

[0184] Step 64: If it is greater, update the current second progress value to the current first progress value.

[0185] The function of this step is to update the current second progress value to facilitate the user to know the current progress in real time.

[0186] Step 65: According to the updated current second progress value, call the incrementProgress function to update the progress displayed in the progress display control.

[0187] The function of this step is to perform a visualization operation according to the current second progress value to facilitate the user to know the current progress in real time.

[0188] When all the load tasks that can be completed in this load task are completed, the webViewDidFinishLoad function will no longer be called. The present invention provides a relatively optimal solution for monitoring the completion progress, specifically:

[0189] After the step 107, the method further includes:

[0190] Step 71, if the webViewDidFinishLoad function is not called, obtain the second loading status of the current page according to the stringByEvaluatingJavaScriptFromString function.

[0191] The function of this step is to determine the loading status of the current page.

[0192] Step 72, determine whether the second loading status is in an active state.

[0193] The function of this step is to determine whether to terminate the request based on the loading status of the current page.

[0194] Step 73, if it is, construct the second waitForCompleteJS script.

[0195] The function of this step is to facilitate the execution process of the completeProgress function through the second waitForCompleteJS script.

[0196] Step 74, determine whether the readyState status of the second waitForCompleteJS script is in a completed state.

[0197] The function of this step is to efficiently obtain the moment when the execution of the completeProgress function starts through the readyState status.

[0198] Step 75, if the readyState status of the second waitForCompleteJS script is in a completed state, call the completeProgress function to end the current loading request.

[0199] The function of this step is to quickly end the current loading request through the completeProgress function.

[0200] Step 76, call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state.

[0201] The function of this step is to promptly display the current process in a visual form to facilitate the user to know the current loading process in real time.

[0202] To implement the above embodiments, the present invention divides the above steps into 5 parts.

[0203] 1) Preparation work for data interception

[0204] This part needs to define the init function, which includes a pointer maxCount to the maximum number of loading tasks, the number of tasks being loaded loadingcout, and a variable _interactive indicating the current loading state of the task.

[0205] Among them, the number of tasks being loaded loadingcout contains the variable _loadingcout. Through this variable _loadingcout, the pointer maxCount to the maximum number of loading tasks can be assigned a value. When the variable _interactive is YES, it means the task is currently in the loading process; when the variable _interactive is NO, it means the task is not currently in the loading process.

[0206] Here, the pointer maxCount to the maximum number of loading tasks corresponds to the number of current loading tasks that need to be executed in this loading request.

[0207] Define the startProgress function to activate the data loading.

[0208] Define the setProgress function to set the current progress.

[0209] 2) Interception of event tasks before loading data

[0210] To accurately know the loading progress, relevant data before loading the data needs to be obtained, and events are intercepted before the request starts. There is a function shouldStartLoadWithRequest before the web page starts to make a request. This function has multiple function parameters, and one of the function parameters is request. This function is a method that will be called when the page is about to start making a request.

[0211] Through this part, the event tasks before starting to load data can be obtained, so as to know what happened before a request and facilitate updating the progress.

[0212] 3) Interception of the time before loading data

[0213] After the time of this loading request starts, the webViewDidStartLoad function will be called. This function is a function that will be called after the network request starts. This function has one parameter, which is webView. After this function is called, the current function is first called out using the webViewDidStartLoad function.

[0214] This part listens for requests before the time has started, intercepts events before the time request, and updates some progress before the event starts.

[0215] 4) Processing of the event task for completing data loading

[0216] After the network loading is successful, the webViewDidFinishLoad method will be called. After this method is called, this method needs to be delegated, and some event processing needs to be done in this method. This part intercepts when the loading is completed, and at the same time listens to the status in real time through js to ensure that the monitored progress is relatively real-time.

[0217] 5) Processing of the event task for data loading failure

[0218] Through this part, it is possible to monitor the status in real time when the data loading fails, ensuring that more event tasks can be monitored in real time. Finally, through multiple processes and links, it is ensured that the detected process is relatively accurate.

[0219] Based on the same inventive concept as the method, an embodiment of the present invention further provides a loading progress monitoring device, as Figure 2 shown in the structural schematic diagram of the embodiment of the device, specifically including:

[0220] A task number acquisition module 801, configured to acquire the current loading task number of the current loading request according to the function call situation of the loading task;

[0221] A first judgment module 802, configured to judge whether the page start loading function is called;

[0222] A first task number update module 803, configured to increase the current loading task number when the page start loading function is called, and return to the first judgment module;

[0223] A first control module 804, configured to start monitoring the progress of the current loading request when the page start loading function is not called;

[0224] A second judgment module 805, configured to continue to judge whether the page end loading function is called according to the progress of the current loading request;

[0225] A second task number update module 806, configured to reduce the current loading task number when the page end loading function is called;

[0226] A first progress update module 807, configured to update the progress displayed in the progress display control of the current page according to the reduced current loading task number output by the second task number update module 806.

[0227] In a possible embodiment, the device further includes:

[0228] An observer construction module, which is used to call the addObserver function to construct a progress observer before the first URL acquisition module works; wherein, the callback processing parameter of the progress observer is the webView control, the KeyPath parameter of the progress observer is the estimatedProgress function, and the observed value parameter of the progress observer includes the old value and the new value of the estimatedProgress function.

[0229] In a possible embodiment, the device further includes:

[0230] A first URL acquisition module, which is used to acquire the URL of the current loading request before the first URL acquisition module works;

[0231] A second URL acquisition module, which is used to acquire the URL of the currently successfully loaded page;

[0232] A third judgment module, which is used to judge whether the URL of the current loading request is the same as the URL of the currently successfully loaded page;

[0233] A second control module, which is used to call the completeProgress function to end the current loading request when the URL of the current loading request is the same as the URL of the currently successfully loaded page; and is also used to activate the task number acquisition module to work when the URL of the current loading request is different from the URL of the currently successfully loaded page;

[0234] A second progress update module, which is used to call the incrementProgress function to update the progress displayed in the progress display control to the state of completed loading.

[0235] In a possible embodiment, the device further includes:

[0236] A fourth judgment module, which is used to judge whether there is an exception handling during the execution of the current loading request after the second judgment module works;

[0237] A third task number update module, which is used to subtract 1 from the current loading task number and reduce the current loading task number when there is an exception handling during the execution of the current loading request;

[0238] A third progress update module, which is used to call the incrementProgress function according to the reduced current loading task number output by the third task number update module to update the progress displayed in the progress display control.

[0239] In a possible embodiment, the device further includes:

[0240] A first loading state acquisition module, configured to, after the third progress update module operates, obtain the first loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0241] A fifth judgment module, configured to judge whether the first loading state is in an active state;

[0242] A first script construction module, configured to construct a first waitForCompleteJS script when the first loading state is not in an active state;

[0243] A sixth judgment module, configured to judge whether the readyState state of the first waitForCompleteJS script is a completed state;

[0244] A third control module, configured to call the completeProgress function to end the current loading request when the readyState state of the first waitForCompleteJS script is a completed state;

[0245] A fourth progress update module, configured to call the incrementProgress function to update the progress displayed in the progress display control to a loaded completed state.

[0246] In a possible embodiment, the first progress update module includes:

[0247] A first progress value acquisition module, configured to call the setProgress function to obtain the current first progress value;

[0248] A second progress value acquisition module, configured to call the incrementProgress function to obtain the current second progress value;

[0249] A seventh judgment module, configured to judge whether the current first progress value is greater than the current second progress value;

[0250] A progress value update module, configured to update the current second progress value to the current first progress value when the current first progress value is greater than the current second progress value;

[0251] A progress value display module, configured to call the incrementProgress function to update the progress displayed in the progress display control according to the updated current second progress value.

[0252] In a possible embodiment, the device further includes:

[0253] A second loading state acquisition module, configured to, after the first progress update module works and when the page end loading function is not called, acquire the second loading state of the current page according to the stringByEvaluatingJavaScriptFromString function;

[0254] An eighth determination module, configured to determine whether the second loading state is in an active state;

[0255] A second script construction module, configured to construct a second waitForCompleteJS script when the second loading state is in an active state;

[0256] A ninth determination module, configured to determine whether the readyState state of the second waitForCompleteJS script is a completed state;

[0257] A fourth control module, configured to call the completeProgress function to end the current loading request when the readyState state of the second waitForCompleteJS script is a completed state;

[0258] A fifth progress update module, configured to call the incrementProgress function to update the progress displayed in the progress display control to a loaded completed state.

[0259] Based on the same inventive concept as the method, an embodiment of the present invention further provides a computer device, including:

[0260] A memory, configured to store a computer program;

[0261] A processor, configured to execute the computer program to implement the steps of the method for encrypting data transmission as described in the above method embodiment.

[0262] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the method for encrypting data transmission as described in the above method embodiment.

[0263] Compared with the prior art, the embodiment of the present invention has the following advantages and beneficial effects:

[0264] In the embodiment of the present invention, the number of current loading tasks to be executed for the current loading request is first obtained, and then a more accurate number of current loading tasks is obtained according to the call situation of the page start loading function. After that, according to the call situation of the page end loading function, the number of completed current loading tasks is determined. Finally, according to the number of current loading tasks to be executed for the current loading request and the number of completed current loading tasks, real-time and accurate monitoring of the loading progress is achieved.

[0265] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0266] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (devices, systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0267] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the specified functions in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0268] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.

[0269] Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the present application.

[0270] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.

Claims

1. A loading progress monitoring method, characterized in that, Including: Step 1: Obtain the current number of loading tasks for this loading request according to the function call situation of the loading task. Step 2: Determine whether the page start loading function is called. Step 3: If so, increase the current number of loading tasks and return to Step 2. Step 4: If not, start monitoring the progress of this loading request. Step 5: Continue to determine whether the page end loading function is called according to the progress of this loading request. Step 6: If the page end loading function is called, reduce the current number of loading tasks. Step 7: Obtain the reduced current number of loading tasks, and update the progress displayed in the current page's progress display control according to the reduced current number of loading tasks. After Step 7, the method further includes: If the page end loading function is not called, obtain the second loading state of the current page according to the stringByEvaluatingJavaScriptFromString function. Judge whether the second loading state is in an active state. If it is, construct a second waitForCompleteJS script. Judge whether the readyState state of the second waitForCompleteJS script is in a completed state. If the readyState state of the second waitForCompleteJS script is in a completed state, call the completeProgress function to end this loading request. Call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state.

2. The loading progress monitoring method according to claim 1, wherein Before Step 1, the method further includes: Call the addObserver function to construct a progress observer; wherein, the callback processing parameter of the progress observer is the webView control, the KeyPath parameter of the progress observer is the estimatedProgress function, and the observed value parameter of the progress observer includes the old value and the new value of the estimatedProgress function.

3. The loading progress monitoring method according to claim 1, wherein Before Step 1, the method further includes: Obtain the URL of this loading request. Obtain the URL of the currently loaded successfully. Judge whether the URL of this loading request is the same as the URL of the currently loaded successfully. If the URL of this loading request is the same as the URL of the currently loaded successfully, call the completeProgress function to end this loading request. Call the incrementProgress function to update the progress displayed in the progress display control to the loaded completed state. If the URL of this loading request is not the same as the URL of the currently loaded successfully, perform Step 1.

4. The loading progress monitoring method according to claim 1, wherein, After Step 5, the method further includes: Step 11: Judge whether an exception handling occurs during the execution of this loading request. Step 12, if it occurs, then subtract 1 from the current number of loading tasks to reduce the current number of loading tasks; Step 13, according to the reduced current number of loading tasks in Step 12, call the incrementProgress function to update the progress displayed in the progress display control.

5. The loading progress monitoring method according to claim 4, wherein After the said Step 13, the method further includes: Obtain the first loading state of the current page according to the stringByEvaluatingJavaScriptFromString function; Judge whether the first loading state is in an active state; If the first loading state is not, then construct the first waitForCompleteJS script; Judge whether the readyState state of the first waitForCompleteJS script is in a completed state; If the readyState state of the first waitForCompleteJS script is in a completed state, then call the completeProgress function to end the current loading request; Call the incrementProgress function to update the progress displayed in the progress display control to the state of loading completed.

6. The loading progress monitoring method according to claim 1, characterized in that The said Step 7 includes: Call the setProgress function to obtain the current first progress value; Call the incrementProgress function to obtain the current second progress value; Judge whether the current first progress value is greater than the current second progress value; If it is greater, then update the current second progress value to the current first progress value; According to the updated current second progress value, call the incrementProgress function to update the progress displayed in the progress display control.

7. A computer device, characterized in that, It includes: A memory for storing a computer program; A processor for executing the computer program to implement the steps of the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Webpage loading progress monitoring method and webpage loading progress monitoring device

    CN103914302A

  • Page loading progress display method and device and mobile terminal

    CN105491129A