Picture loading method, electronic equipment, storage medium and program product

By obtaining and preloading the address information of the image to be loaded in advance and cached it to the local library, the problem of users in traditional technology being unable to see the image as soon as possible is solved, and the target image is quickly displayed and the waiting time is reduced.

CN119646335APending Publication Date: 2025-03-18KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411864232.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

When loading pictures on traditional front-end pages, they need to wait for the pictures to be downloaded from the network to the local area before displaying, resulting in users being unable to see the pictures as soon as possible when the view container requests pictures, and they need to wait for a white screen or a placeholder map.

Method used

By obtaining the address information of the image to be loaded in advance when the page loads the request, and preloading it to the local library as a preloaded image. When the view container requests a target image, find and provide preloaded images from the local library for display.

Benefits of technology

It realizes that the target image is displayed immediately after the view container is created, without waiting for download from the network, reducing the time for users to wait for the target image to be displayed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646335A_ABST
    Figure CN119646335A_ABST
Patent Text Reader

Abstract

The invention provides a picture loading method, electronic equipment, a readable storage medium and a computer program product. The picture loading method comprises the steps of obtaining address information of a to-be-loaded picture in response to a page loading request; based on the address information of the to-be-loaded picture, loading the to-be-loaded picture to a local picture library as a pre-loaded picture; in response to an acquisition request of the view container for the target picture, determining the target picture in the preloaded pictures of the local library; and providing the target picture to the view container for display.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a picture loading method, electronic equipment, storage medium and program product. Background Art

[0002] At present, when a traditional front-end page displays a certain image, it often loads the corresponding view container when the corresponding page is drawn, and initiates a network request to obtain the image when the view container is created. As a result, when the view container is waiting for the image to be displayed, the user will first see a large white screen or other image placeholders, and wait for the image to be downloaded from the network to the local computer before the replacement display can be completed, and the image requested by the view container cannot be displayed immediately. Summary of the invention

[0003] The present disclosure provides a picture loading method, electronic device, storage medium and program product.

[0004] According to one aspect of the present disclosure, a method for loading an image is provided, comprising: In response to a page loading request, the address information of the image to be loaded is obtained; based on the address information of the image to be loaded, the image to be loaded is loaded into a local library as a preloaded image; in response to a request for obtaining a target image by a view container, the target image is determined in the preloaded images in the local library; and the target image is provided to the view container for display.

[0005] According to at least one embodiment of the image loading method of the present disclosure, the address information of the image to be loaded is obtained, including: in response to a page loading request, obtaining the resource file of the page; and extracting the image address information from the resource file of the page to obtain the address information of the image to be loaded.

[0006] According to at least one embodiment of the image loading method disclosed herein, image address information is obtained in the resource file of the page to obtain the address information of the image to be loaded, including: performing field segmentation processing on the resource file, dividing the resource file into multiple fields based on the value symbol and separator symbol of the resource file; retrieving the field with the address annotation from the multiple fields, determining the field with the address annotation as the address field; and obtaining the attribute value of the address field, and obtaining the address information of the image to be loaded based on the attribute value of the address field.

[0007] According to at least one embodiment of the image loading method of the present disclosure, the attribute value of the address field is obtained, and the address information of the image to be loaded is obtained based on the attribute value of the address field, including: converting the attribute value of the address field into an address string and storing it in an address set; deserializing each of the address strings in the address set to obtain an address object corresponding to each address string; and splicing each of the address objects into the address information of the image to be loaded.

[0008] According to at least one embodiment of the image loading method of the present disclosure, based on the address information of the image to be loaded, the image to be loaded is loaded into the local library, including: adding the address information of the image to be loaded to a preloading queue, and configuring the loading order of the images to be loaded based on the order in which the address information of the images to be loaded is obtained; and based on the loading order in the preloading queue, accessing the address information of the images to be loaded in the preloading queue in sequence, and loading the images to be loaded into the local library.

[0009] According to at least one embodiment of the present disclosure, the image loading method further includes: in response to the target image not existing in the preloaded images of the local library, searching for address information of the target image in the preloading queue; and in response to the preloading queue including the address information of the target image, adjusting the loading priority of the target image in the preloading queue to the highest priority.

[0010] According to at least one embodiment of the image loading method of the present disclosure, the image to be loaded is loaded into a local library based on the address information of the image to be loaded, and also includes: obtaining a resource occupation notification; in response to the resource occupation notification being high resource occupation, pausing the image loading task in the preloading queue; and in response to the resource occupation notification being low resource occupation, continuing to execute the paused image loading task in the preloading queue.

[0011] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the image loading method of any embodiment of the present disclosure.

[0012] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the image loading method of any embodiment of the present disclosure is implemented.

[0013] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the image loading method of any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0015] Figure 1 It is a schematic diagram of an application scenario of a picture loading method according to an embodiment of the present invention.

