Resource loading method and apparatus, and device and storage medium

By automatically detecting and correcting the mismatch between resource paths and types, the problem of resource loading errors in virtual scene applications is solved, and the accuracy and reliability of resource loading are improved.

WO2024183447A1PCT designated stage expired Publication Date: 2024-09-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Application Number
PCT/CN2024/071133
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-06
Filing Date
2024-01-08
Publication Date
2024-09-12

Smart Images

  • Figure CN2024071133_12092024_PF_FP_ABST
    Figure CN2024071133_12092024_PF_FP_ABST
Patent Text Reader

Abstract

A resource loading method and apparatus, and a device and a storage medium, which relate to the technical field of data processing. The method comprises: receiving a first resource loading request (201), wherein the first resource loading request is used for requesting asynchronous loading of a first resource; acquiring the resource type of the first resource (202); in response to the resource type of the first resource not matching the format of a resource path of the first resource, correcting the resource path of the first resource on the basis of the resource type of the first resource (203); and on the basis of the corrected resource path of the first resource, loading the first resource in an asynchronous loading manner (204). The solution can reduce resource loading errors and improve the accuracy of resource loading.
Need to check novelty before this filing date? Find Prior Art

Description

Resource loading method, device, equipment and storage medium

[0001] This application claims priority to the Chinese patent application filed on March 6, 2023, with application number 202310242411.0 and invention name “Resource loading method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of the present application relate to the field of data processing technology, and in particular to a resource loading method, apparatus, device, and storage medium. Background Art

[0003] During the operation of a virtual scene application based on a game engine, resource loading is usually involved.

[0004] In related technologies, when a virtual scene application based on a game engine is running, resources are first loaded asynchronously through an asynchronous loading process, and the asynchronously loaded resources are cached in the memory of a computer device. Subsequently, when resources are loaded synchronously through a synchronous loading process, the cached resources are queried from the memory; wherein, during asynchronous loading, after receiving a resource loading request, the corresponding resources can be loaded through the resource path indicated by the resource loading request.

[0005] However, in the above resource loading solution, when the path indicated by the resource loading request is incorrect, resource loading errors may occur, affecting the accuracy of resource loading.

[0006] Summary of the Invention

[0007] The embodiments of the present application provide a resource loading method, apparatus, device, and storage medium, which can improve the accuracy of resource loading. The technical solution is as follows:

[0008] According to one aspect of an embodiment of the present application, a resource loading method is provided, the method being executed by a computer device, the method comprising:

[0009] receiving a first resource loading request, where the first resource loading request is used to request asynchronous loading of a first resource; the first resource loading request indicates a resource path of the first resource;

[0010] Obtaining the resource type of the first resource;

[0011] In response to a mismatch between the resource type of the first resource and the format of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource;

[0012] Based on the corrected resource path of the first resource, the first resource is loaded in an asynchronous loading manner.

[0013] According to one aspect of an embodiment of the present application, a resource loading device is provided, the device comprising:

[0014] A first request receiving module is configured to receive a first resource loading request, wherein the first resource loading request is configured to request asynchronous loading of a first resource; the first resource loading request includes a resource path of the first resource;

[0015] A resource type acquisition module, configured to acquire the resource type of the first resource;

[0016] a path correction module, configured to correct the resource path of the first resource based on the resource type of the first resource in response to a mismatch between the resource type of the first resource and the format of the resource path of the first resource;

[0017] A loading module is configured to load the first resource in an asynchronous loading manner based on the corrected resource path of the first resource.

[0018] In a possible implementation, the path correction module is used to:

[0019] Obtain the suffix of the resource path of the first resource;

[0020] In response to the resource type of the first resource not matching the suffix of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

[0021] In one possible implementation, the path correction module is used to add the specified suffix to the resource path of the first resource in response to the resource type of the first resource being a blueprint type and the suffix of the resource path of the first resource being not a specified suffix, to obtain a corrected resource path of the first resource.

[0022] In one possible implementation, the path correction module is used to remove the specified suffix on the resource path of the first resource in response to the resource type of the first resource being a non-blueprint type and the suffix of the resource path of the first resource being a specified suffix, to obtain a corrected resource path of the first resource.

[0023] In a possible implementation, the resource type acquisition module is configured to determine the resource type corresponding to the application programming interface API receiving the first resource loading request as the resource type of the first resource.

[0024] In a possible implementation, the first resource loading request indicates resource paths of N resources, where the N resources include the first resource; N is an integer greater than or equal to 2;

[0025] The device further comprises:

[0026] a resource partitioning module, configured to, in response to N being greater than a first threshold, partition the resource paths of the N resources into at least two resource path sets; wherein the number of resource paths contained in each resource path set is no greater than the first threshold; and the N resources are loaded in batches using the resource path sets as units;

[0027] The path correction module is used to correct the resource path of the first resource based on the resource type of the first resource in response to the fact that the resource path set corresponding to the current processing batch includes the first resource and the resource type of the first resource does not match the format of the resource path of the first resource.

[0028] In a possible implementation, the apparatus further includes:

[0029] an adding module, configured to add the first resource loading request to a waiting queue in response to the number of asynchronous resource loading requests being processed reaching a second threshold;

[0030] The path correction module is used to remove the first resource loading request from the waiting queue in response to the number of asynchronous resource loading requests being processed being less than the second threshold and the first resource loading request being at the top of the waiting queue, and to execute the step of correcting the resource path of the first resource based on the resource type of the first resource in response to the mismatch between the resource type of the first resource and the format of the resource path of the first resource.

[0031] In a possible implementation, the adding module is configured to insert the first resource loading request into the waiting queue based on the priority of the first resource loading request and the priorities of the asynchronous resource loading requests already in the waiting queue.

[0032] In a possible implementation, the apparatus further includes:

[0033] The sorting module is used to sort the asynchronous resource loading requests in the waiting queue based on the respective priorities of the at least two asynchronous resource loading requests in response to the waiting queue containing at least two asynchronous resource loading requests and the waiting queue meeting the sorting condition.

[0034] In a possible implementation, the sorting condition includes at least one of the following conditions:

[0035] The number of asynchronous resource loading requests being processed is less than the second threshold;

[0036] The time interval between the current moment and the first moment reaches a time threshold; the first moment is the moment when the asynchronous resource loading requests in the waiting queue were last sorted;

[0037] Furthermore, after the first moment, the number of asynchronous resource loading requests newly added to the waiting queue is not less than a third threshold.

[0038] In a possible implementation, the apparatus further includes:

[0039] A second request receiving module, configured to receive a second resource loading request, where the second resource loading request is used to request synchronous loading of a second resource;

[0040] A query module, configured to query the second resource in a memory; the memory stores resources loaded via an asynchronous resource loading request;

[0041] The loading stopping module is configured to stop the loading process of the second resource in response to not finding the second resource in the memory.

[0042] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the above-mentioned resource loading method.