[0016] Figure 2 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0017] Figure 3 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0018] Figure 4 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0019] Figure 5 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0020] Figure 6 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0021] Figure 7 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0022] Figure 8 It is a flowchart of a method for loading an image according to an embodiment of the present invention.

[0023] Fig. 9 It is a schematic block diagram of the structure of a picture loading device according to an embodiment of the present disclosure.

[0024] Fig.10 It is a schematic block diagram of the structure of an electronic device equipped with a picture loading device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0025] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0027] When displaying images on the front-end page (such as Android page, Hongmeng page, etc.), it is usually necessary to obtain data containing the image address information (url) from the network, convert the data containing the image address information into a file in JSON (JavaScript Object Notation, abbreviated as: JSON) format, and then parse the JSON format file into a local Java object so that the correct image address information is stored locally. When the front-end page is drawn, the view container will be loaded. The visual container completes the network request for the target image object according to the image address information in the Java object, downloads the target image from the network and displays it. From the user's perspective, in the process from the visual container initiating the network request for the image object to downloading the target image from the network and displaying it, the target image cannot be seen. Usually, only the default white screen interface when no image is displayed, or the preset placeholder image, can be seen until the target image is downloaded. That is to say, from the user's perspective, when the user's operation on the front-end page needs to display the target image, the target image is often not visible at the first time. The view container needs to respond to the user's operation and download the target image, and wait until the target image is downloaded before the target image can be displayed.

[0028] Figure 1 The application scenario of the image loading method of an embodiment of the present disclosure is shown. In this application scenario, an Android page is used as an example of a front-end page, and the images corresponding to the image address information contained in the resources of the Android page are recorded as images to be loaded, indicating that in this Android page, according to the preset image display strategy or the user's operation, the images corresponding to these image address information may need to be loaded. That is, the images that may be displayed on the Android page are recorded as images to be loaded, and the address information of the images to be loaded is contained in the resources of the Android page.

[0029] For example, Figure 1As shown, in the Android system, the resources of the Android page are usually files in JSON format. If you want to display the image to be loaded on the page, you need to parse the Java object containing the image address information of the image to be loaded from the JSON format file, so that you can extract the address information of the image to be loaded from this Java object, and initiate a network request to load the image to be loaded according to the address information of the image to be loaded. In addition, in the embodiment of the present disclosure, the loading of the image to be loaded does not depend on the creation of the view container. Specifically, the embodiment of the present disclosure maintains a local library in the background, and when responding to the loading request of the Android page, the image to be loaded is downloaded from the network to the local library for cache according to the address information of the image to be loaded, and the cached images in the local are recorded as preloaded images. When it is necessary to display a certain image to be loaded, the preloaded image corresponding to the image to be loaded that has been downloaded to the local can be found in the local library, and this process can be completed before the view container is created. In this way, the target image can be found in all the preloaded images in the local library for display at the first time after the view container is created, without waiting for the target image to be downloaded from the network, so that the user can see the display of the target image at the first time.

[0030] Figure 2 FIG. 1 is a schematic diagram showing the overall process of a method M100 for loading an image according to an embodiment of the present disclosure. Figure 2 The method shown includes steps S110 to S140. The method can be executed by electronic devices such as mobile phones and tablet computers.

[0031] Specifically, Figure 2 The methods shown include: S110. In response to the page loading request, obtain address information of the image to be loaded.

[0032] Among them, the embodiment of the present disclosure is mainly applicable to the loading of images on Android pages. Android pages refer to application program interfaces running on the Android operating system. For other pages other than Android pages, such as web pages, h5 pages, etc., the image loading method M100 of the embodiment of the present disclosure can also be implemented to load images, without limitation here.

[0033] The image to be loaded refers to the image contained in the resource file of the page, which is usually an image that may be displayed on the page, for example, displayed based on the image display strategy configured on the page, or triggered by the user's operation, etc., and there is no restriction here.

[0034] The address information of the image to be loaded refers to the information that can obtain the address of the image, such as a specific domain name, path, etc. The address information of the image to be loaded can specifically refer to the uniform resource locator (URL) of the image to be loaded. In an example, if the address information of an image is in a resource file of a page, the image is recorded as the image to be loaded of the page, indicating that the image may be loaded and displayed on this page.

[0035] S120: Based on the address information of the image to be loaded, load the image to be loaded into the local library as a preloaded image.

[0036] Among them, the local library refers to the local image storage space of the user's device. The local library can be used to cache images downloaded from the Internet. The image to be loaded in the preloaded address information in the local library refers to initiating a network request based on the address information, and obtaining the image to be loaded indicated by the address information from the network. When a picture is in the state of being downloaded from the network to the local library, the status of this picture is recorded as a loading picture. When a picture has been downloaded from the network to the local library, the status of this picture is recorded as a loaded picture. The loaded pictures in the local library, that is, the pictures that have been downloaded to the local library, are determined to be preloaded pictures. At this time, if the picture to be loaded is requested to be obtained, this picture to be loaded has been determined as a preloaded picture in the local library, then there is no need to download this picture from the network, and the picture can be directly obtained in the local library.