[0043] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned resource loading method.

[0044] In another aspect, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the resource loading method provided in the various optional implementations described above.

[0045] The technical solutions provided by the embodiments of the present application may have the following beneficial effects:

[0046] When receiving a request for asynchronous resource loading, the resource path indicated by the request is first matched with the resource type. If the resource path indicated by the request does not match the resource type, it means that the resource path indicated by the request is incorrect. At this time, the resource path is automatically corrected according to the resource type, and then the resource is loaded according to the corrected resource path. Since the above scheme can automatically correct the resource path that may be erroneous according to the resource type, it can ensure the accuracy of resource loading through the resource path, reduce the possibility of resource loading errors, and improve the accuracy of resource loading. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] FIG1 is a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application;

[0048] FIG2 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0049] FIG3 is a schematic diagram of a resource configuration tool configuring resources in a pipeline manner;

[0050] FIG4 is a diagram showing the implementation framework of resource loading involved in this application;

[0051] FIG5 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0052] FIG6 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0053] FIG7 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0054] FIG8 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0055] FIG9 is a flowchart of a resource loading method provided by an embodiment of the present application;

[0056] FIG10 is a schematic diagram of the reading speed of storage modules at various levels in a computer system;

[0057] FIG11 is a flowchart of synchronous resource loading involved in this application;

[0058] FIG12 is a flowchart of asynchronous resource loading involved in this application;

[0059] FIG13 is a flowchart of the asynchronous waiting queue processing involved in this application;

[0060] FIG14 is a flowchart of batch resource path processing involved in this application;

[0061] FIG15 is a block diagram of a resource loading device provided by one embodiment of the present application;

[0062] FIG16 is a structural block diagram of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0063] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0064] 1) Asset Load

[0065] When an application uses resources, it first needs to read the resources to be used from the resource file (which may be stored on the hard disk or in a network location) and then store them in the memory. The process of storing resources in the resource file in the memory is called resource loading.

[0066] 2) Preload

[0067] Preloading is an optimization technology for application operation that can significantly improve key performance indicators. It loads resources in advance and loads resources that the application may use later into memory in advance to improve resource loading efficiency when the application uses resources.

[0068] 3) Asynchronous loading

[0069] The process of launching one or more processes to load resources outside the main process of the application is called asynchronous resource loading. The asynchronous loading process does not affect the execution of the main process of the application.

[0070] 4) Synchronous loading

[0071] The process of loading resources through the application's main process is called synchronous resource loading. During synchronous loading, the application's main process needs to wait for the synchronous loading to complete before executing subsequent steps.

[0072] FIG1 shows a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application, which may include: a first terminal 110 and a server 120 .

[0073] The first terminal 110 has an application 111 installed and running. The application 111 can be an application developed based on a game engine. When the first terminal runs the application 111, the user interface of the application 111 is displayed on the screen of the first terminal 110. Optionally, the application 111 can be any one of a role-playing game (RPG), a multiplayer online battle arena game (MOBA), a battle royale shooting game, and a simulation game (SLG). The first terminal 110 is a terminal used by a first user 112. The first user 112 uses the first terminal 110 to control a virtual object A in a virtual scene to perform activities. The virtual object A can be referred to as the master virtual object of the first user 112. Illustratively, the virtual object A is a first virtual character, such as a simulated character or an anime character.

[0074] FIG1 shows only one terminal, but in different embodiments, multiple other terminals may be connected to the server 120. Optionally, one or more terminals may be developer terminals, on which a development and editing platform for an application supporting a virtual scene is installed. The developer may edit and update the application on the terminal and transmit the updated application installation package to the server 120 via a wired or wireless network. The first terminal 110 may download the application installation package from the server 120 to update the application.

[0075] The first terminal 110 and other terminals are connected to the server 120 via a wireless network or a wired network.

[0076] Server 120 includes at least one of a single server, a server cluster consisting of multiple servers, a cloud computing platform, and a virtualization center. Server 120 provides backend services for applications that support virtual scenarios. Optionally, server 120 performs primary computing tasks, while terminals perform secondary computing tasks; alternatively, server 120 performs secondary computing tasks, while terminals perform primary computing tasks; alternatively, server 120 and terminals utilize a distributed computing architecture for collaborative computing.

[0077] In an illustrative example, the server 120 includes a memory 121, a processor 122, a user account database 123, an interactive service module 124, and a user-facing input / output interface (I / O interface) 125. The processor 122 is configured to load instructions stored in the server 120 and process data in the user account database 123 and the interactive service module 124. The user account database 123 is configured to store user account data used by the first terminal 110 and other terminals, such as the user account's avatar, nickname, combat power index, and the service area where the user account is located. The interactive service module 124 is configured to provide a virtual scene for users to interact with other users' virtual objects, such as social interaction and battles. The user-facing I / O interface 125 is configured to establish communication and exchange data with the first terminal 110 via a wireless network or a wired network.

[0078] In related technologies, in applications that require resource loading, the resource path in the resource loading request needs to be manually configured by the developer. When the number of resources in the application is large (for example, in game applications, the number of resources is usually extremely large), it is easy for the configured resource path to have an incorrect format. For example, the developer may not be clear about the correspondence between the resource path and the resource type, or an erroneous operation may occur when configuring the resource path, etc., resulting in an incorrect format of the resource path.

[0079] In this regard, subsequent embodiments of the present application provide a solution for automatically correcting the resource path during the resource loading process to reduce the situation where resource loading errors are caused by incorrect resource path configuration.

[0080] Please refer to Figure 2, which shows a flow chart of a resource loading method provided by an embodiment of the present application. For ease of explanation, only the computer device that performs each step is introduced and described. The above-mentioned computer device can be the first terminal 110 or server 120 shown in Figure 1 above; the method can include the following steps:

[0081] Step 201: Receive a first resource loading request, where the first resource loading request is used to request asynchronous loading of a first resource; the first resource loading request indicates a resource path of the first resource.

[0082] The first resource can be non-executable data required by the application during operation. Alternatively, the resource can be any non-executable data logically deployed by the application. For example, a resource can be displayed as an error message in the application or as part of a user interface. Resources can contain data in various forms, including strings, images, and persistent objects.

[0083] Resources can be stored in resource files, allowing application developers to make changes to the resources used by an application without having to recompile the entire application.

[0084] Taking a game engine-based application (such as a game) as an example, the above resources may include virtual objects (Actors), blueprints, textures, maps, videos, audios, particles, materials, meshes, and the like.

[0085] The above-mentioned game engine can be used for program development in multiple fields such as game development, virtual reality (VR), and 3D mapping. Game engines include but are not limited to 3D game engines, 2D game engines, etc. The embodiment of this application does not limit the type of game engine.

[0086] In a possible implementation, the first resource loading request may directly include the resource path of the first resource.

[0087] Alternatively, the first resource loading request may also indirectly indicate the resource path of the first resource. For example, the first resource loading request may carry resource path indication information, and the computer device may query the pre-stored resource path corresponding to the resource path indication information based on the resource path indication information.