[0037] S130 . In response to the view container's request for obtaining the target image, determine the target image from preloaded images in the local library.

[0038] In the embodiments of the present disclosure, the loading process of the image to be loaded is separated from the view container, and the process of preloading the image in the local library can be performed before the creation of the view container, or it can be performed synchronously when the view container is created, which is not limited here. In this way, the image to be loaded that has been downloaded to the local can be obtained and displayed as soon as the view container is created.

[0039] The target image refers to the image that needs to be displayed. The view container can manage the view layout of the page and set the target image to be displayed in the layout structure of the page. When there is a task to display the target image, the view container initiates a request to obtain the target image. When the system responds to the request to obtain the target image, it determines the target image from the preloaded images in the local library. If the target image can be determined in the local library, the target image can be returned to the view container for display.

[0040] S140: Provide the target image to the view container for display.

[0041] The target image is displayed in the view container by using the view component managed by the view container. For example, by using the ImageView class and setting the image source of the ImageView class to an image in the local library, a request can be initiated to use the image in the local library for display.

[0042] If the target image can be found in the local library, it means that the target image has been pre-stored in the local library. At this time, there is no need to download the target image from the network. The target image in the local library can be directly transferred to the view container for display. In this way, during the process from the view container initiating a request to obtain the target image to the target image being transferred to the view container for display, the target image can be quickly obtained locally instead of being downloaded from the network, so that the target image can be displayed immediately, reducing the waiting time for the target image to be displayed.

[0043] If the target image cannot be found in the local library temporarily, you can wait for a while. At this time, the target image may be in the loading state. After a short waiting time, it can be downloaded to the local library. When the target image is downloaded to the local library, the target image can be found and transferred to the view container for display. Compared with downloading the target image from the network again, the time required to wait for the target image being loaded in the local library to complete the download is shorter, which can also reduce the waiting time for the target image to be displayed.

[0044] In summary, the image to be loaded in the embodiment of the present disclosure can be downloaded from the network to the local library as early as when responding to a page loading request, and cached as a preloaded image, so that the preloading timing of the preloaded image is not related to the creation timing of the view container, and the download can be completed in the local library before the creation of the view container, so that after the view container is created, the preloaded image can be transmitted to the view container for display as soon as it is determined as the target image, thereby reducing the waiting time for the target image to be displayed.

[0045] Specifically, taking the Android system as an example, assuming that the page architecture of the Android system is configured to display images based on multiple view containers (view trees), then in the scheme of the embodiment of the present disclosure, the target image is not preloaded based on the address of the target image based on the view container, and the loading of the target image does not depend on the completion of the creation of the view container. When the network request for the page begins, the address of the target image can be obtained, and the loading of the target image can be started, and the target image can be cached to the local library. In other words, the timing of starting to load the target image can be earlier than the timing of creating the view container, or it can be done during the creation process of the view container, so that some target images can be cached before the view container is completed.

[0046] When the view container for displaying the target image is created, the view container will first obtain the cached target image from the local library to reduce the waiting time for the user to wait for the target image to be displayed. The target image can be displayed synchronously when the view container is created. Alternatively, if the target image in the local library has not been cached, when the view container is created, it only needs to wait for the target image in the local library to be cached. The view container does not need to initiate a request to obtain the target image and wait for the target image to be downloaded from scratch, thereby reducing the waiting time for the user to wait for the target image to be displayed.

[0047] Regarding step S110, in some embodiments of the present disclosure, it may include: Figure 3 Steps S1110 to S1120 are shown.

[0048] S1110. In response to a page loading request, obtain a resource file of the page.

[0049] The resource files of the page include various data resources of the page application, such as pictures, strings, colors, layout files, etc. In some embodiments of the present disclosure, the resource files of the page are files in JSON format, in the form of strings. When the page of the Android system is loaded, the file in JSON format is parsed for display.

[0050] S1120. Extract image address information from the resource file of the page to obtain address information of the image to be loaded.

[0051] In some implementations, the image address information is included in the resource file of the page and has a specific format or a specific field. It can be searched based on the rules corresponding to the specific format, or searched based on the specific field, and the address information of the image to be loaded can be extracted based on the search result. For example, the address information of the image to be loaded is the URL of the image to be loaded, which has a specific URL field. By searching the specific URL field, obtaining the value of the specific URL field, and extracting the URL of the image to be loaded from the resource file according to the value of the specific URL field, the URL of the image to be loaded can be obtained.

[0052] In some embodiments, the resource file of the page of the Android system is a file in JSON format, in the form of a string, and is recorded as a JSON string. A JSON parsing library provided by the Android system, such as a Gson parsing library, a JSON_Object parsing library, etc., can be used to parse the field corresponding to the address information of the image to be loaded in the JSON string to extract the address information of the image to be loaded from the resource file.

[0053] Further, regarding step S1120, in some embodiments of the present disclosure, it may include: Figure 4The steps S1121 to S1123 shown. Steps S1121 to S1123 are applicable to the case where the resource file is a JSON - formatted file, and are used to extract the address information of the image to be loaded from the resource file.

[0054] S1121. Perform field splitting on the resource file, and split the resource file into multiple fields based on the value symbol and delimiter of the resource file.

[0055] The resource file in JSON format usually includes multiple types of fields. To facilitate finding the field corresponding to the image address, it is necessary to perform field splitting on the resource file and split the fields in the resource file.

[0056] Performing field splitting on the resource file can be done based on the value symbol of the resource file. The value symbol of the resource file refers to the symbol used to represent the value in the resource file, such as the "[]" symbol, "{}" symbol, etc. The delimiter of the resource file refers to the symbol used to separate the fields in the resource file, such as the "," symbol.

[0057] For example, a part of the content of a JSON - formatted resource file is as follows: “{ "name": "Zhang San", "age": "30" }” This part of the content includes the value symbol "{}", so the content within the value symbol "{}" is split into fields. Among them, the delimiter "," includes two fields "name" and "age" before and after, so this part of the content can be split into two fields, namely "name": "Zhang San" and "age": "30".

[0058] S1122. Retrieve the fields with address annotations among the multiple fields, and determine the fields with address annotations as address fields.

[0059] When retrieving the fields related to the address information of the image to be loaded among the multiple fields, it can be achieved by using the Java annotation function. Java annotation (Annotation) is a mechanism for providing metadata, which can be checked and processed at compile - time or run - time. The annotation itself does not directly perceive that an object is assigned a value, but rather the compiler or run - time tools process the annotation and perform corresponding operations.

[0060] First, define a custom annotation, called address annotation, to mark the image URL field that needs to be stored. Based on the address annotation, when configuring the JSON resource file, use the address annotation to mark the image URL field that needs to be stored. Next, when parsing the JSON resource file, traverse all fields and search for fields marked by the address annotation in all fields. If there is a field marked by the address annotation, determine the field as the address field.

[0061] S1123. Acquire the attribute value of the address field, and obtain the address information of the image to be loaded based on the attribute value of the address field.

[0062] In some implementations, the attribute of the address information of the image to be loaded is a string field, and when the address field is found, the attribute value of the address field is the address information of the image to be loaded. In this case, obtaining the address information of the image to be loaded based on the attribute value of the address field includes determining the attribute value of the address field as the address information of the image to be loaded.

[0063] In some implementations, the attribute of the address information of the image to be loaded is a nested object or array. In this case, the address information of the image to be loaded corresponds to multiple address fields, and the attribute value of each address field corresponds to an element of the address information array. It is necessary to use a recursive parsing method to obtain the attribute values ​​of the multiple address fields, and perform deserialization processing based on the attribute value of each address field. The address information of the image to be loaded is obtained according to the deserialization processing result of the attribute value of each address field. Combining the above steps S1121 to S1123, during the preloading process, the process of obtaining the address information of the image to be loaded is a non-perceptual process, and it is only necessary to store the pre-defined address annotation in the correct parsing position.

[0064] Further, regarding step S1123, in some embodiments of the present disclosure, it may include: Figure 5 Steps S11231 to S11233 are shown. Steps S11231 to S11233 are applicable to obtaining the address information of the image to be loaded based on the attribute value of the address field when the attribute of the address information of the image to be loaded is a nested object or array.

[0065] S11231. Convert the attribute value of the address field into an address string and store it in the address collection.

[0066] The address collection is a Java collection created in the process of obtaining the address information of the image to be loaded based on the attribute value of the address field, such as a list collection, an array collection, etc., which are not limited here. The address collection is used to store the string obtained by recursive parsing.

[0067] S11232. Deserialize each address string in the address set to obtain an address object corresponding to each address string.

[0068] The address object refers to the Java object corresponding to the address string. Deserialization refers to the process of restoring a string to a Java object. Specifically, taking the case where the address information is an array as an example, when storing the address information in a resource file in JSON format, each element of the address information array is first converted into a JSON string through serialization, and the mapping relationship between the elements of the address information array and the JSON string is retained. Based on this mapping relationship, the JSON string (address string) can be restored to a Java object during the deserialization process, that is, restored to an element in the address information array. Each address string in the same address set is mapped from different elements in the same address information array. Therefore, by deserializing each address string in the same address set into an address object, each element in the same address information array can be obtained.