[0088] The resource path may include the storage locations of the corresponding resource at all levels. For example, the resource path may be a string consisting of the storage locations of the corresponding resource at all levels and a file name.

[0089] For example, if the resource path is "D: / xxGame / Actor / ziyuan.ziyuan1", it means that the corresponding resource is the resource file named "ziyuan1" in the "Actor" folder in the "xxGame" folder in the D drive, and the package name is "ziyuan1".

[0090] It should be noted that the above resource path is only illustrated using "D: / xxGame / Actor / ziyuan1" as an example. For different applications, the setting rules of their resource paths may be different. The embodiment of this application does not limit the setting rules of the resource path.

[0091] Step 202: Obtain the resource type of the first resource.

[0092] The resource types can be pre-set by the developer. For example, the resource types can include blueprint resources and non-blueprint resources. Alternatively, the resource types can be further divided, for example, non-blueprint resources can be further divided into particle resources, texture resources, material resources, etc.

[0093] Step 203: In response to the fact that the resource type of the first resource does not match the format of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

[0094] In an embodiment of the present application, when developing an application, developers can set the format of the resource path according to the relationship between the format of the resource path and the resource type agreed upon in advance, that is, different resource types can correspond to resource paths of different formats. After the computer device receives an asynchronous resource loading request, when it detects that the format of the resource path requested to be loaded does not match the resource type, it can modify the format of the resource path indicated by the request according to the format corresponding to the resource type of the resource. For example, when the computer device detects that the format of the resource path requested to be loaded does not match the resource type, it can modify the format of the resource path indicated by the request to the format corresponding to the resource type of the resource.

[0095] Step 204: Load the first resource in an asynchronous loading manner based on the corrected resource path of the first resource.

[0096] In an embodiment of the present application, after the computer device corrects the resource path of the first resource, it can perform asynchronous resource loading according to the corrected resource path of the first resource, for example, reading the corresponding first resource from the disk of the computer device and caching it in the memory.

[0097] In addition, if the resource type of the first resource matches the format of the resource path of the first resource, the computer device directly loads the first resource in an asynchronous loading manner based on the resource path of the first resource.

[0098] Among them, the various steps involved in the solution shown in the embodiment of the present application can be executed by the resource loading subsystem in the application.

[0099] In an embodiment of the present application, resources in an application program may be pre-configured according to resource type through offline pipeline collection.

[0100] For example, during the application development process, in the offline resource configuration stage, the resource configuration tool can be used to parse the application code in a pipeline manner and gradually configure various resources in the application.

[0101] Please refer to FIG3 , which shows a schematic diagram of a resource configuration tool configuring resources in a pipeline manner.

[0102] For example, taking the resource configuration of a game character's skills in a game application as an example, the resource configuration tool first analyzes the skills used by the game character. For each skill, the corresponding resources of the skill are analyzed, including the special effects, animations, etc. of the corresponding skill.

[0103] To sum up, the scheme shown in the embodiment of the present application, when receiving a request for asynchronously loading resources, first matches the resource path indicated by the request with the resource type. If the resource path indicated by the request does not match the resource type, it means that the resource path indicated by the request is incorrect. At this time, the resource path is automatically corrected according to the resource type, and then the resource is loaded according to the corrected resource path. Since the above scheme can automatically correct the resource path that may be erroneous according to the resource type, it can ensure the accuracy of loading resources through the resource path, reduce the situation of resource loading errors, and improve the accuracy of resource loading.

[0104] The solution shown in the above embodiment of the present application can be applied to any application that needs to asynchronously load resources. For example, please refer to Figure 4, which shows the implementation framework diagram of resource loading involved in this application.

[0105] As shown in Figure 4, at the software level, software applications such as a game engine-based application 41 are running in the operating system of the computer device; among them, the application 41 includes multiple subsystems that need to use resources, such as a UI interaction subsystem 41a and a task subsystem 41b, as well as a resource loading subsystem 41c for loading resources; each subsystem in the application 41 respectively encapsulates a part of the functional interface in the game engine.

[0106] At the hardware level, the computer device includes a memory 42 and a disk 43, wherein the disk 43 stores various resource files of the application 41. In addition, the computer device also includes necessary computer hardware such as a processor, a bus, and a power supply, which will not be described in detail here.

[0107] During the operation of the application 41, when the UI interaction subsystem 41a, task subsystem 41b and other subsystems need to asynchronously load one or some resources, they can send a first resource loading request to the resource loading subsystem 41c, which includes the resource path 44 of the first resource, to request the first resource to be loaded asynchronously; after receiving the first resource loading request, the resource loading subsystem 41c first determines whether the resource type of the first resource and the format of the resource path 44 match.

[0108] If the resource type of the first resource matches the format of the resource path 44 , the resource loading subsystem 41 c directly loads the first resource from the disk 43 to the memory 42 according to the resource path 44 , and then returns the loaded first resource to the subsystem that sent the first resource loading request 44 .

[0109] If the resource type of the first resource does not match the format of the resource path 44, the resource loading subsystem 41c first corrects the resource path 44 according to the resource type of the first resource, modifies the format of the resource path 44 to a format that matches the resource type of the first resource, and obtains the corrected resource path 45. Then, according to the resource path 45, the first resource is loaded from the disk 43 to the memory 42, and then the loaded first resource is returned to the subsystem that sent the first resource loading request 44.

[0110] Based on the embodiment shown in FIG2 , please refer to FIG5 , which shows a flow chart of a resource loading method provided by an embodiment of the present application. For ease of explanation, only the computer device is used as the subject of each step. As shown in FIG5 , step 203 in the embodiment shown in FIG2 above can be implemented as steps 203a and 203b:

[0111] Step 203a: Obtain the suffix of the resource path of the first resource.

[0112] In an embodiment of the present application, different types of resources can be distinguished by the suffix of the resource path. After receiving a request to asynchronously load a resource, the suffix of the resource path of the first resource to be loaded can be obtained first. For example, the last designated symbol (such as the "." symbol, the "_" symbol, etc.) in the resource path of the first resource and the characters after the last designated symbol are obtained as the suffix of the resource path of the first resource.

[0113] Step 203b: In response to the fact that the resource type of the first resource does not match the suffix of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

[0114] In an embodiment of the present application, after obtaining the suffix of the resource path of the first resource, it can be determined whether the suffix of the resource path of the first resource conforms to the format of the suffix corresponding to the resource type of the first resource. If so, no correction is required; otherwise, the suffix of the resource path of the first resource needs to be corrected according to the format of the suffix corresponding to the resource type of the first resource.

[0115] In an embodiment of the present application, if the resource type of the first resource does not match the suffix of the resource path of the first resource, the computer device may modify the suffix of the resource path of the first resource to a suffix that matches the resource type of the first resource.

[0116] The above solution stipulates different suffixes for the resource paths of different types of resources, and determines whether the resource path is accurate by checking the suffix. The process logic is concise and can ensure configuration efficiency during the development process and processing efficiency during the application process, thereby ensuring application development and execution efficiency.

[0117] In one possible implementation, in response to a mismatch between the resource type of the first resource and a suffix of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource includes:

[0118] In response to the resource type of the first resource being a blueprint type and the suffix of the resource path of the first resource not being a specified suffix, the specified suffix is ​​added to the resource path of the first resource to obtain a revised resource path of the first resource.

[0119] For example, taking an application based on the UE4 engine (a game engine) as an example, in the UE4 engine, the suffix of the blueprint type resource is pre-set to "_C". When the resource type of the first resource is obtained as a blueprint type, if the suffix of the resource path of the first resource is not "_C", it is considered that the resource path of the first resource needs to be corrected. At this time, the suffix "_C" is directly added to the resource path of the first resource.

[0120] In one possible implementation, in response to a mismatch between the resource type of the first resource and a suffix of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource includes:

[0121] In response to the resource type of the first resource being a non-blueprint type and the suffix of the resource path of the first resource being a specified suffix, the specified suffix on the resource path of the first resource is removed to obtain a revised resource path of the first resource.

[0122] For example, taking the application based on the UE4 engine as an example, in the UE4 engine, it is preset that non-blueprint resources do not have the suffix "_C". When the resource type of the first resource obtained is a non-blueprint type, if the suffix of the resource path of the first resource is "_C", it is considered that the resource path of the first resource needs to be corrected. At this time, the "_C" suffix of the resource path of the first resource can be directly removed.

[0123] The above scheme divides resources into two types of resources: blueprint type and non-blueprint type. The resource path can be corrected by adding or deleting suffixes. On the premise of improving the accuracy of resource loading, it can avoid the resource path checking and correction process occupying too much processing power and processing time of the computer equipment, thereby ensuring the execution efficiency of resource loading.

[0124] The embodiment of the present application only takes the suffix setting method of the blueprint / non-blueprint resources involved in the UE4 engine as an example. The embodiment of the present application does not limit the suffix setting method of the resource type.

[0125] The solution shown in the embodiment of the present application is explained by taking the classification of resources into blueprint resources and non-blueprint resources as an example. Optionally, the resources used by the application can also be classified according to other rules. The embodiment of the present application does not limit the way of dividing resources.

[0126] For example, the above application can classify resources into blueprint resources, material resources, mesh resources, etc., and set different suffixes for different resource types.

[0127] In addition, the solution shown in the embodiment of the present application uses suffixes to distinguish and check resource paths. Optionally, the computer device can also distinguish and check resource paths in other ways, such as setting different prefixes for different types of resources, or setting different fixed location fields, etc. The embodiment of the present application does not limit this.

[0128] Based on one or more of the embodiments shown in Figures 2 and 5, please refer to Figure 6, which shows a flow chart of a resource loading method provided by one embodiment of the present application. For ease of explanation, only the computer device is used as the subject of each step. As shown in Figure 6, step 202 in the embodiment shown in Figure 2 above can be implemented as step 202a:

[0129] Step 202a: Determine the resource type corresponding to the API that receives the first resource loading request as the resource type of the first resource.

[0130] In an embodiment of the present application, different application programming interfaces (APIs) can be set for resource loading requests of different resource types. When receiving the above-mentioned first resource loading request, the resource type of the first resource requested to be loaded can be determined through the API interface corresponding to the first resource loading request.

[0131] Among them, when developers develop applications, for asynchronous resource loading logic, they can configure different APIs for different types of resources in the resource loading subsystem. When the subsystem that uses resources in the application requests to load resources, it can call the API corresponding to the resource type to be loaded to send the above-mentioned first resource loading request to the resource loading subsystem. Correspondingly, the resource loading subsystem determines the corresponding resource type based on the API that receives the first resource loading request.

[0132] Through the above solution, the computer device can determine the resource type of the corresponding resource path through the interface receiving the request, without the need to configure other messages or fields to indicate the resource type corresponding to the above first resource loading request, which can improve the efficiency of obtaining resource types during the operation of the application.

[0133] The solution shown in the embodiment of the present application only uses the example of determining the resource type through an API to illustrate how a computer device obtains the resource type. Optionally, the computer device can also determine the resource type in other ways.

[0134] For example, the above-mentioned first resource loading request may carry a resource type indication field, which may indicate the resource type corresponding to the resource path indicated by the first resource loading request. When the computer device runs the above-mentioned application, the resource loading subsystem receives the above-mentioned first resource loading request, parses the resource type indication field in the first resource loading request, and determines the resource type of the first resource.

[0135] In the above solution, developers do not need to develop different APIs for the resource loading subsystem, which can improve the development efficiency of the application.

[0136] Based on the embodiments shown in one or more of Figures 2, 5, and 6, please refer to Figure 7, which shows a flow chart of a resource loading method provided by one embodiment of the present application. For ease of explanation, only the computer device that performs each step is introduced and described. As shown in Figure 7, the first resource loading request indicates the resource path of N resources, including the first resource; N is an integer greater than or equal to 2; before the above step 203, step 205 can also be included. Step 203 in the embodiment shown in Figure 2 above can also be implemented as step 203c:

[0137] Step 205: In response to N being greater than a first threshold, the resource paths of the N resources are divided into at least two resource path sets; the number of resource paths contained in each resource path set is not greater than the first threshold; the N resources are loaded in batches based on the resource path set.

[0138] In an embodiment of the present application, when a computer device processes a first resource loading request, if the first resource loading request indicates a large number of resources, that is, the number of resource paths indicated by the first resource loading request is greater than a first threshold, the computer device may divide all resource paths indicated by the first resource loading request into at least two batches for loading processing, so that the number of resources loaded in each batch remains below the first threshold.

[0139] For example, when a computer device is running an application, the resource loading subsystem processes a first resource loading request. If the number of resource paths of the N resources indicated by the first resource loading request is greater than a first threshold, then M resource paths are extracted from the resource paths of the N resources in order from first to last, where the value of M is a positive integer and the value of M is equal to the first threshold. The extracted M resource paths are divided into a first resource path set; then, if the number of remaining resource paths is greater than M, then M resource paths are extracted from the remaining resource paths in order from first to last, and the extracted M resource paths are divided into a second resource path set. If the number of remaining resource paths is not greater than M, all remaining resource paths are added to the second resource path set, and the above steps are repeated until all N resource paths are divided.

[0140] The above-mentioned batch loading refers to loading multiple batches of resources one after another. After the loading of one batch of resources is completed, the loading process of the next batch of resources is processed.

[0141] Step 203c: In response to the resource path set corresponding to the current processing batch including the first resource and the resource type of the first resource not matching the format of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