[0069] S11233. Concatenate each address object into address information of the image to be loaded.

[0070] Here, each address object refers to the address object corresponding to each address string in the same address set. In this way, by splicing each address object, the address information of the image to be loaded can be obtained.

[0071] In an example, the deserialization and concatenation processes from step S11231 to step S11233 can be implemented by using the Gson parsing library.

[0072] In some embodiments of the present disclosure, the address information of the image to be loaded is obtained as a model data object. The created view container can initiate a request to obtain the image to be loaded corresponding to the address information according to the address information in the model data object, wherein the image to be loaded obtained by the view container request is recorded as the target image. In an embodiment of the present disclosure, in response to the view container's request to obtain the target image, a network request is not initiated to download the target image according to the address information of the target image, but first a search is made to see whether the target image is cached in the local library. If the target image is cached, the target image can be directly transferred to the view container for display without spending time downloading the target image from the network.

[0073] Regarding step S120, in some embodiments of the present disclosure, it may include the following steps: Figure 6 Steps S1201 to S1202 are shown.

[0074] S1201: Add address information of the to-be-loaded pictures to a preloading queue, and configure a loading order of the to-be-loaded pictures based on the order in which the address information of the to-be-loaded pictures is obtained.

[0075] The preload queue is used to plan the early loading of image resources that may be requested, so as to complete the loading of these image resources in advance before the view container actually requests the image resources.

[0076] The loading order of the images to be loaded is the order in which network requests are initiated to obtain the images to be loaded. Multiple images to be loaded in the preload queue can be loaded at the same time, but the network requests for the multiple images to be loaded are initiated in sequence according to the loading order.

[0077] The loading order of the images in the preloading queue can be executed in a first-in-first-out order, that is, the address information extracted first is added to the preloading queue first, and a network request is initiated to the corresponding address to download the image in the order in which the address information is added to the preloading queue.

[0078] S1202: Based on the loading order in the preloading queue, access the address information of the to-be-loaded pictures in the preloading queue in sequence, and load the to-be-loaded pictures into the local library.

[0079] In one example, a preloading task class is defined, such as the PreloadTask class, which contains the address information of the image to be loaded and the preloading callback. A preloading queue is also created, LinkedList is used to manage the preloading task queue, and Handler and Thread are used to execute the preloading task. When executing the preloading task, Glide is used in the background thread to preload the image in the address information, and Glide is used to cache the downloaded image in the local library. At this time, the image cached in the local library is recorded as a loaded image. When the loading task of the image to be loaded is completed, that is, when the image to be loaded is loaded into the local library, the address information of the image to be loaded will be removed from the preloading queue.

[0080] Regarding step S120, in some embodiments of the present disclosure, it may also include the following Figure 7 Steps S1203 to S1205 are shown.

[0081] S1203. Obtain resource occupation notification.

[0082] The resource occupancy notification is used to indicate the current resource occupancy of the system. In an example, a resource may refer to CPU usage, memory usage, disk I / O, network bandwidth usage, etc. You can select to monitor specific resources and regularly notify the occupancy of the resource according to the application scenario.

[0083] S1204: In response to the resource occupancy notification indicating high resource occupancy, suspend the image loading task in the preloading queue.

[0084] Among them, high resource occupancy means that the current resources are relatively tight. For example, the resource occupancy notification is used to indicate the current memory occupancy of the system. When the memory occupancy of the system is monitored to be greater than the memory occupancy threshold, a high resource occupancy notification is issued. Similarly, when the resource occupancy notification is used to indicate the current CPU usage of the system, when the CPU usage of the system is monitored to be greater than the CPU usage threshold, a high resource occupancy notification is issued. Similarly, when the resource occupancy notification is used to indicate the current disk I / O of the system, when the disk I / O of the system is monitored to be greater than the I / O threshold, a high resource occupancy notification is issued. Similarly, when the resource occupancy notification is used to indicate the current network bandwidth usage of the system, when the network bandwidth occupancy of the system is monitored to be greater than the bandwidth threshold, a high resource occupancy notification is issued.

[0085] That is to say, it is possible to determine whether the system is currently in a state of high resource occupancy based on a high resource occupancy threshold. The high resource occupancy threshold may be a threshold set based on a combination of one or more parameters such as memory occupancy, CPU usage, disk I / O, network bandwidth, etc. If the resource monitoring software or program monitors that the system's current real-time parameters related to the high resource occupancy threshold exceed the high resource occupancy threshold, it is determined that the system is currently in a state of high resource occupancy, and the resource monitoring software or program issues a resource occupancy notification indicating high resource occupancy.

[0086] For example, the memory usage rate x% can be set as the high resource usage threshold, and if the resource monitoring software or program monitors that the current system memory usage rate exceeds x%, a high resource usage notification is issued. The value of x can be set by those skilled in the art according to specific needs.