[0142] Among them, in the processing batch where the first resource is located, the computer device can execute a check and correction process for the resource path of the first resource to avoid the resource path check and correction process occupying too many resources and affecting the execution of other processes when too many resource paths are requested to be loaded at one time.

[0143] The resource path checking and correction process in step 203c may refer to steps 230a and 203b in the embodiment shown in FIG. 3 , and will not be described in detail here.

[0144] Based on one or more of the embodiments shown in Figures 2, 5, 6, and 7, please refer to Figure 8, which shows a flow chart of a resource loading method provided by one embodiment of the present application. For ease of explanation, only the computer device is used as the subject of each step. As shown in Figure 8, before the above step 203, step 206 may also be included. In the embodiment shown in Figure 2 above, step 203 may also be implemented as step 203d:

[0145] Step 206: In response to the number of asynchronous resource loading requests being processed reaching a second threshold, add the first resource loading request to a waiting queue.

[0146] In an embodiment of the present application, when the number of asynchronous resource loading requests to be processed is too large, in order to avoid occupying too much processing power by processing too many asynchronous resource loading requests at the same time, the computer device can first check the number of asynchronous resource loading requests currently being processed when receiving the first resource loading request. If the number of asynchronous resource loading requests currently being processed has reached the second threshold, the first resource loading request will not be processed temporarily, but the first resource loading request will be added to the waiting queue.

[0147] Step 203d: In response to the number of asynchronous resource loading requests being processed being less than the second threshold and the first resource loading request being at the top of the waiting queue, the first resource loading request is removed from the waiting queue, and in response to the format of the resource type of the first resource and the resource path of the first resource not matching, a step of correcting the resource path of the first resource based on the resource type of the first resource is performed.

[0148] When the number of asynchronous resource loading requests being processed subsequently is less than a second threshold, the computer device may extract a new resource loading request from the head of the waiting queue for resource loading processing.

[0149] Through the solution shown in the embodiment of the present application, the computer device can control the number of asynchronous resource loading requests processed simultaneously, avoid excessive processing power due to excessive asynchronous resource loading requests being processed simultaneously, and ensure the processing power of other processes in the application besides resource loading, thereby ensuring the running effect of the application, such as the occurrence of freezes during the running of the application.

[0150] The resource path checking and correction process in step 203d may refer to steps 230a and 203b in the embodiment shown in FIG. 3 , and will not be described in detail here.

[0151] In a possible implementation, adding the first resource loading request to a waiting queue includes:

[0152] Based on the priority of the first resource loading request and the priorities of the asynchronous resource loading requests already in the waiting queue, the first resource loading request is inserted into the waiting queue.

[0153] In the above solution, when adding the first resource loading request to the waiting queue, the first resource loading request can be inserted into the waiting queue according to the priority of the first resource loading request. The priority of the first resource loading request can be determined by factors such as the resource type requested by the first resource loading request, the importance of the resource, and the request time.

[0154] Among them, the above-mentioned inserting the first resource loading request into the waiting queue based on the priority of the first resource loading request and the priority of the asynchronous resource loading request already in the waiting queue may mean: when the priority of the asynchronous resource loading request already in the waiting queue is lower than the priority of the first resource loading request, the first resource is inserted before the asynchronous resource already in the waiting queue.

[0155] In the above solution, when the first resource loading request is added to the waiting queue, the arrangement order of the requests in the waiting queue can be determined, and the accuracy of the arrangement order of the requests in the waiting queue can be guaranteed at all times.

[0156] In another possible implementation, in response to the waiting queue containing at least two asynchronous resource loading requests and the waiting queue meeting a sorting condition, the asynchronous resource loading requests in the waiting queue are sorted based on respective priorities of the at least two asynchronous resource loading requests.

[0157] In the above scheme, after the first resource loading request is added to the waiting queue, the waiting queue containing at least two asynchronous resource loading requests can be sorted according to priority when the sorting conditions are met. This scheme does not require sorting every time a request is added, reducing the complexity of the processing process.

[0158] The sorting of the asynchronous resource loading requests in the waiting queue based on the respective priorities of at least two asynchronous resource loading requests may refer to sorting the asynchronous resource loading requests in the waiting queue in descending order of priority.

[0159] In one possible implementation, the sorting condition includes at least one of the following conditions:

[0160] The number of asynchronous resource loading requests being processed is less than the second threshold;

[0161] The time interval between the current moment and the first moment reaches the duration threshold; the first moment is the last time the asynchronous resource loading requests in the waiting queue were sorted;

[0162] Furthermore, after the first moment, the number of asynchronous resource loading requests newly added to the waiting queue is not less than a third threshold.

[0163] In an embodiment of the present application, the computer device can trigger the sorting of the waiting queue containing at least two asynchronous resource loading requests according to priority at certain time intervals, and / or at intervals according to the number of newly added asynchronous resource loading requests, and / or when a new asynchronous resource loading request needs to be started. There is no need to sort each time a request is added, thereby reducing the complexity of the processing process.

[0164] Based on one or more of the embodiments shown in Figures 2, 5 to 8, please refer to Figure 9, which shows a flow chart of a resource loading method provided by one embodiment of the present application. For ease of explanation, only the computer device is used as the subject of each step. As shown in Figure 9, after the above step 204, steps 207 to 209 may also be included:

[0165] Step 207: Receive a second resource loading request, where the second resource loading request is used to request synchronous loading of a second resource.

[0166] Among them, the solution shown in the embodiment of the present application not only supports asynchronous loading of resources, but also supports synchronous loading of resources. For example, the subsystem that uses resources in the application can send a second resource loading request to the resource loading subsystem to synchronously load the second resource, so as to obtain the required resources from the resource loading subsystem.

[0167] Step 208: Query the memory for the second resource; the memory stores the resource loaded through the asynchronous resource loading request.

[0168] In an embodiment of the present application, when performing synchronous resource loading, after receiving the second resource loading request, the resource loading subsystem can directly query the second resource from the memory.

[0169] Step 209: In response to not finding the second resource in the memory, stop the loading process of the second resource.

[0170] In an embodiment of the present application, during the synchronous loading process, after the computer device receives the synchronous loading request, it can directly query the corresponding resources in the memory. If the corresponding resources do not exist in the memory, the loading process will no longer be executed, thereby avoiding the synchronous loading process blocking the main process of the application.

[0171] In response to finding the second resource in the memory, the second resource is returned to the sender of the second resource request.

[0172] Through the above solution, if the computer device fails to find the second resource from the memory during the synchronous resource loading process, the process of loading the second resource from the disk into the memory can be stopped, thereby avoiding the process blocking the execution of the main process of the application and not triggering the Flush function, thereby reducing the lag of the application.

[0173] In response to not finding the second resource in the memory, a null value may be returned to the sender of the second resource request.

[0174] In another possible implementation, in response to not finding the second resource in memory, a third resource of the same resource subtype as the second resource may be returned to the sender of the second resource request. This third resource indicates that the second resource failed to load. The resource subtype is the most refined classification of resources within an application. In other words, the third resource is used to replace the second resource. The subsystem using the second resource can directly use the third resource to replace the second resource and perform subsequent processing steps.

[0175] For example, the above-mentioned third resource can be a visual resource (such as particle resources, material resources, image resources or animation resources) or an audio resource. The visual resource or audio resource can be directly used by the subsystem in the application that sends the second resource loading request according to the usage logic of the second resource. That is, the second resource originally required is replaced with a third resource of the same subtype. When the third resource is displayed or played in the interface of the application, it can be used to prompt the user that the second resource failed to load.

[0176] For example, when the second resource is a skill special effect, if the second resource does not exist in the memory, the resource loading subsystem can return a skill special effect resource to replace the second resource. The effect of the skill special effect resource when displayed is to prompt that the original skill special effect loading error occurred.

[0177] The above solution can be applied in the testing phase of an application. That is, when testers test an application, they can quickly determine problems or vulnerabilities in the application through the effects of resources displayed or played on the interface, making it easier for testers to quickly locate problematic code or resources and improve the testing efficiency of the application.

[0178] Taking the solution shown in the above embodiment of this application as an example, applied to a game application based on the UE4 engine, this solution uses the method of encapsulating and optimizing the native loading interface to improve the performance of resource loading and the fault tolerance of use. Resource preloading is mainly carried out by resource classification and offline resource collection. This can not only provide a better gaming experience, but also avoid the lag caused by resource configuration errors and improve development efficiency.

[0179] Please refer to Figure 10, which shows a schematic diagram of the read speed of storage modules at various levels in a computer system. As shown in Figure 10, in a computer system, the speed at which an application reads data from memory is much higher than the speed at which it reads data from disk. Therefore, during the running of an application, it is necessary to load resources from disk into memory first, and then retrieve the resources from memory for use, thereby improving resource utilization efficiency.

[0180] In this solution, the default synchronous loading interface is encapsulated. This synchronous loading interface only performs cache memory queries and does not trigger synchronous loading. This avoids triggering the Flush function during synchronous loading, causing lag and degrading the gaming experience.

[0181] Please refer to Figure 11, which shows a flowchart of the synchronous resource loading process involved in this application. As shown in Figure 11, the synchronous resource loading steps are as follows:

[0182] 1) Initiate a synchronous loading request and input the resource path to be loaded (step S1101).

[0183] 2) Perform FindObject processing (memory query) in the loading system to check whether the resource has been loaded into the memory (step S1102). If the memory query is successful, the resource object is directly returned (step S1103). If the memory query FindObject fails, a null value is returned (step S1104).

[0184] In this solution, the asynchronous resource loading interface is encapsulated. The resource path is checked before the asynchronous request to ensure the correctness of the common resource type and blueprint resource path. If the path is wrong, the resource path will be automatically repaired.

[0185] Please refer to Figure 12, which shows the asynchronous resource loading flow chart involved in this application. As shown in Figure 12, the asynchronous resource loading steps are as follows:

[0186] 1) Initiate an asynchronous resource loading request and input the resource path to be loaded (step S1201).

[0187] 2) Perform FindObject processing (memory query) in the loading system to check whether the resource has been loaded into the memory (step S1202). If the memory query is successful, the resource object is directly returned (step S1203). If the memory query fails, dynamically create a loading proxy object RequestData object, assign a unique request identifier (Identity, ID) to the RequestData object (step S1204), set the complete request path (step S1205), and determine whether the number of loading requests in the current loading queue exceeds the maximum allowed number (step S1206). If the maximum number of loading requests is exceeded, RequestData is added to the waiting queue (step S1207). If the maximum number of loading requests is not exceeded, start loading the current request (step S1208).

[0188] 3) When resource loading is completed, RequestData::Executed() is called back to notify the resource loading binding function (step S1209), completing the asynchronous resource loading.

[0189] When there are too many load requests at the same time, they will enter the waiting queue and process the load requests one by one according to their priority. Please refer to Figure 13, which shows the asynchronous waiting queue processing flow chart involved in this application. As shown in Figure 13, the asynchronous waiting queue processing steps are as follows:

[0190] Check the waiting loading queue in real time (step S1301), determine whether the number of waiting loading queues is greater than 1 (step S1302), if not, return to step S1301; if so, determine whether the current loading queue is less than the maximum number of simultaneous requests (step S1303), if not, return to S1301, if so, prioritize the waiting loading queues, and then sort by request time (step S1304); take out the highest priority waiting loading request, start the loading request (step S1305), update the waiting loading request queue, remove the already started loading, and complete the asynchronous waiting queue processing (step S1306).

[0191] In this solution, when a large number of resource paths are requested to be loaded, the resources will be loaded in batches according to the maximum number of resources loaded in a single batch until all resources are loaded and a loading completion notification is returned.

[0192] Please refer to Figure 14, which shows a flow chart of batch resource path processing involved in this application. As shown in Figure 14, the batch resource path processing steps are:

[0193] 1) Initiate an asynchronous resource loading request (step S1401) and obtain RequestData request data, which includes ReqID (request ID), LoadedSoftPaths (total loading path data set), Priority (loading priority default value is low priority), CompletedDel (loading completion callback), and FrameMaxLoadAssetPaths (the maximum number of loaded resources in a single wave default value is 100).

[0194] 2) Calculate the total number of loading waves that need to be processed for the current asynchronous loading request (step S1402), TotalLoadCount (total loading waves) = LoadedSoftPaths (total loading path data set) / FrameMaxLoadAssetPaths (maximum number of loaded resources in a single wave).

[0195] 3) If TotalLoadCount (total loaded waves) is greater than one, start the cyclic wave loading count (step S1403), wait for the current wave loading to be completed (step S1404), and add the resource collection loaded in the current wave to LoadedAssets, that is, the total loaded resource collection (step S1405), and increase the CurrentLoadCount (current wave) count by one.

[0196] 4) Determine whether CurrentLoadCount is equal to the total number of loaded waves (step S1406). If so, proceed to S1407. Otherwise, return to step S1403 until CurrentLoadCount (current wave) is equal to TotalLoadCount (total loaded waves).

[0197] Integrate all loaded resources LoadedAssets (a collection of total loaded resources), issue CompletedDel (loading completion callback), and complete the batch resource path loading process (step S1407).

[0198] The solution shown in the embodiment of the present application can be used for loading and preloading resources in an open large world based on game engines such as UE4. Among them, in large-world type games, resource loading is working all the time. As a high-frequency working system, it is particularly important to ensure the processor time consumption of a single frame and improve the usage tolerance. Through the solution provided by this application, other systems in the game do not need to worry about the high load caused by a large number of requests, nor do they need to worry about the path checking efficiency problems caused by a single large number of resource loading. At the same time, the encapsulated system will not call the LoadObject Flush central processing unit (CPU) to cause jamming, and will use cache query and preloading to optimize synchronous loading.