[0087] For another example, the high resource usage threshold can be configured as a threshold of a combination of multiple parameters, such as configuring the combination of the two parameters of memory usage x% and CPU usage y% as the high resource usage threshold. If the current memory usage of the system exceeds x%, but the CPU usage does not exceed y%, it does not belong to the high resource usage situation. Only when the current memory usage of the system exceeds x% and the CPU usage exceeds y%, will it be determined that the system is in a high resource usage state, and the resource monitoring software or program will issue a high resource usage notification.

[0088] In response to the resource usage notification of high resource usage, the image loading task in the preloading queue is suspended. In this way, on the one hand, it is possible to avoid caching images in the case of high resource usage, so as to avoid image caching failure due to excessive resource usage, and on the other hand, it is possible to free up the resources used for loading images to execute the currently ongoing tasks, so as to avoid preloading images blocking high-priority tasks or causing high-priority tasks to freeze.

[0089] In one example, pausing the image loading task in the preloading queue specifically refers to pausing the loading task of the image with the highest loading priority in the preloading queue. Since the images in the preloading queue initiate network requests in sequence according to the loading order, when the loading task of the image with the highest loading priority is suspended, since the network request of the task cannot be issued, other subsequent loading tasks are also blocked and no network request is issued, so that the subsequent loading tasks of other images are blocked and equivalent to being suspended.

[0090] S1205 . In response to the resource occupancy notification indicating low resource occupancy, continue to execute the suspended image loading task in the preloading queue.

[0091] Specifically, in response to the resource occupancy notification of low resource occupancy, a search is performed to determine whether there is a paused image loading task. If there is a paused image loading task, execution of the loading task is resumed, so that the image loading tasks in the preloading queue are resumed and continued to be executed.

[0092] Similar to the scheme described above for determining whether the system is currently in a state of high resource occupancy, a threshold judgment method can be used to determine whether the system is currently in a state of low resource occupancy. The low resource occupancy threshold can also be a threshold set based on a combination of one or more of the parameters such as memory occupancy, CPU usage, disk I / O, network bandwidth, etc. If the resource monitoring software or program monitors that the system's current real-time parameters related to the low resource occupancy threshold are lower than the low resource occupancy threshold, it is determined that the system is currently in a state of low resource occupancy, and the resource monitoring software or program issues a resource occupancy notification indicating low resource occupancy.

[0093] In one example, only one threshold is used to determine the high resource occupancy state and low resource occupancy state of the system. For example, the memory occupancy rate x% can be set as the resource occupancy threshold. If the resource monitoring software or program monitors that the current memory occupancy rate of the system exceeds x%, a high resource occupancy notification is issued. If the resource monitoring software or program monitors that the current memory occupancy rate of the system is less than or equal to x%, a low resource occupancy notification is issued. The value of x can be set by those skilled in the art according to specific needs.

[0094] In another example, two thresholds, a high resource occupancy threshold and a low resource occupancy threshold, are used to determine whether the system is in a high resource occupancy state or a low resource occupancy state. Among them, the values ​​of the high resource occupancy threshold and the low resource occupancy threshold are different. For example, when the current memory occupancy rate of the system exceeds x1%, it is judged to be in a high resource occupancy state, and when the current memory occupancy rate of the system is lower than x2%, it is judged to be in a low resource occupancy state. Among them, x1>x2, and the values ​​of x1 and x2 can be set by those skilled in the art according to specific needs. In this case, there is a scenario where the current memory occupancy rate of the system is x3%, x1>x3>x2, that is, the resource occupancy state of the system is between the high resource occupancy state and the low resource occupancy state, and this state is called a buffer state. Because the change of the system from a high resource occupancy state to a low resource occupancy state is often not instantaneous, there may be a change process from high to low and then from low to high in the middle. For example, the memory occupancy rate of the system drops from a state higher than x1% to a state lower than x1% and then rises back to a state higher than x1%. If the memory usage is lower than x1%, it is judged as low resource usage. Then, when the memory usage fluctuates between higher and lower than x1%, notifications of high resource usage and low resource usage will be frequently switched, causing the image loading task to frequently switch between suspending execution and continuing execution, which is not very intelligent. Based on this, a high resource usage threshold is set for the state of high resource usage, and a low resource usage threshold is set for the state of low resource usage. A high resource usage notification is issued only when the parameter related to the resource usage threshold is higher than the resource usage threshold, and a low resource usage notification is issued only when the parameter related to the resource usage threshold is lower than the resource usage threshold. When the parameter related to the resource usage threshold is between the high resource usage threshold and the low resource usage threshold, that is, when the system is in a buffering state, no notification related to resource usage is issued, so that the originally suspended image loading task remains suspended, and the originally loading image loading task continues to load. In this way, it is possible to avoid the image loading task from repeatedly switching between suspending execution and continuing execution.