[0199] Specifically, the method provided in this application has the following effects:

[0200] 1) Developers no longer need to worry about efficiency issues brought by native interfaces. They can use the loading interface at any time, and performance optimization will be integrated into the packaged system.

[0201] 2) An offline classified resource collection strategy is adopted. Paths can be stored in a resource preload table using object IDs as keys. During runtime, references are added and deleted based on object IDs to achieve cache loading and clearing.

[0202] 3) Resource classification is performed during resource collection, which allows for more friendly statistics of resource usage for each module and system. Preloading also ensures a good and smooth gaming experience.

[0203] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0204] Please refer to Figure 15, which shows a block diagram of a resource loading device provided by an embodiment of the present application. The device may include:

[0205] The first request receiving module 1501 is configured to receive a first resource loading request, where the first resource loading request is used to request asynchronous loading of a first resource; the first resource loading request includes a resource path of the first resource;

[0206] A resource type acquisition module 1502 is configured to acquire the resource type of the first resource;

[0207] a path correction module 1503, configured to correct the resource path of the first resource based on the resource type of the first resource in response to a mismatch between the resource type of the first resource and the format of the resource path of the first resource;

[0208] The loading module 1504 is configured to load the first resource in an asynchronous loading manner based on the corrected resource path of the first resource.

[0209] In a possible implementation, the path correction module 1503 is configured to:

[0210] Obtain the suffix of the resource path of the first resource;

[0211] In response to the resource type of the first resource not matching the suffix of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

[0212] In one possible implementation, the path correction module 1503 is used to add the specified suffix to the resource path of the first resource in response to the resource type of the first resource being a blueprint type and the suffix of the resource path of the first resource being not a specified suffix, to obtain a corrected resource path of the first resource.

[0213] In one possible implementation, the path correction module 1503 is used to remove the specified suffix on the resource path of the first resource in response to the resource type of the first resource being a non-blueprint type and the suffix of the resource path of the first resource being a specified suffix, to obtain a corrected resource path of the first resource.

[0214] In a possible implementation, the resource type acquiring module 1502 is configured to determine the resource type corresponding to the application programming interface API receiving the first resource loading request as the resource type of the first resource.

[0215] In a possible implementation, the first resource loading request indicates resource paths of N resources, where the N resources include the first resource; N is an integer greater than or equal to 2;

[0216] The device further comprises:

[0217] a resource partitioning module, configured to, in response to N being greater than a first threshold, partition the resource paths of the N resources into at least two resource path sets; wherein the number of resource paths contained in each resource path set is no greater than the first threshold; and the N resources are loaded in batches using the resource path sets as units;

[0218] The path correction module 1503 is used to correct the resource path of the first resource based on the resource type of the first resource in response to the fact that the resource path set corresponding to the current processing batch includes the first resource and the resource type of the first resource does not match the format of the resource path of the first resource.

[0219] In a possible implementation, the apparatus further includes:

[0220] an adding module, configured to add the first resource loading request to a waiting queue in response to the number of asynchronous resource loading requests being processed reaching a second threshold;

[0221] The path correction module 1503 is used to remove the first resource loading request from the waiting queue in response to the number of asynchronous resource loading requests being processed being less than the second threshold and the first resource loading request being at the top of the waiting queue, and to execute the step of correcting the resource path of the first resource based on the resource type of the first resource in response to the mismatch between the resource type of the first resource and the format of the resource path of the first resource.

[0222] In a possible implementation, the adding module is configured to insert the first resource loading request into the waiting queue based on the priority of the first resource loading request and the priorities of the asynchronous resource loading requests already in the waiting queue.

[0223] In a possible implementation, the apparatus further includes:

[0224] The sorting module is used to sort the asynchronous resource loading requests in the waiting queue based on the respective priorities of the at least two asynchronous resource loading requests in response to the waiting queue containing at least two asynchronous resource loading requests and the waiting queue meeting the sorting condition.

[0225] In a possible implementation, the sorting condition includes at least one of the following conditions:

[0226] The number of asynchronous resource loading requests being processed is less than the second threshold;

[0227] The time interval between the current moment and the first moment reaches a time threshold; the first moment is the moment when the asynchronous resource loading requests in the waiting queue were last sorted;

[0228] Furthermore, after the first moment, the number of asynchronous resource loading requests newly added to the waiting queue is not less than a third threshold.

[0229] In a possible implementation, the apparatus further includes:

[0230] A second request receiving module, configured to receive a second resource loading request, where the second resource loading request is used to request synchronous loading of a second resource;

[0231] A query module, configured to query the second resource in a memory; the memory stores resources loaded via an asynchronous resource loading request;

[0232] The loading stopping module is configured to stop the loading process of the second resource in response to not finding the second resource in the memory.

[0233] To sum up, the solution shown in the embodiment of the present application, when receiving a request for asynchronously loading resources, first matches the resource path indicated by the request with the resource type. If the resource path indicated by the request does not match the resource type, it means that the resource path indicated by the request is incorrect. At this time, the resource path is automatically corrected according to the resource type, and then the resource is loaded according to the corrected resource path. This can reduce the possibility of resource loading errors and improve the accuracy of resource loading.

[0234] FIG16 illustrates a block diagram of a computer device 1600 according to an exemplary embodiment of the present application. Computer device 1600 may be a terminal device, such as a VR device, an AR device, a smartphone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), or an MP4 player (Moving Picture Experts Group Audio Layer IV). Computer device 1600 may also be referred to as a user device, a portable terminal, or other similar terminology.

[0235] Typically, the computer device 1600 includes a processor 1601 and a memory 1602 .

[0236] Memory 1602 may include one or more computer-readable storage media, which may be tangible and non-transitory. Memory 1602 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 1602 is used to store at least one instruction, which is executed by processor 1601 to implement the method provided in the embodiments of the present application.

[0237] In some embodiments, the computer device 1600 may further optionally include a peripheral device interface 1603 and at least one peripheral device. Specifically, the peripheral device includes at least one of a radio frequency circuit 1604 , a touch screen display 1605 , a camera 1606 , an audio circuit 1607 , and a power supply 1608 .

[0238] In some embodiments, the computer device 1600 further includes one or more sensors 1609 , including but not limited to an acceleration sensor 1610 , a gyroscope sensor 1611 , a pressure sensor 1612 , an optical sensor 1613 , and a proximity sensor 1614 .

[0239] Those skilled in the art will appreciate that the structure shown above does not limit the computer device 1600 , and the computer device 1600 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.

[0240] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the above-mentioned resource loading method is implemented.

[0241] In an exemplary embodiment, a computer program product or computer program is also provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described resource loading method.

[0242] It should be understood that the term "plurality" used herein refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates an "or" relationship between the associated objects.