[0095] In another example, it is also possible to determine whether the system is currently in a low resource occupancy state based on the range judgment method. For example, a parameter range [a1, a2] is set to represent high resource occupancy, and a parameter range [b1, b2] is set to represent low resource occupancy. When the parameter related to resource occupancy is within the range [a1, a2], the system is determined to be in a high resource occupancy state, and a high resource occupancy notification is issued; when the parameter related to resource occupancy is within the range [b1, b2], the system is determined to be in a low resource occupancy state, and a low resource occupancy notification is issued. If the parameter related to resource occupancy is neither within the range [a1, a2] nor within the range [b1, b2], no notification related to resource occupancy is issued, so that the originally paused image loading task remains paused, and the originally loading image loading task continues to load.

[0096] In some embodiments of the present disclosure, a priority processing strategy is introduced based on the preloading queue so that specific images to be loaded can be loaded first. For example, assuming that a certain image to be loaded is recorded as image A, and the current loading order of image A in the preloading queue is the 100th. At this time, the view container has completed the creation and initiated a request for image A, then the loading order of image A can be adjusted to the 1st place, and the loading task of image A can be started immediately after the loading of the currently loading image is completed, that is, after the loading of the image with the loading order of the 0th place is completed. In this way, the target image can be loaded in priority response to the view container's task.

[0097] Specifically, in some embodiments of the present disclosure, the image loading method M100 may also include: Figure 8 Steps S150 to S160 are shown. Steps S150 to S160 are used to process a scenario where, in response to a request for obtaining a target image from a view container, a target image is searched for in all preloaded images in a local library.

[0098] S150 . In response to the target picture not existing in the preloaded pictures in the local library, searching for address information of the target picture in the preload queue.

[0099] That is to say, when the view container requests the target image, if the target image can be found in the local library, it means that the target image has been downloaded and cached in the local library. At this time, the target image can be directly obtained from the local library. If the target image does not exist in the local library, that is, the target image has not been downloaded to the local library, then when the view container requests the target image, it will be impossible to find the target image. In this case, the target image requested by the view container may be in the process of downloading or waiting to be downloaded. It can be determined whether the target image is in the process of downloading or waiting to be downloaded by judging whether there is the address information of the target image in the preloading queue. If the target image does not exist in the local library, but the address information of the target image is in the preloading queue, it can be determined that the target image has not been loaded yet. In this case, in order to respond to the acquisition request of the view container in a timely manner, the loading priority of the target image can be increased so that the target image is loaded first to reduce the waiting time for displaying the target image.

[0100] S160 . In response to the address information of the target picture being included in the preloading queue, adjusting the loading priority of the target picture in the preloading queue to the highest priority.

[0101] In some embodiments of the present disclosure, the images in the preloading queue are loaded in order of priority. In one example, when the address information of a picture is added to the preloading queue, an initial priority is configured for the picture based on the order in which the address information is obtained. For example, if the address information of picture A is the 100th address information obtained, the priority of picture A is configured to 100. The pictures in the preloading queue are loaded in order of priority from small to large. Assuming that the preloading queue currently also includes pictures with priorities of 1-99, the current loading order of picture A in the preloaded pictures is 100th.

[0102] The highest priority refers to the priority that takes precedence over the loading priority of any other picture in the preloading queue. In one example, the loading priority of the pictures in the preloading queue starts from "1" and is sequentially extended by 1 integer value, for example, the loading priority includes 1, 2, 3, ..., n, where n is an integer. The smaller the value of the loading priority, the higher the priority represented, and the earlier the order of loading. For example, a picture with a loading priority of "1" is loaded before a picture with a loading priority of "2". On this basis, the highest priority is configured to "0", indicating that it takes precedence over any other loading priority. When the loading priority of the target picture in the preloading queue is adjusted to the highest priority, the loading priority of the target picture is assigned to "0" so that it can be loaded immediately. For example, picture A is the target picture. When the address information of picture A is found in the queue to be loaded, the loading priority of picture A is "100", then the loading priority of picture A is adjusted to "0" to immediately trigger the loading task of picture A.

[0103] When the target image loading task is completed, that is, when the target image is cached in the local library, the target image in the local library is immediately transferred to the view container for display. Specifically, in some embodiments of the present disclosure, the image loading method M100 may also include the following: Figure 8 Step S170 shown.

[0104] S170: In response to the target image being loaded into the local library, providing the target image to the view container for display.

[0105] In one example, the target image is image A. If the address information of image A is found in the preload queue when executing step S150, the address information of image A in the preload queue is monitored. When the address information of image A is monitored to be removed from the preload queue, it indicates that the loading task of image A is completed. At this time, in response to the monitoring of the address information of image A being removed from the preload queue, image A can be searched in the preloaded images of the local library. If image A can be found in the local library, it indicates that image A has been loaded into the local library. In response to image A being loaded into the local library, image A is provided to the view container for display.

[0106] Based on any of the above implementations, the present disclosure also provides a picture loading device. Fig. 9 It is a schematic block diagram of the structure of a picture loading device according to an embodiment of the present disclosure.

[0107] like Fig. 9 As shown, the image loading device includes: The acquisition module 110 is used to obtain address information of a to-be-loaded image in response to a page loading request.

[0108] The preloading module 120 is used to load the to-be-loaded picture into the local library as a preloaded picture based on the address information of the to-be-loaded picture.

[0109] The search module 130 is used to determine the target image from the preloaded images in the local library in response to the view container's request for obtaining the target image.

[0110] The display module 140 is used to provide the target image to the view container for display.

[0111] In some embodiments of the present disclosure, the image loading device further includes a slicing module (not shown), which is used to split the knowledge package to obtain multiple slicing packages. Specifically, the slicing module can be used to obtain the knowledge package and identify the topological structure of the knowledge package; and in response to the topological structure of the knowledge package being a decision flow forest structure, split the knowledge package into multiple slicing packages, each slicing package corresponding to a decision flow in the knowledge package.

[0112] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0113] The execution subject of the image loading method in the specific implementation manner of the present disclosure may be an electronic device such as a mobile phone or a tablet computer.

[0114] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, which can execute the image loading method of any of the above embodiments of the present disclosure, and the image loading device of any of the above embodiments can be configured on the electronic device.

[0115] Fig.10 It is a schematic block diagram of the structure of an electronic device 1000 equipped with a picture loading device according to an embodiment of the present disclosure.

[0116] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.

[0117] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.

[0118] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0119] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0120] A computer program or instruction may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0121] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may 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.

[0122] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable image loading device to produce a machine, so that the instructions executed by the processor of the computer or other programmable image loading device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0123] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable image loading device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0124] These computer program instructions may also be loaded onto a computer or other programmable image loading device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0125] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0126] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0127] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A method for loading an image, characterized in that: include: In response to the page loading request, obtain the address information of the image to be loaded; Based on the address information of the image to be loaded, the image to be loaded is loaded into the local library as a preloaded image; In response to a request from the view container for obtaining a target image, determining the target image from preloaded images in the local library; as well as The target image is provided to the view container for display.

2. The image loading method according to claim 1, characterized in that: Get the address information of the image to be loaded, including: In response to a page loading request, obtaining a resource file of the page; and The image address information is extracted from the resource file of the page to obtain the address information of the image to be loaded.

3. The image loading method according to claim 2, characterized in that: Obtaining the image address information in the resource file of the page to obtain the address information of the image to be loaded includes: Performing field segmentation processing on the resource file, segmenting the resource file into multiple fields based on the value symbol and the separator symbol of the resource file; Retrieving the field with the address annotation from the plurality of fields, and determining the field with the address annotation as the address field; and The attribute value of the address field is obtained, and the address information of the image to be loaded is obtained based on the attribute value of the address field.

4. The image loading method according to claim 3, characterized in that: Acquiring the attribute value of the address field, and obtaining the address information of the image to be loaded based on the attribute value of the address field, including: Convert the attribute value of the address field into an address string and store it in an address set; Deserialize each of the address strings in the address set to obtain an address object corresponding to each of the address strings; and Each of the address objects is spliced ​​into the address information of the image to be loaded.

5. The image loading method according to claim 1, characterized in that: Based on the address information of the image to be loaded, the image to be loaded is loaded into the local library, including: Adding the address information of the to-be-loaded pictures to a preloading queue, and configuring the loading order of the to-be-loaded pictures based on the order in which the address information of the to-be-loaded pictures is obtained; and Based on the loading order in the preloading queue, the address information of the to-be-loaded pictures in the preloading queue is accessed in sequence, and the to-be-loaded pictures are loaded into the local library.

6. The image loading method according to claim 5, characterized in that: Also includes: In response to the target picture not existing in the preloaded pictures of the local library, searching for address information of the target picture in the preload queue; as well as In response to the preloading queue including the address information of the target picture, the loading priority of the target picture in the preloading queue is adjusted to the highest priority.

7. The image loading method according to claim 5, characterized in that: Based on the address information of the image to be loaded, the image to be loaded is loaded into the local library, and further includes: Get resource usage notification; In response to the resource occupancy notification being high resource occupancy, pausing the image loading tasks in the preloading queue; and In response to the resource occupancy notification being low resource occupancy, continuing to execute the suspended picture loading task in the preloading queue.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the image loading method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the image loading method according to any one of claims 1 to 7 when executed by the processor.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the image loading method according to any one of claims 1 to 7 is implemented.