[0243] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A resource loading method, the method being executed by a computer device, the method comprising: receiving a first resource loading request, where the first resource loading request is used to request asynchronous loading of a first resource; The first resource loading request indicates a resource path of the first resource; Obtaining the resource type of the first resource; In response to a mismatch between the resource type of the first resource and the format of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource; Based on the corrected resource path of the first resource, the first resource is loaded in an asynchronous loading manner.

2. The method according to claim 1, in response to the resource type of the first resource not matching the format of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource, comprises: Obtaining the suffix of the resource path of the first resource; In response to the resource type of the first resource not matching the suffix of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

3. The method according to claim 2, in response to the resource type of the first resource not matching the suffix of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource, comprises: In response to the resource type of the first resource being a blueprint type, and the suffix of the resource path of the first resource is not a specified suffix, the specified suffix is ​​added to the resource path of the first resource to obtain a revised resource path of the first resource.

4. The method according to claim 2, in response to the resource type of the first resource not matching the suffix of the resource path of the first resource, modifying the resource path of the first resource based on the resource type of the first resource, comprises: In response to the resource type of the first resource being a non-blueprint type and the suffix of the resource path of the first resource being a specified suffix, the specified suffix on the resource path of the first resource is removed to obtain a revised resource path of the first resource.

5. According to any one of claims 1 to 4, the step of obtaining the resource type of the first resource comprises: The resource type corresponding to the application programming interface API receiving the first resource loading request is determined as the resource type of the first resource.

6. The method according to any one of claims 1 to 5, wherein the first resource loading request indicates resource paths of N resources, wherein the N resources include the first resource; and N is an integer greater than or equal to 2; Before the resource path of the first resource is corrected based on the resource type of the first resource in response to the format of the resource type of the first resource not matching the format of the resource path of the first resource, the method further includes: In response to N being greater than a first threshold, dividing the resource paths of the N resources into at least two resource path sets; The number of resource paths included in each resource path set is not greater than the first threshold; the N resources are loaded in batches based on the resource path set; In response to the resource type of the first resource not matching the format of the resource path of the first resource, based on the resource type of the first resource, correcting the resource path of the first resource includes: In response to the resource path set corresponding to the current processing batch including the first resource, and the resource type of the first resource does not match the format of the resource path of the first resource, based on the resource type of the first resource, The resource path of the first resource is corrected.

7. The method according to any one of claims 1 to 6, wherein in response to the resource type of the first resource not matching the format of the resource path of the first resource, before correcting the resource path of the first resource based on the resource type of the first resource, the method further comprises: In response to the number of asynchronous resource loading requests being processed reaching a second threshold, adding the first resource loading request to a waiting queue; In response to the resource type of the first resource not matching the format of the resource path of the first resource, based on the resource type of the first resource, correcting the resource path of the first resource includes: In response to the number of asynchronous resource loading requests being processed being less than the second threshold and the first resource loading request being at the head of the waiting queue, the first resource loading request is removed from the waiting queue, and in response to the format of the resource type of the first resource not matching the format of the resource path of the first resource, a step of correcting the resource path of the first resource based on the resource type of the first resource is performed.

8. The method according to claim 7, wherein adding the first resource loading request to a waiting queue comprises: Based on the priority of the first resource loading request and the priorities of the asynchronous resource loading requests already in the waiting queue, the first resource loading request is inserted into the waiting queue.

9. The method according to claim 7, further comprising: In response to the waiting queue containing at least two asynchronous resource loading requests and the waiting queue meeting a sorting condition, the asynchronous resource loading requests in the waiting queue are sorted based on respective priorities of the at least two asynchronous resource loading requests.

10. The method according to claim 9, wherein the sorting condition comprises at least one of the following conditions: The number of asynchronous resource loading requests being processed is less than the second threshold; The time interval between the current moment and the first moment reaches a time threshold; the first moment is the last time the asynchronous resource loading requests in the waiting queue were sorted; And, after the first moment, the number of asynchronous resource loading requests newly added to the waiting queue is not less than a third threshold.

11. The method according to any one of claims 1 to 10, further comprising: receiving a second resource loading request, where the second resource loading request is used to request synchronous loading of a second resource; Querying the second resource in memory; The memory stores resources loaded through asynchronous resource loading requests; In response to not finding the second resource in the memory, stopping the loading process of the second resource.

12. A resource loading device, comprising: A first request receiving module, configured to receive a first resource loading request, wherein the first resource loading request is used to request asynchronous loading of a first resource; The first resource loading request includes a resource path of the first resource; A resource type acquisition module, used to acquire the resource type of the first resource; a path correction module, configured to correct the resource path of the first resource based on the resource type of the first resource in response to a mismatch between the resource type of the first resource and the format of the resource path of the first resource; A loading module is used to load the first resource in an asynchronous loading manner based on the corrected resource path of the first resource.

13. The device according to claim 12, wherein the path correction module is used to: Obtaining the suffix of the resource path of the first resource; In response to the resource type of the first resource not matching the suffix of the resource path of the first resource, the resource path of the first resource is modified based on the resource type of the first resource.

14. According to the device according to claim 13, the path correction module is used to add the specified suffix to the resource path of the first resource in response to the resource type of the first resource being a blueprint type and the suffix of the resource path of the first resource is not a specified suffix, so as to obtain a corrected resource path of the first resource.

15. According to the device according to claim 13, the path correction module is used to remove the specified suffix on the resource path of the first resource in response to the resource type of the first resource being a non-blueprint type and the suffix of the resource path of the first resource being a specified suffix, so as to obtain the corrected resource path of the first resource.

16. The device according to any one of claims 12 to 15, wherein the resource type acquisition module is used to determine the resource type corresponding to the application programming interface API receiving the first resource loading request as the resource type of the first resource.

17. The device according to any one of claims 12 to 16, wherein the first resource loading request indicates resource paths of N resources, the N resources include the first resource; N is an integer greater than or equal to 2; The device also includes: a resource partitioning module, configured to partition resource paths of the N resources into at least two resource path sets in response to N being greater than a first threshold; The number of resource paths included in each resource path set is not greater than the first threshold; the N resources are loaded in batches based on the resource path set; The path correction module is used to correct the resource path of the first resource based on the resource type of the first resource in response to the resource path set corresponding to the current processing batch containing the first resource and the resource type of the first resource not matching the format of the resource path of the first resource.

18. A computer device, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the resource loading method according to any one of claims 1 to 11.

19. A computer-readable storage medium, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the resource loading method according to any one of claims 1 to 11.

20. A computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium; the computer program is read and executed by a processor of a computer device to implement the resource loading method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • An H5 multi-terminal access method based on a mixed mode mobile application

    CN109683990A

  • Multi-outlet routing selection method

    CN110138660A

  • Game engine resource processing method, electronic equipment and computer readable storage medium

    CN111569431A

  • Picture processing method and device, electronic equipment and storage medium

    CN112169326A

  • URL error-correcting method, server, terminal and system

    US20160364495A1

Cited By

  • Page picture resource progressive loading method, device and system and storage medium

    CN119669595A