A mobile advertising SDK communication link exception diagnosis method
By establishing communication execution instances and recording execution events in the mobile advertising SDK communication link, the problem of inaccurate anomaly location in existing technologies is solved, enabling precise location and providing a data foundation, thereby improving diagnostic efficiency and accuracy.
Patent Information
- Application Number
- CN202611697102.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing methods for diagnosing communication link anomalies in mobile advertising SDKs cannot accurately determine whether an anomaly occurred during request generation, communication transmission, response processing, or callback execution, resulting in low efficiency and insufficient accuracy in fault location.
By establishing a communication execution instance when the mobile advertising SDK loads the interface, the instance identifier runs through the request object, network task and callback receiver object, records the actual execution events, and associates the execution events according to the instance identifier and event sequence, verifies the execution positions of adjacent programs, and determines the fault range and abnormal location.
It enables precise location of anomalies in the mobile advertising SDK communication link, reduces the bias of manual troubleshooting, and provides a clear data foundation for reproducing and locating software malfunctions.
Smart Images

Figure CN123178245A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer program execution fault diagnosis technology, specifically a method for diagnosing communication link anomalies in a mobile advertising software development kit (SDK). Background Technology
[0002] Advertising SDKs in existing mobile applications typically perform functions such as ad loading and display by sending requests to the advertising server and receiving returned data. In actual operation, the advertising SDK needs to go through multiple consecutive execution phases, including initialization, request construction, communication sending, response receiving, data parsing, and display callback. Existing anomaly detection methods usually judge the communication status based on whether the request returned successfully, the interface error code, or the final ad display result. This only identifies an overall result anomaly and cannot establish a correlation between the SDK's internal execution phases and communication events.
[0003] When an ad fails to load, a request times out, or an abnormal display occurs, existing technologies struggle to accurately determine whether the anomaly occurred during request generation, communication transmission, response processing, or callback execution. This results in mobile ad SDK communication link fault location primarily relying on manual review of runtime logs, leading to low anomaly location efficiency and insufficient diagnostic accuracy. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention provides a method for diagnosing communication link anomalies in mobile advertising SDKs, thereby resolving the problems mentioned in the background section.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for diagnosing communication link anomalies in a mobile advertising SDK, comprising the following steps: S1. When the host application enters the mobile advertising SDK loading interface, a communication execution instance corresponding to this interface call is established, the instance identifier is written into the SDK request context, and the correspondence between each object and the instance identifier is established when the request object is formed, the network task is established, and the callback receiving object is established respectively. S2. Record the actual execution events at the program execution locations corresponding to the SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry, and associate the actual execution events corresponding to the same communication execution instance according to the instance identifier and the order of event occurrence. S3. Verify the actual execution events corresponding to adjacent program execution positions in the same communication execution instance sequentially; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position has an actual execution event formed by using the output of the previous level program as input, register the current missing event as a missing event and continue to verify the subsequent program execution position; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position does not have an actual execution event that can prove that the output of the previous level program has been actually used, under the condition that the key object correspondence can be verified, take the previously verified program execution position as the starting point for fault verification; if the key object correspondence cannot be verified, register the current communication execution instance as incomplete diagnostic evidence; S4. Read the program exception events, network task end events, cancellation events, and process lifecycle events associated with the current communication execution instance from the fault verification starting point to the immediately following program execution position. Verify whether the immediately following program execution position has been reached based on the boundary confirmation conditions corresponding to the current SDK version. If it is confirmed that the position has not been reached, determine the fault interval based on the fault verification starting point and the immediately following program execution position. When the first actual event that terminates the current execution segment and its occurrence position can be identified, register the occurrence position as the first exception position. S5. Extract the actual execution events that have been formed from the time the current communication execution instance enters the SDK loading interface to the time the fault range is determined. Maintain the correspondence between the instance identifier and the local identifier of the request object, the network task identifier and the local identifier of the callback object that have been formed. Then, associate the fault range determined in S4 with the aforementioned actual execution events and write them into the non-volatile storage area.
[0006] Furthermore, in S1: After the application process starts, it reads and updates the process startup sequence number. When the SDK loading interface is entered, it reads the SDK package identifier, SDK version identifier, and the current instance increment sequence number in the process, and forms the instance identifier based on the process startup sequence number, SDK package identifier, SDK version identifier, and instance increment sequence number. After a request object is created, a mapping relationship is established between the local identifier and the instance identifier of the request object. After a network task is created, a mapping relationship is established between the network task identifier, the local identifier of the request object, and the instance identifier. After a callback receiver object is created, a mapping relationship is established between the local identifier and the instance identifier of the callback object.
[0007] Furthermore, in S2: Read the SDK version identifier and the diagnostic boundary configuration corresponding to the SDK version identifier, and determine the program execution location corresponding to the SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry based on the diagnostic boundary configuration; When the current SDK version identifier matches the SDK version identifier in the diagnostic boundary configuration, the corresponding actual execution event is recorded at each program execution location.
[0008] Furthermore, S2 also includes: When each actual execution event is written, the instance identifier is checked. For events related to the request object, the local identifier of the request object is checked at the same time. For events related to the network task, the network task identifier is checked at the same time. For events related to the callback, the local identifier of the callback object is checked at the same time. The actual execution events that have been verified are assigned event numbers according to the actual writing order in the current communication execution instance, and are written together with the corresponding monotonic running time into the local loop diagnostic area.
[0009] Furthermore, in S3: When the actual execution event corresponding to the current program execution position is missing, read the actual execution event of the next program execution position and verify the correspondence between the previous level program output used by the next actual execution event and the current communication execution instance; The request object phase checks against the local identifier of the request object, the network task phase checks against the network task identifier, and the callback phase checks against the local identifier of the callback object. When the correspondence is consistent with the current communication execution instance, the current missing event is registered as a missing data collection event.
[0010] Furthermore, S3 also includes: When the same communication execution instance is missing two consecutive actual execution events at two adjacent program execution positions, under the condition that the first actual execution event after the two adjacent program execution positions can be checked step by step along the corresponding object identifier to the current communication execution instance, the missing events corresponding to the two adjacent program execution positions are registered as missing events in sequence. If step-by-step verification cannot be completed, the verification process will stop and the last program execution location that has been verified will be used as the starting point for fault verification. If the correspondence between key objects cannot be verified, the current communication execution instance will be registered as having incomplete diagnostic evidence.
[0011] Furthermore, in S4: Program exception events are associated with the current communication execution instance based on the instance identifier and the location identifier of the exception occurrence; network task completion events are associated with the current communication execution instance based on the instance identifier and the network task identifier; cancellation events are associated with the current communication execution instance based on the instance identifier and the location of the cancellation occurrence; and process lifecycle events are associated with the application process in which the current communication execution instance resides based on the process startup sequence number. According to the monotonic operation time, verify the actual occurrence order of the aforementioned events, and verify the actual relationship between each event and the execution segment from the fault verification start point to the immediately following program execution position; if the first actual event that terminates the execution segment can be determined, and the occurrence position of the event can be verified, the corresponding occurrence position is registered as the first abnormal position; if the first actual interruption event and its occurrence position cannot be determined, retain the determined fault interval and the actual events that have been obtained, and do not register the first abnormal position.
[0012] Furthermore, in S5: Extract the actual execution events that have been formed in the current communication execution instance, the missing collection information registered by S3, and the fault verification starting point and fault range determined by S4; when S4 has determined the first abnormal position, extract the first abnormal position at the same time, and maintain the established correspondence between the instance identifier, the local identifier of the request object, the network task identifier, and the local identifier of the callback object; Event fields that have not actually been formed remain missing. After the fault diagnosis data is written and the write success result is obtained in the non-volatile storage area, the solidification completion flag is written, and then the temporary object association information corresponding to the current communication execution instance is released.
[0013] Furthermore, when a network task retry occurs in the same communication execution instance, an independent network task identifier is created for each actual network task, and the correspondence between each network task identifier and the same instance identifier is maintained. The network task completion event that has been generated in the previous network task is retained. The subsequent network task continues to execute the adjacent program execution location verification and fault range determination based on the corresponding actual execution event. The fault diagnosis data of the previous network task that has been solidified is not overwritten by the subsequent network task and subsequent communication execution instances.
[0014] Compared with existing technologies, this invention provides a method for diagnosing communication link anomalies in mobile advertising SDKs, which has the following beneficial effects: 1. A communication execution instance is established based on a single mobile advertising SDK loading interface call. Instance identification is integrated across the request object, network task, and callback receiving object. Actual execution events are recorded at the corresponding locations: SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry. To address missing events at program execution locations, the presence of actual execution events generated by the previous level's program output at subsequent program execution locations distinguishes between missing data and actual execution interruptions. This is further combined with program exception events, network task completion events, cancellation events, and process lifecycle events to determine the fault range. This allows ad loading failures to move beyond a general judgment at the final result level, focusing on the program execution range corresponding to request formation, network task execution, response processing, and callback handover, reducing the bias in anomaly location judgment caused by manually checking each log item.
[0015] 2. Maintain the correspondence between the request object, network task, and callback object and the communication execution instance. When the same SDK has concurrent loading, cross-thread execution, and network task retries, each actual execution event can still maintain continuity according to the instance affiliation. After the fault range is determined, the actual execution events that have been formed, the missing information collected, and the abnormal location are associated and written to the non-volatile storage area. Information that has not been actually obtained remains missing. Subsequent communication execution instances do not overwrite the solidified fault diagnosis data, thereby preserving the real program execution evidence when an SDK communication anomaly occurs, providing a clear data foundation for subsequent reproduction and location of similar software operation faults. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the process for diagnosing communication link anomalies in a mobile advertising SDK according to the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Example: Figure 1 A method for diagnosing communication link anomalies in mobile advertising SDKs is presented, including the following steps: S1. When the host application enters the mobile advertising SDK loading interface, a communication execution instance corresponding to this interface call is established, the instance identifier is written into the SDK request context, and the correspondence between each object and the instance identifier is established when the request object is formed, the network task is established, and the callback receiving object is established respectively. S2. Record the actual execution events at the program execution locations corresponding to the SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry, and associate the actual execution events corresponding to the same communication execution instance according to the instance identifier and the order of event occurrence. S3. Verify the actual execution events corresponding to adjacent program execution positions in the same communication execution instance sequentially; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position has an actual execution event formed by using the output of the previous level program as input, register the current missing event as a missing event and continue to verify the subsequent program execution position; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position does not have an actual execution event that can prove that the output of the previous level program has been actually used, under the condition that the key object correspondence can be verified, take the previously verified program execution position as the starting point for fault verification; if the key object correspondence cannot be verified, register the current communication execution instance as incomplete diagnostic evidence; S4. Read the program exception events, network task end events, cancellation events, and process lifecycle events associated with the current communication execution instance from the fault verification starting point to the immediately following program execution position. Verify whether the immediately following program execution position has been reached based on the boundary confirmation conditions corresponding to the current SDK version. If it is confirmed that the position has not been reached, determine the fault interval based on the fault verification starting point and the immediately following program execution position. When the first actual event that terminates the current execution segment and its occurrence position can be identified, register the occurrence position as the first exception position. S5. Extract the actual execution events that have been formed from the time the current communication execution instance enters the SDK loading interface to the time the fault range is determined. Maintain the correspondence between the instance identifier and the local identifier of the request object, the network task identifier and the local identifier of the callback object that have been formed. Then, associate the fault range determined in S4 with the aforementioned actual execution events and write them into the non-volatile storage area.
[0019] S1 specifically refers to: When the host application actually enters the loading interface of the mobile advertising SDK, this loading interface call is taken as the starting position of a communication execution instance. After the application process starts, it reads the process startup sequence number saved by the previous application process from the local persistent area of the host application, increments this sequence number once when the current application process is created, and writes it back to the local persistent area. The incremented sequence number is used as the process startup sequence number of the current application process.
[0020] When running for the first time and the process startup sequence number does not exist in the local persistent memory, a process startup sequence number corresponding to the current application process is established with a preset initial value. The process startup sequence number is only updated when the application process is re-established and remains unchanged during the lifetime of the same application process.
[0021] Once the mobile advertising SDK loading interface is accessed, it reads the SDK package identifier and SDK version identifier actually installed in the host application, and reads the instance incrementing sequence number maintained within the current process. The SDK package identifier uses the identifier of the SDK component actually integrated when the host application is built, and the SDK version identifier uses the version information carried by the currently installed SDK package, and is not based on the ad slot name, ad type, or network target address.
[0022] The instance increment sequence number is restored to its initial count position when the current application process starts. Each new SDK loading interface call generates a new unused sequence number. An instance increment sequence number corresponds to only one loading interface call within the current application process and is not reassigned during the process's lifetime. The preset initial value of the process startup sequence number and the initial count position of the instance increment sequence number are fixed by the diagnostic configuration of the current SDK version and remain consistent throughout the operation of the same SDK version. The process startup sequence number, SDK package identifier, SDK version identifier, and instance increment sequence number together form the instance identifier of the current communication execution instance.
[0023] Once the instance identifier is generated, it is immediately written into the SDK request context established for this loading interface. The request context corresponds to the local runtime data used by the current communication execution instance during its internal SDK flow, and is not written into the request body sent to the advertising server.
[0024] The request context is established when the self-loading interface is entered. It ends when the current instance completes the host callback and there are no pending verification exceptions. When the current instance cancels and enters fault verification, the already formed instance association information is retained until the fault diagnosis data is solidified. When the application process actually ends, the diagnostic data that has been successfully saved before the end shall prevail.
[0025] If the host callback has already been entered but the host application continues to perform ad display and business processing, the diagnostic lifecycle of the current communication execution instance will not be extended to avoid subsequent ad business behaviors re-entering the current SDK communication link diagnostic process.
[0026] When the SDK internally creates a request object based on this loading call, it creates a local identifier for the request object after the request object is constructed and meets the conditions for submission to the network client. The local identifier of the request object is generated by the order in which the request objects are formed within the current communication execution instance and is stored together with the instance identifier. This allows the same instance to distinguish different request objects when a request is rebuilt, and also avoids the problem of reusing the identifier after the object is released when the runtime memory address is used as a long-term identifier.
[0027] When a communication execution instance forms only one request object, the request objects are formed in the order of the first request object in that instance. When a request object is reconstructed internally by the SDK, the new request object obtains a new local identifier, while the original request object identifier is retained until the current instance ends. After the request object is formed, a correspondence between the instance identifier and the request object's local identifier is written to the local diagnostic association area. This correspondence is not established while the request object is still in the field assembly process, and the non-existent request object local identifier is not written if the construction process is interrupted due to a program exception.
[0028] After a request object enters the network client, the network task mapping is established only when the network client actually creates an executable network task. If the network client can provide its own network task identifier, it directly reads that identifier. If the network client does not provide an independent task number, a local network task identifier is created at the location where the network task object is created, according to the order in which network tasks are formed within the current instance, and the actual lifecycle of the network task object serves as the identifier's validity period. Subsequently, the instance identifier, the request object's local identifier, and the network task identifier are jointly written into the task association entry. The task association entry only reflects the ownership relationship between actually created program objects and does not infer the mapping relationship between the request object and the network task based on the request occurrence time, target host address, ad slot parameters, or thread identifier.
[0029] When the SDK internally retryes network tasks, each newly created network task obtains an independent network task identifier. Each network task continues to be associated with the same instance identifier and is also associated with the local identifier of the request object it actually uses. The associated information of a previous network task is not immediately deleted after it ends. The network task identifier and the fact that the task has ended are retained until the current communication execution instance completes fault verification. Only when the current instance completes the host callback and there are no pending verification exceptions are the associated items of the completed temporary task released.
[0030] When the SDK creates a result callback object for the current communication execution instance, it reads the instance identifier from the request context and creates a local identifier for the callback object for this result callback. The local identifier of the callback object is formed according to the actual creation order of callback objects within the current communication execution instance, and is used to distinguish different callback objects generated due to retries, failure handling, and execution thread switching. The instance identifier and the local identifier of the callback object are jointly written into the local association information of the callback receiving object.
[0031] When the SDK prepares to deliver the result to the host application, the callback receiving object that actually participated in this callback carries the instance identifier into the subsequent execution process. When the host application actually enters the callback entry point corresponding to the callback receiving object, it still reads the same instance identifier and the callback object's local identifier. If the callback object has not actually been created, the callback object's local identifier is not pre-generated. If an exception occurs before the SDK enters the callback object creation location, subsequent diagnosis continues to use the request object and network task association information already formed by the current instance.
[0032] When the mobile advertising SDK switches between the main thread, worker thread, network execution thread, and callback execution thread during operation, it does not use thread identifiers to re-establish communication execution instances, nor does it change the instance identifiers already formed according to thread changes. Thread identifiers are only saved as auxiliary information about the location of subsequent actual execution events.
[0033] Instance attribution is always verified based on the instance identifier stored in the request context, the instance identifier stored in the task association item, and the instance identifier stored in the callback receiver object. When the same thread processes two communication execution instances sequentially, the two instances remain separate based on their respective instance identifiers; when the same communication execution instance passes through multiple execution threads, each stage is still attributed to the same instance.
[0034] When a host application integrates multiple mobile advertising SDKs, each SDK reads its own actual SDK package identifier and SDK version identifier. The instance identifiers of different SDKs are formed by the information of their respective SDK components. When the same SDK makes multiple loading interface calls simultaneously, each call obtains a different incrementing instance sequence number.
[0035] When a network client fails to actually establish a network task, no network task identifier is generated, no task association item is created, and existing instance identifiers and request object local identifiers are retained. If the request object is not fully constructed, no request object local identifier is generated; if the callback object is not actually established, no callback object local identifier is generated.
[0036] When the current application process terminates abnormally before the communication execution instance is completed, the process startup sequence number corresponding to this process will no longer be used for the new process. The new process will obtain a new process startup sequence number. Therefore, the communication execution instance left before the process exits will not overlap with the communication execution instance generated after restarting.
[0037] After the current communication execution instance enters the host callback entry and completes the current communication diagnostic process, it releases the temporary instance association information in the request context. Instances that have entered fault verification retain the association items of the corresponding request object, network task, and callback object until the fault diagnosis data is solidified. After the task association items and callback association items are released, they will no longer be used for new communication execution instances. Even if the runtime environment subsequently reuses the same program object storage location, a new correspondence will be established according to the new instance identifier and the new object local identifier.
[0038] When S2 generates an actual execution event at each fixed program execution location, it reads the instance identifier and corresponding object identifier that S1 has already established, and checks them against the corresponding items of the request object, the task association items, and the association information in the callback receiving object. It does not re-determine the ownership of the communication execution instance based on the thread identifier, the event occurrence time, and the advertising business information.
[0039] S2 specifically refers to: After establishing a communication execution instance in S1 and associating the instance identifier with the request context, seven fixed program execution positions are set according to the actual program execution order of the current communication execution instance in the mobile advertising SDK. These positions are, in order: SDK loading interface entry position, request object formation position, network task establishment position, network result return position, response processing completion position, callback issuance position, and host callback entry point.
[0040] The seven program execution locations correspond to six adjacent execution segments, which are as follows: from SDK loading interface entry to request object formation, from request object formation to network task establishment, from network task establishment to network result return, from network result return to response processing completion, from response processing completion to callback issuance, and from callback issuance to host callback entry.
[0041] The seven program execution locations are used to mark the actual program boundaries of a single communication execution instance of the mobile advertising SDK, from entering through the local interface, executing the network task, to returning the result to the host application. The number of locations does not change based on whether the advertisement is successfully displayed, the advertisement fill status, or the advertisement business results.
[0042] When the SDK version used to implement this method is released, a diagnostic boundary configuration corresponding to the current SDK version is established. The diagnostic boundary configuration stores the SDK version identifier, boundary identifiers corresponding to seven program execution locations, and the event types allowed to be written to each boundary. The boundary identifiers correspond to fixed execution entry points or fixed execution exit points in the actual SDK code, and remain unchanged during the production run of the same SDK version.
[0043] After the application process enters S2, it first reads the SDK version identifier obtained in S1 and performs a consistency check with the SDK version identifier saved in the current diagnostic boundary configuration. If they match, it obtains seven program execution locations according to the current diagnostic boundary configuration; if they do not match, it does not use the old version's internal boundaries to continue forming fault location judgments, writes a diagnostic boundary configuration mismatch flag to the current communication execution instance, and retains actual events that can be directly obtained from the SDK loading interface and host callback entry point to avoid incorrect stage attribution caused by using the old program locations after SDK code changes. After the new SDK version completes program boundary verification, it uses the new diagnostic boundary configuration corresponding to that version.
[0044] After the host application actually enters the mobile advertising SDK loading interface, it writes an interface entry event at a point within the loading interface before the construction of the current request object begins. The interface entry event reads the instance identifier from the request context established by S1, as well as the SDK package identifier, SDK version identifier, current loading interface identifier, event occurrence time, and current execution thread identifier.
[0045] The current loading interface identifier is taken from the loading interface actually called by the SDK and is not renamed according to the advertising business name. The monotonic runtime clock provided by the mobile terminal operating system is read at the time the event occurs. The monotonic runtime clock is used to determine the sequence of events within the current application process and is not affected by user modifications to the system date, system time, or system time zone. The execution thread identifier is only used to check the actual execution environment after a failure occurs and does not participate in determining the ownership of the communication execution instance.
[0046] After the SDK completes the construction of the request object, it sets the request object formation position before the request object enters the network client submission entry. A request object formation event is only written at this position when the request object has been formed into an actual request object that the network client can receive. No request object formation event is written if the request object is still in the field assembly process or if the request construction has stopped due to a program exception. The request object formation event obtains the instance identifier and local identifier of the request object from the corresponding item in S1, and reads the target network host identifier, request method, and actual length of the request data from the actual request object.
[0047] The target network host identifier is taken from the target host portion of the current request address, and the business query content from the complete ad request address is not stored. The request method is directly read from the network request method already set in the current request object. When actual data is being sent, the actual length of the request data is the length of the data to be sent that was formed before submission to the network client; when the current request does not carry a request body, the actual length of the request data is registered as zero. The ad request body, the original value of the user identifier, ad creative data, and ad delivery parameters are not included in diagnostic events.
[0048] After a request object enters the network client, the network task creation location is reached only if the network client has already created a real network task corresponding to the request object. If the network client provides its own network task identifier, that network task identifier is read; if the network client does not provide an independent task number, the local network task identifier formed by S1 at the network task object creation location is read.
[0049] The network task creation event is written with the instance identifier, request object local identifier, network task identifier, network client type, and network task creation time, and the correspondence between the instance identifier, request object local identifier, and network task identifier and the task association item in S1 is verified. If the network client has not yet created an actual network task, a network task creation event is not generated in advance. If a program exception occurs during the network task creation process even though the request object has been created, the request object creation event is retained, and a separate program exception event is generated at the location of the program exception for further verification by S3 and S4.
[0050] After a network task enters the actual communication execution phase, the end callback generated by the network client for that network task serves as the exit point for the network execution phase. When the network client receives a normal response from the server and actually delivers the response data to the SDK, it reaches the network result return position and writes a network result return event. The network result return event stores the instance identifier, network task identifier, actual response status, actual response data length, and the network result return time.
[0051] The actual length of the response data is taken from the length of the data already delivered to the SDK by the network client, not the length of the object after SDK parsing. When the network client fails to receive a normal response and terminates the current network task due to actual technical results such as domain name resolution failure, connection establishment failure, connection interruption, read / write timeout, or network task cancellation, no network result return event is written. Instead, a network task termination event is written at the actual end position of the network task, saving the instance identifier, network task identifier, task termination type given by the network client, and termination time. The network task termination type is directly derived from the actual termination result generated by the current network client and is not re-inferred based on subsequent advertisement display results. This network task termination event is used by S4 as evidence of abnormal execution.
[0052] After the network result is returned, the SDK begins processing the response data. Following the existing response processing flow in the current version, the SDK reads the data returned by the network client, completes the reading of protocol fields, constructs the response object, and generates the local result object required for subsequent callbacks.
[0053] When the SDK has generated an actual response object that can enter the current result callback process, it reaches the response processing completion position and writes a response processing completion event. The response processing completion event saves the instance identifier, network task identifier, and response processing completion time, and maintains the correspondence between the current response object and the network task to which the actual returned data belongs.
[0054] When the server returns an empty ad result conforming to the SDK's defined data format, as long as the SDK has completed normal data processing and formed the corresponding result object, a response processing completion event is still written; the empty ad content is not considered a response processing failure. If a program exception occurs during response data processing, causing the current processing flow to not reach the response processing completion position, a response processing completion event is not written. Instead, a program exception event is generated at the actual exception capture position, saving the current instance identifier, network task identifier, exception occurrence location identifier, exception type, and occurrence time.
[0055] When the SDK completes response processing and is ready to pass the current result to the host application, it sets the callback emission position before calling the result callback entry point registered by the host application. After the program actually reaches this position, it reads the instance identifier and callback object local identifier from the callback receiver object established in S1 and writes them to the callback emission event.
[0056] The formation of a callback emission event indicates that the SDK has reached the program boundary where it delivers the result to the host application, and is not contingent on whether the host application has already processed the result. If a program exception occurs after the response processing is completed but before the actual callback emission point is reached, the SDK only retains the already formed response processing completion event and the corresponding program exception event, and does not generate a callback emission event in advance.
[0057] After the host application actually enters the callback acceptor object established by S1, it reaches the host callback entry point and writes the host callback entry point event. The host callback entry point event reads the instance identifier and callback object local identifier already saved in the callback acceptor object, and writes the entry time and the actual execution thread identifier.
[0058] When a callback event has been generated but the host callback entry event has not yet been generated, the host callback entry event is not directly written based on the time interval between the two. Instead, the current actual execution state is maintained, and S3 continues to determine whether the next program execution position has actually been generated.
[0059] When the seven main types of events are written to the local circular diagnostic area, the instance identifier carried by the current event is checked before each write. Request object-related events are further checked against the local identifier of the request object, network task-related events are further checked against the network task identifier, and callback-related events are further checked against the local identifier of the callback object.
[0060] When the correspondence matches the request object, task association, and callback receiving object already established in S1, the current event enters the event sequence of the communication execution instance; when the correspondence does not match the current instance, the event is not merged into the current instance, and the association verification failure flag is retained in the context of the current instance for subsequent fault diagnosis to distinguish between object association abnormalities and program execution interruption.
[0061] For each successful write of an actual execution event within the same communication execution instance, the current event sequence number of that instance is read, and the next event sequence number is obtained. The obtained event sequence number is then written together with the current event sequence number into the circular diagnostic area. The event sequence number only increments according to the actual order in which events of the current instance successfully enter the circular diagnostic area; events that fail to be written do not occupy the sequence number of completed events.
[0062] When different execution threads arrive at the diagnostic data collection location at adjacent times, the event sequence number is still formed according to the order in which each event successfully enters the current instance's event sequence. The monotonic runtime is used to preserve the actual time relationship, and the event sequence number is used to maintain the order of events already collected by the current instance when the monotonic runtime is the same. Thread identifiers do not participate in event sorting, nor are they used as a condition for event attribution.
[0063] The local loop diagnostic area retains the actual events generated by each communication execution instance according to the instance identifier. The capacity of the diagnostic area is determined based on the concurrent loading scale allowed by the current SDK version, the seven main types of events generated by a communication execution instance in the normal execution path, and the number of network task-related events that can be generated by the retry path, so that the diagnostic area can store the actual events corresponding to the communication execution instances that are currently running.
[0064] During normal operation, the capacity of the diagnostic area will not be temporarily changed due to a single anomaly. When the diagnostic area reaches its configured capacity, the earliest event data that has formed a host callback entry event, completed the current instance's end processing, and has not yet entered fault verification will be released first. Communication execution instances that have not yet ended, communication execution instances that have experienced program exception events, and communication execution instances that have entered fault verification will continue to be retained until subsequent verification and fault diagnosis data are completed and solidified.
[0065] If, upon reaching a certain program execution location, the corresponding actual execution event is not fully written due to a failure to write to the diagnostic area, no valid event with incomplete content is generated. During the diagnostic data collection process, a diagnostic data collection exception flag is written to the request context of the current communication execution instance, and the actual event types and corresponding program execution locations are retained. This exception flag only indicates a deficiency in the diagnostic event collection process and does not directly indicate a runtime failure of the mobile advertising SDK at that program execution location.
[0066] When S3 reads the event sequence of the current instance, it continues to check whether the next program execution position has used the output of the previous program to form a real execution event at the position where there is a missing diagnostic acquisition anomaly flag, and then distinguishes between the missing diagnostic event acquisition and the actual interruption of SDK execution.
[0067] S3 directly reads the event sequence already formed by the current communication execution instance, verifies the actual execution events according to the adjacent program execution positions, and further checks whether the next program execution position has formed an actual execution event by using the output of the previous level program as input for the missing event position.
[0068] S3 specifically refers to: After S2 completes the collection of actual execution events for the current communication execution instance, it uses the instance identifier formed by S1 as the basis for event attribution. Following a fixed sequence of events—SDK loading interface entry point, request object formation point, network task establishment point, network result return point, response processing completion point, callback issuance point, and host callback entry point—it sequentially verifies adjacent program execution positions. Verification only processes events already formed in the current communication execution instance and program objects directly associated with it; it does not infer the execution status of the current instance based on event times, thread positions, or target network hosts of other communication execution instances.
[0069] When verification begins, the interface entry event is read from the event sequence formed by the current instance in S2. If the interface entry event exists, and the instance identifier, SDK package identifier, and SDK version identifier carried by the event are consistent with the corresponding information in the S1 request context, the SDK loading interface entry position is taken as the first program execution position that has completed verification.
[0070] The interface entry event was not written because S2 had already left a diagnostic collection anomaly flag. Subsequently, the request object formation event already existed, and the instance identifier carried by the request object formation event was consistent with the S1 request context. At the same time, the local identifier of the request object could be found in the corresponding item of the request object established by S1. Based on the actual program relationship that the request object must form after this interface entry, relying on the current request context, the interface entry event was registered as a collection missing event, and the location of the request object formation was verified.
[0071] If the interface entry event does not exist and there is no actual program object that can establish a direct correspondence with the current request context, the content of the interface entry event will not be rewritten; if the diagnostic collection component has confirmed that the instance association information is missing, the current instance will be registered as having incomplete diagnostic evidence, and the events of other instances will not be used to supplement it.
[0072] When a request object formation event exists, the instance identifier and local identifier of the request object are read from the event and compared with the corresponding item in the S1 request object. If both point to the current communication execution instance, the request object formation position is considered to have been verified. If a request object formation event does not exist, the immediately following network task establishment event is read.
[0073] The network task creation event already exists, and its request object local identifier can correspond to the current instance in the S1 task association item. When the network task is actually created using the request object, based on the fact that the network client must obtain the previous request object to create the network task, the request object formation event is registered as a missing data collection event, and the request object formation position is taken as the program boundary that has been crossed.
[0074] At this point, only the fact that the request object formation event is missing and the network task establishment event used as the basis for verification are saved. The occurrence time, thread identifier, target network host identifier, and actual length of the request data that should have been present in the request object formation event are not filled in.
[0075] If neither the request object formation event nor the network task creation event exists, check whether any program exception events, cancellation events, or process lifecycle end events associated with the current instance have occurred between the request object formation location and the network task creation location.
[0076] When the aforementioned actual termination event exists, the event that formed the requested object is not registered as a missing data collection event, nor is the data extrapolated to the next program execution position. Instead, the most recently verified program execution position is retained as the starting point for fault verification, and the already formed actual termination event is submitted to S4 for further verification. If no actual termination event exists, and the diagnostic data collection anomaly flag indicates that the key object association information in this interval has not been successfully saved, the current instance is registered as having incomplete diagnostic evidence, and no fault location more detailed than the existing evidence is formed.
[0077] When a network task creation event exists, the network task identifier, request object local identifier, and instance identifier are read and compared with the S1 task association item. If the correspondence of the three identifiers matches, the network task creation location is considered to have been verified. If the network task creation event is not successfully written, but a subsequent network result return event has been generated, and the network task identifier in the network result return event can correspond to the current instance in the S1 task association item, based on the procedural relationship that network results can only be generated by network tasks that have been actually created and executed, the network task creation event is registered as a missing data collection, and the network result return location is further verified.
[0078] If the network task creation event is not successfully written, and the network client has already terminated the current network task in a failed manner, the network task termination event generated by S2 is read. If the network task identifier in the network task termination event can correspond to the current instance in the task association item of S1, it indicates that the network task itself has actually been established and entered the execution process. Therefore, the network task creation event is registered as a missing data collection event; the network result return position is not considered as having been crossed.
[0079] At this point, the network task establishment location is taken as the final program execution location after verification, and the network task termination event is retained in S4. When the network client has clearly given a failure termination result, the network result return event is kept in the unformed state and is not registered as a missing data collection.
[0080] When a network result return event exists, verify whether the network task identifier in the event matches the current instance in the task association item of S1. If they match, the network result return location is considered to have completed verification. If a network result return event does not exist, but a response processing completion event has been generated, read the instance identifier and network task identifier in the response processing completion event, and verify the correspondence between the network task identifier and the task association item established in S1.
[0081] When the network task identifier points to the current communication execution instance, and the response object is formed by the data submitted to the SDK by the network task, based on the actual program relationship that the response processing must take the previous network result as input, the network result return event is registered as a missing data collection, and the position of response processing completion is verified.
[0082] If a network result return event does not exist, but a network task termination event corresponding to the current network task identifier exists, subsequent events are not used to infer that the network result has been returned normally. The network task termination event is directly used as actual evidence that the communication execution segment has abnormally terminated. The network task establishment position is maintained as the last normally executed program position that has completed verification, and S4 further determines the fault range based on the network task termination event. When the SDK actually performs a cancellation operation during the execution of the current network task, the cancellation event is also retained, and the missing network result return event after cancellation is not registered as a data collection failure.
[0083] When a response processing completion event exists, its instance identifier and network task identifier are read. The correspondence between the network task identifier and the current instance is verified, and it is confirmed that the current response object originates from the data actually returned by the network task. If the correspondence is correct, the response processing completion position is considered to have been verified.
[0084] If the response processing completion event does not exist, but the callback emission event has been formed, check the correspondence between the instance identifier of the callback emission event, the local identifier of the callback object, and the S1 callback receiving object, and read the source of the result object used by the callback object in the fixed execution path of the current version of the SDK.
[0085] When the callback object has actually obtained the result formed by the current instance response processing and entered the callback sending position, according to the program execution relationship that the callback sending position can only be reached after the current response processing is completed, the response processing completion event is registered as a missing data collection, and the callback sending position is verified again.
[0086] If a program exception event occurs before the response data reaches the response processing completion position after entering the SDK, it will not be considered a missing data collection due to the lack of subsequent response processing completion events. The network result return position remains the last program execution position that has been verified. Program exception events are retained and passed to S4 according to their actual occurrence position. When the SDK normally generates an empty result object according to the established response processing flow and continues to reach the response processing completion position, it continues to verify according to the existing response processing completion events, and the completion status of that program position will not be changed due to empty advertisement content.
[0087] When a callback event exists, the instance identifier and the callback object's local identifier are read from the event and compared with the callback receiving object established in S1. If the correspondence matches, the callback sending position is considered to have been verified. If a callback event does not exist, but a host callback entry event has been formed, and the instance identifier and callback object's local identifier carried by the host callback entry event match the S1 callback receiving object, based on the program relationship that the SDK has actually initiated this callback before the host application can enter the callback receiving object, the callback event is registered as a missing data collection, and the callback sending position is considered a program boundary that has been crossed.
[0088] When a callback event exists but the host callback entry event does not, since there is no next fixed program execution position after the host callback entry to prove that the entry has been actually entered, the host callback entry event is not supplemented by assumption. In this case, the callback issuance position is kept as the last program execution position that has been verified, and S4 is entered to read the current callback receiving object, the actual callback execution status, and process lifecycle events. When the host application has actually entered the callback receiving object, the host callback entry event written in S2 is used as the basis for the current communication execution instance to have successfully crossed the last program boundary.
[0089] Whenever a major program execution event is missing and is identified as missing based on the actual execution of the subsequent program execution location, the missing program execution location, the type of the subsequent actual execution event used to prove that the location has been crossed, and the instance identifier that both correspond to it are written into the diagnostic information of the current instance; when a request object is involved, the local identifier of the request object is also saved; when a network task is involved, the network task identifier is also saved; when a callback process is involved, the local identifier of the callback object is also saved.
[0090] This registration is only used to indicate that the missing data is the diagnostic event collection result; it does not recreate the missing event itself. The original event's missing monotonic runtime, thread identifier, actual length of requested data, actual length of response data, and exception type remain missing.
[0091] During the entire adjacent location verification process, a program execution location is considered to have completed verification only under two circumstances: 1) There is an execution event at the current location that was actually collected by S2 and verified through object correspondence; 2) The corresponding event at the current location is missing, but there is an execution event at the immediately adjacent program execution location that proves the output of the previous level program has been actually used, and the relevant instance identifier and object identifier are consistent with the correspondence established by S1. Apart from these two cases, a location is not considered complete based on the expected relationship that the program should normally execute to a certain location.
[0092] If the current program execution position does not meet the above completion verification conditions, and there is no execution event immediately following the next program execution position that can prove that the output of the previous stage has been actually used, then the program will stop moving forward across the program boundary. The current position is taken as the starting point for fault verification from the last program execution position that met the completion verification conditions.
[0093] The fault verification starting point only indicates the last program boundary that can be confirmed by existing evidence for the current instance, and does not directly indicate that the fault must have occurred at that location. S4 reads the program exception events, network task termination events, cancellation events, and process lifecycle events that have occurred between the next program execution location starting from this fault verification starting point, and then determines the fault range based on the actual exception events.
[0094] When two adjacent main program execution events are missing in the same communication execution instance, only if the last program execution position has an event that can prove that the previous output has actually been transmitted according to the aforementioned object correspondence, can the previous events be registered as missing events level by level.
[0095] If intermediate object associations are lost and it cannot be confirmed that subsequent events actually use the output of the current instance's predecessor, the inference should not be continued across the missing object associations. In this case, the last program execution location that can be confirmed by the actual event and the complete object correspondence should be retained. If key association information is missing due to the failure of the diagnostic acquisition component to write, the current instance should be registered as having incomplete diagnostic evidence.
[0096] When S2 writes the diagnostic collection anomaly flag, the flag itself is not considered an anomaly in the mobile advertising SDK program. Even if a diagnostic collection anomaly flag exists, but the subsequent program execution location can prove that the preceding execution has been completed through the actual object relationships of the current instance, the corresponding major event is still registered as a collection missing event. If the diagnostic collection anomaly has caused the key correspondences in the instance identifier, request object local identifier, network task identifier, and callback object local identifier to be unverifiable, and there is no actual execution event that can restore these correspondences, fine-grained fault location judgment is not entered to avoid writing the failure of the diagnostic collection component itself as a mobile advertising SDK communication link failure.
[0097] After completing the above verification, communication execution instances that have successfully passed all seven program execution points proceed to normal termination processing. For communication execution instances with a clearly defined fault verification starting point, the fault verification starting point, the actual execution events collected, the missing data entries, and the currently existing abnormal events are all handed over to S4. S4 does not re-establish instance ownership relationships, nor does it re-determine the object correspondence in S1. Instead, after the final program boundary confirmed in S3, it continues to read the actual abnormal events of the current communication execution instance and determine the fault range.
[0098] S4 specifically refers to: After determining the fault verification starting point of the current communication execution instance, S3 uses the program execution position corresponding to this fault verification starting point as the last program boundary that can be confirmed by actual execution events, and the immediately following program execution position as the current fault verification endpoint. Fault verification only reads program exception events, network task end events, cancellation events, and process lifecycle events directly related to the current instance between two adjacent program execution positions. It does not re-establish the instance identifier and object correspondence already formed by S1, nor does it change the registration results of S3 for missing events.
[0099] Before determining that the execution position of the immediately following program has not been reached, the boundary confirmation conditions of the execution segment are read according to the diagnostic boundary configuration corresponding to the current SDK version. For the communication execution segment between the establishment of the network task and the return of the network result, the connection timeout, read / write timeout, and task completion callback currently configured by the network client are used as the confirmation basis. If the network client has already given the actual task completion result, no further waiting for additional diagnostic timeouts is required.
[0100] From the SDK loading interface to request object formation, from request object formation to network task establishment, from network result return to response processing completion, from response processing completion to callback issuance, and from callback issuance to the execution segment corresponding to the host callback entry, the boundary confirmation time limit is used, which is saved with the diagnostic boundary configuration of the current SDK version. The boundary confirmation time limit is determined based on the actual processing flow of the corresponding program execution segment, the thread scheduling method used by the SDK, and the existing runtime configuration, and is fixedly saved in the diagnostic boundary configuration of the current SDK version. It is not temporarily changed for a single exception during the runtime of the same SDK version.
[0101] The boundary confirmation time limit is determined before the SDK version is released, based on the normal operation process of the corresponding program execution segment, and written into the diagnostic boundary configuration of the corresponding version. During the determination process, the configuration value is formed based on the normal completion status and execution time range of the corresponding execution segment. During the actual operation, only the diagnostic boundary configuration corresponding to the current version is read for judgment, and the boundary confirmation time limit is not adjusted based on the running result of a single communication execution instance.
[0102] For execution segments using boundary confirmation timeouts, the actual arrival time of the previous program execution position is used as the timing start point. The current time is read according to the monotonic running clock used in S2, and the difference between the current time and the timing start point is compared with the boundary confirmation timeout corresponding to the execution segment. If the difference reaches the boundary confirmation timeout and S3 has not obtained verification evidence that the immediately following program execution position has arrived, the fault verification of the corresponding execution segment begins. If the actual arrival time of the previous program execution position cannot be obtained, the timing start point is not inferred based on the missing event; only the actual interruption event already formed by the current communication execution instance is used for verification.
[0103] If the diagnostic boundary configuration of the current SDK version does not set the boundary confirmation time limit for the corresponding execution segment, the interruption of the execution segment will not be determined based on time, but will only be verified based on the actual program exception events, network task completion events, cancellation events, and process lifecycle events that can be obtained.
[0104] Program exceptions occur at the actual exception capture location in the SDK, saving the instance identifier, exception location identifier, exception type, and monotonic execution time. When a program exception occurs in the execution segment of an already established network task, the corresponding network task identifier is saved; when a program exception occurs during callback handover, the local identifier of the callback object is saved. Network task termination events originate directly from the failure termination callback generated by the network client for the current real network task, saving the instance identifier, network task identifier, task termination type, and termination time.
[0105] Cancellation events are generated only when the SDK actually performs a cancellation action, saving the instance identifier, cancellation location, and cancellation time. If the network task has already been established when cancellation occurs, the identifier of the cancelled network task is also saved; if the cancellation occurs before the network task is established, no non-existent network task identifier is generated. Process lifecycle events are associated with the process startup sequence number in S1, saving the process startup, normal termination, and abnormal termination facts that can be actually obtained by the host application runtime environment. If the mobile terminal runtime environment does not provide verifiable abnormal termination information, it does not automatically generate a process abnormal termination event based on the sudden stop of the communication execution instance.
[0106] For actual events acquired within the fault verification interval, their original order of occurrence is maintained according to the monotonic running time. When multiple actual events occur in the same verification interval, a fixed priority is not preset among program exception events, network task termination events, cancellation events, and process lifecycle events. Instead, the actual relationship between each event and the current execution segment is checked. The first actual event that can terminate the current execution segment and prevent the immediately following program execution position from being formed is taken as the interrupt event of the current instance.
[0107] Following an interruption event, any subsequent events arising from the termination of the previous action are retained, but the starting point for fault verification remains unchanged. For example, if the SDK first cancels a network task, and the network client subsequently returns a result indicating the task cancellation has ended, the actual cancellation event indicates that the current instance was terminated by the SDK's cancellation action. Subsequent network task completion events are saved as facts of task completion after cancellation and are not re-identified as independent network communication failures.
[0108] The fault verification starts at the SDK loading interface entry point. If the requested object formation point is not formed after the corresponding boundary confirmation conditions are met, the actual events between the interface entry point and the requested object formation point are read. If there is a program exception event consistent with the current instance, and the requested object construction process does not continue to the requested object formation point after the program exception occurs, the fault interval is maintained between the SDK loading interface entry point and the requested object formation point, and the location where the program exception occurred is saved.
[0109] If a cancellation event exists for the current instance, register the current communication execution instance as cancelled and do not write the failure to form a request object as an SDK program fault. If the actual process lifecycle event of the current process having terminated can be obtained, register the current instance as a process interruption and maintain the last confirmed program execution position. If none of the above actual events exist, and S3 has confirmed that key diagnostic information is missing, maintain the incomplete diagnostic evidence and do not forcibly form a request to construct a fault.
[0110] The fault verification starts at the point where the request object is formed. If the network task establishment point has not yet been formed, the task submission process corresponding to the local identifier of the current request object in S1 is read. If the network client generates a program exception event consistent with the current instance before accepting the request object, and no real network task has been formed, the fault interval is maintained from the point where the request object is formed to the point where the network task is established.
[0111] The network client has already created a network task corresponding to the current request object. The task association item in S1 can obtain the corresponding network task identifier. However, if S2 fails to save the network task creation event, a network task creation failure will not occur in S4. Instead, the existing missing data collection criteria from S3 will be returned, and subsequent verification will continue with the actual network task. If the current instance has already performed a cancellation action before the network task was created, it will be treated as a cancellation and no non-existent network task identifier will be generated.
[0112] When the fault verification starts at the network task establishment location, the execution result of the actual network task is read using the network task identifier in the S1 task association item. When the network client has obtained a normal server response, a network result return event should be generated by S2; if the network result return event is missing due to diagnostic collection failure, but the subsequent response processing completion event can prove that a normal response has entered the SDK according to the S3 rules, the missing collection result should be retained, and a communication fault should not be re-generated in S4.
[0113] When a network client terminates a task in a failed manner and actually generates a network task termination event, the failure range is maintained from the network task establishment position to the network result return position, based on the task termination type saved by the network client. Domain name resolution failure, connection establishment failure, existing connection interruption, and read / write timeout all use the actual technical termination type returned by the network client, and are not renamed based on the ad loading result. If the SDK has already executed the cancellation action corresponding to the current instance before the network task terminated, it saves the cancellation event and the network task termination event together according to their actual time relationship, and processes the task according to the cancellation path.
[0114] The fault verification starts at the network result return position. If the response processing completion position has not been formed after the corresponding boundary confirmation conditions are met, the actual response processing process after the current network task is submitted to the SDK is read. If a program exception occurs during response parsing, response object construction, and the formation of the local result required for subsequent callbacks, and this exception prevents the program from reaching the response processing completion position, the fault interval is maintained between the network result return position and the response processing completion position, while saving the actual exception occurrence position and exception type.
[0115] If the data returned by the server can form a valid empty result object according to the current SDK's established data format and has entered the response processing completion stage, the response processing will not fail due to empty advertising content. If the response data does not conform to the current SDK's established data format and a clear technical failure event occurs due to the SDK's existing data processing exit, the actual failure location will be saved, and the situation will not be rewritten as a network transmission failure.
[0116] The fault verification starts at the response processing completion position. If the callback issuance position has not been formed after the corresponding boundary confirmation condition is met, the callback receiving object established by S1 and the result handover process of the current instance are read. If the result object has been formed, but the SDK generates a program exception before the result object is handed over to the callback receiving object, and the execution process has not reached the callback issuance position, the fault interval is maintained between the response processing completion position and the callback issuance position.
[0117] When the current instance performs a cancellation action within this range, it is treated as a cancellation termination. If the callback receiver object has not yet been actually created, no local identifier for the callback object is generated; program exceptions are still retained based on the instance identifier and the actual location of the exception.
[0118] The fault verification starts at the callback issuance location. If the host callback entry point is not formed within the callback confirmation timeout period, the local identifier of the callback object established by S1 is read, and it is verified whether the callback receiving object is still associated with the current instance. The callback confirmation timeout period is taken from the diagnostic boundary configuration of the current SDK version, determined according to the callback thread scheduling method adopted by this SDK version and the actual execution flow of the callback receiving object, and remains fixed during the operation of the current SDK version, without being temporarily changed for a single callback.
[0119] If the host application process continues to exist during the confirmation period, the callback recipient still corresponds to the current instance, and no cancellation or process termination event occurs, the fault range is maintained from the callback issuance position to the host callback entry point. If the application process has generated a verifiable termination event after the callback is issued, the current instance is registered as a process interruption, and the lack of a host callback entry point is not directly considered an SDK callback program exception. If the callback reaches the confirmation time limit but has not yet been reached, the current instance remains pending verification, and the fault range is not prematurely established.
[0120] When S4 forms a fault zone, only the instance identifier and its mapping to the S1 object can be used to directly associate the actual event of the current communication execution instance. Network task-related exceptions must be verified against the network task identifier corresponding to the current instance, and callback-related exceptions must be verified against the local identifier of the callback object corresponding to the current instance. Program exceptions generated by other SDKs, network task failures of other communication execution instances, and thread exceptions that occur only because of their similar occurrence times are not included in the current instance.
[0121] When multiple actual abnormal events exist within the current fault verification interval, the interrupt event that first prevents the current execution segment from reaching the immediately following program execution position is determined according to the monotonic running time and the actual program execution path, and the position corresponding to this event is registered as the first abnormal position. Subsequent actual events are retained as supplementary diagnostic evidence for the same instance. If it is impossible to determine from the actual events already obtained which event caused the current execution segment to terminate, only the fault interval defined by two adjacent program execution positions and the abnormal events already obtained are retained, without further forming more detailed abnormal positions that lack direct evidence support.
[0122] After S4 is completed, the instance identifier, fault verification start point, fault range, first abnormal location, corresponding program abnormal event, network task end event, cancellation event, and obtainable process lifecycle events are passed to S5. S5 uses the object correspondence established in S1, the actual execution events formed in S2, and the missing collection information registered in S3 to solidify the fault diagnosis data, without changing the fault range already determined in S4.
[0123] S5 specifically refers to: After S4 determines the fault range of the current communication execution instance, it uses the instance identifier formed in S1 as the primary basis for attribution of the current communication execution instance and extracts the execution information that has actually been formed from the time the instance entered the SDK loading interface to the time the fault range is determined from the local loop diagnostic area used in S2.
[0124] Request object-related information continues to be distinguished using the local identifier of the request object established in S1, network task-related information continues to be distinguished using the network task identifier, and callback-related information continues to be distinguished using the local identifier of the callback object. New object mappings are not re-established due to entering the fault data solidification phase. When multiple communication execution instances are running simultaneously, data from different instances are not merged based on ad slot name, target network host identifier, thread identifier, or the proximity of event occurrence times.
[0125] First, read the actual execution events that have been successfully written to the seven program execution locations in S2 for the current instance, and retain the original instance identifier, object local identifier, network task identifier, monotonic execution time, and event sequence number for each event. Then, read the still valid association information of the current instance in the corresponding items of the request object in S1, the task association items, and the callback receiving object, so that the request object formation event, network task establishment event, network task completion event, callback emission event, and host callback entry event can continue to be mapped to the actual program object.
[0126] When S3 has registered a program execution location as missing, it saves the missing data flag for that location in the fault diagnosis data. Simultaneously, it saves the subsequent actual execution event and its corresponding object, which S3 uses to prove that the location has been crossed. The event occurrence time, thread identifier, actual length of the request data, actual length of the response data, and exception type that were not successfully acquired at the missing data location remain missing; no inferred data is added based on preceding or following events.
[0127] Based on the aforementioned execution information, the fault verification start point, fault range, and first anomaly location formed in S4 are read, and the actual anomaly evidence directly corresponding to the current fault range is extracted. When a program exception causes execution interruption, the instance identifier, anomaly location identifier, anomaly type, and monotonic running time in the program exception event are saved; when a network task ends in a failed manner, the corresponding network task identifier, the actual task end type given by the network client, and the end time are saved; when the SDK has already executed the cancellation action of the current instance, the cancellation location, cancellation time, and the identifier of the network task that actually exists are saved; when the application process ends in the current execution segment, the process lifecycle events that can be obtained by the mobile terminal's operating environment are saved. Anomalies not obtained in S4 are not re-inferred in S5.
[0128] The program execution order in the fault diagnosis data continues to use the event sequence numbers and monotonic running times already formed in S2, without readjusting the actual order of events. Event sequence numbers are used to maintain the order of successfully collected events in the current instance, and monotonic running times are used to preserve the temporal relationship of each actual event within the current application process. For missing collection locations registered in S3, only a corresponding missing flag is inserted; no new event sequence number is generated for that missing location, nor are the already formed event sequence numbers of the actual events preceding and following it changed.
[0129] When the first abnormal location determined by S4 is located between two adjacent program execution locations, the fault interval and the actual location of the abnormality are preserved in the fault diagnosis data. The abnormal location is not rewritten to the previous or next program execution location in order to form a continuous sequence.
[0130] After completing the fault data processing for the current instance, an anomaly diagnosis record is created in the local non-volatile storage area with write permissions for the host application. The anomaly diagnosis record is distinguished by at least the SDK package identifier, SDK version identifier, process startup sequence number, and instance increment sequence number, so that the anomaly diagnosis record can be mapped to the current communication execution instance created by S1.
[0131] The SDK package identifier and SDK version identifier directly use the actual SDK information read by S1, and no new SDK identifier caliber is used. The process startup sequence number is used to distinguish the instance before and after the application process is restarted, and the instance increment sequence number is used to distinguish different loading interface calls within the same process.
[0132] The anomaly diagnosis log first writes instance-level basic information, then writes program execution events in the order of actual events in the current instance, followed by the missing data collected in S3 and the fault range and anomaly evidence generated in S4. Instance-level basic information stores the instance identifier, SDK package identifier, SDK version identifier, and process startup sequence number; object association information stores the local identifier of the actually formed request object, network task identifier, and callback object; execution information stores the program execution location, event type, event sequence number, and monotonic execution time; fault information stores the fault verification start point, fault range, first anomaly location, and corresponding actual anomaly event.
[0133] If no object is created for the current instance, the corresponding object identifier is not written. The ad request body, ad creative content, user profile information, ad bidding content, and delivery rules are not written to the anomaly diagnostic log.
[0134] To distinguish between complete solidified data and partial data written due to process interruption, the anomaly diagnosis record is initially in an incomplete solidification state when it is established. Only after instance-level basic information, currently acquired execution events, S3 missing data collection information, and S4 fault diagnosis information have all been written, and the mobile terminal storage interface returns a success message for the above writes, is a solidification completion flag written to the end of the anomaly diagnosis record.
[0135] Before the completion flag is written, the request object corresponding items, task association items, and callback object association information used for fault verification in the current instance are not released. After the completion flag is successfully written, the current anomaly diagnosis record is retained as complete diagnostic data for this fault, and temporary association information that has ended and will no longer participate in subsequent verifications is released.
[0136] If an application process terminates abnormally before the completion flag is written, the next application process will read the abnormal diagnostic records from the non-volatile storage area upon startup. Records with the completion flag are read as complete solidified data; records without the completion flag remain as incomplete solidified data, and only the actual fields successfully written before exiting are read, with incomplete diagnostic evidence recorded.
[0137] Incompletely saved data will not be used to fill in execution events that were not successfully saved in the previous process, nor will it be used to supplement the fault records of the previous process based on the running data of the current new process. S1 forms a new process startup sequence number in the new process, so the communication execution instances generated by the new process will not be confused with the incompletely saved instances of the previous process.
[0138] When non-volatile storage areas return actual storage anomalies such as insufficient space, directory unwritable, or write failure during the write process, these storage anomalies are not registered as mobile advertising SDK communication link failures. The current instance continues to be retained in the local circular diagnostic area while the application process is still running, and diagnostic data is written to the current request context to solidify the anomaly flag.
[0139] The information related to the requested object, task, and callback object will not be prematurely released due to this write failure before the fault diagnosis data is fully solidified. If the diagnostic information in memory cannot be retained due to the application process exiting, only the actual data that has already successfully entered the non-volatile storage area will be used, and no data that has not actually been written will be generated.
[0140] When there is a pre-defined network task retry process in the same communication execution instance, each actually established network task continues to use the independent network task identifier formed by S1 and is collectively attributed to the current instance identifier. When a previous network task has generated a network task termination event and the corresponding fault range has been determined by S4, S5 saves the actual failure information that the network task has already occurred, and does not delete the fault facts of the previous network task due to the re-establishment of the subsequent network task.
[0141] When the SDK continues to create the next network task according to its established process, the new network task establishes a new task association item according to S1, and continues to generate the corresponding actual execution event according to S2. When the next network task completes normally, the task end type and exception location that have been fixed in the previous network task are not modified; when the next network task fails again, S3 and S4 verification are executed according to the actual event of the corresponding network task.
[0142] For subsequent communication execution instances generated within the same SDK version, each new SDK loading interface call still obtains a new instance increment sequence number according to S1 and forms a new instance identifier. The actual execution events of the current instance are then re-collected according to the seven program execution locations corresponding to S2. Subsequent instances do not inherit the missing collection flags, fault verification start points, and first exception locations of the previous abnormal instance, nor are they pre-defined as exception locations simply because a previous instance has already experienced a fault in a certain program execution segment.
[0143] When a subsequent instance actually crosses the fault interval corresponding to the previous instance, it continues to enter the next program execution position according to its own actual execution event; when a real execution interruption is formed again between the two same program execution positions, the fault evidence of the instance itself is obtained again according to S3 and S4, and an independent abnormal diagnosis record is established.
[0144] When the current communication execution instance terminates due to an actual cancellation action by the SDK, the cancellation event verified by S4 and the program execution events that actually occurred before cancellation are retained. Missing program positions after cancellation are not recorded as SDK program exceptions. When the current instance cannot continue execution due to the actual termination of the application process, the obtained process lifecycle events and the program execution events that actually occurred before process termination are saved. Missing program positions after process exit are not presumed to be an internal SDK execution failure. When a network task has already received a genuine failure result from the network client, the network task termination event is saved. The failure to display the final advertisement is not used to replace the actual technical termination type given by the network client.
[0145] Once the anomaly diagnosis record is finalized, the fault verification start point, fault range, first anomaly location, and actual anomaly evidence for the current instance will remain unchanged. New events generated by subsequent instances will not be added to the anomaly diagnosis record of the previous instance that has already been finalized.
[0146] When a new network task generated within the current instance due to a predetermined retries forms a new event according to its actual execution process, the call attribution is maintained through the same instance identifier, and the task is distinguished through the new network task identifier, without overwriting the previously fixed network task fault information.
[0147] The above content is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for diagnosing communication link anomalies in a mobile advertising SDK, characterized in that, Includes the following steps: S1. When the host application enters the mobile advertising SDK loading interface, a communication execution instance corresponding to this interface call is established, the instance identifier is written into the SDK request context, and the correspondence between each object and the instance identifier is established when the request object is formed, the network task is established, and the callback receiving object is established respectively. S2. Record the actual execution events at the program execution locations corresponding to the SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry, and associate the actual execution events corresponding to the same communication execution instance according to the instance identifier and the order of event occurrence. S3. Verify the actual execution events corresponding to adjacent program execution positions in the same communication execution instance in turn; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position has an actual execution event formed by using the output of the previous level program as input, register the current missing event as a missing event and continue to verify the subsequent program execution position; if the actual execution event corresponding to the current program execution position is missing, and the subsequent program execution position does not have an actual execution event that can prove that the output of the previous level program has been actually used, under the condition that the correspondence of key objects can be verified, take the previously verified program execution position as the starting point for fault verification. When the verification of the correspondence between key objects cannot be completed, the current communication execution instance will be registered as having incomplete diagnostic evidence. S4. Read the program exception events, network task end events, cancellation events and process life cycle events associated with the current communication execution instance from the fault verification starting point to the immediately following program execution position. Verify whether the immediately following program execution position has been reached according to the boundary confirmation conditions corresponding to the current SDK version. If it is confirmed that the position has not been reached, determine the fault range according to the fault verification starting point and the immediately following program execution position. When the first actual event that terminates the current execution segment can be identified and its location, that location is registered as the first abnormal location. S5. Extract the actual execution events that have been formed from the time the current communication execution instance enters the SDK loading interface to the time the fault range is determined. Maintain the correspondence between the instance identifier and the local identifier of the request object, the network task identifier and the local identifier of the callback object that have been formed. Then, associate the fault range determined in S4 with the aforementioned actual execution events and write them into the non-volatile storage area.
2. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 1, characterized in that, In S1: After the application process starts, it reads and updates the process startup sequence number. When the SDK loading interface is entered, it reads the SDK package identifier, SDK version identifier, and the current instance increment sequence number in the process, and forms the instance identifier based on the process startup sequence number, SDK package identifier, SDK version identifier, and instance increment sequence number. After a request object is created, a mapping relationship is established between the local identifier and the instance identifier of the request object. After a network task is created, a mapping relationship is established between the network task identifier, the local identifier of the request object, and the instance identifier. After a callback receiver object is created, a mapping relationship is established between the local identifier and the instance identifier of the callback object.
3. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 1, characterized in that, In S2: Read the SDK version identifier and the diagnostic boundary configuration corresponding to the SDK version identifier, and determine the program execution location corresponding to the SDK loading interface entry, request object formation, network task establishment, network result return, response processing completion, callback issuance, and host callback entry based on the diagnostic boundary configuration; When the current SDK version identifier matches the SDK version identifier in the diagnostic boundary configuration, the corresponding actual execution event is recorded at each program execution location.
4. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 3, characterized in that, S2 also includes: When each actual execution event is written, the instance identifier is checked. For events related to the request object, the local identifier of the request object is checked at the same time. For events related to the network task, the network task identifier is checked at the same time. For events related to the callback, the local identifier of the callback object is checked at the same time. The actual execution events that have been verified are assigned event numbers according to the actual writing order in the current communication execution instance, and are written together with the corresponding monotonic running time into the local loop diagnostic area.
5. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 1, characterized in that, In S3: When the actual execution event corresponding to the current program execution position is missing, read the actual execution event of the next program execution position and verify the correspondence between the previous level program output used by the next actual execution event and the current communication execution instance; The request object phase checks against the local identifier of the request object, the network task phase checks against the network task identifier, and the callback phase checks against the local identifier of the callback object. When the correspondence is consistent with the current communication execution instance, the current missing event is registered as a missing data collection event.
6. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 5, characterized in that, S3 also includes: When the same communication execution instance is missing two consecutive actual execution events at two adjacent program execution positions, under the condition that the first actual execution event after the two adjacent program execution positions can be checked step by step along the corresponding object identifier to the current communication execution instance, the missing events corresponding to the two adjacent program execution positions are registered as missing events in sequence. If step-by-step verification cannot be completed, the verification process will stop and the last program execution location that has been verified will be used as the starting point for fault verification. If the correspondence between key objects cannot be verified, the current communication execution instance will be registered as having incomplete diagnostic evidence.
7. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 1, characterized in that, In S4: Program exception events are associated with the current communication execution instance based on the instance identifier and the location identifier of the exception occurrence; network task completion events are associated with the current communication execution instance based on the instance identifier and the network task identifier; cancellation events are associated with the current communication execution instance based on the instance identifier and the location of the cancellation occurrence; and process lifecycle events are associated with the application process in which the current communication execution instance resides based on the process startup sequence number. According to the monotonic operation time, verify the actual occurrence order of the aforementioned events, and verify the actual relationship between each event and the execution segment from the fault verification start point to the immediately following program execution position; if the first actual event that terminates the execution segment can be determined, and the occurrence position of the event can be verified, the corresponding occurrence position is registered as the first abnormal position; if the first actual interruption event and its occurrence position cannot be determined, retain the determined fault interval and the actual events that have been obtained, and do not register the first abnormal position.
8. The method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 1, characterized in that, In S5: Extract the actual execution events that have been formed in the current communication execution instance, the missing collection information registered by S3, and the fault verification starting point and fault range determined by S4; When S4 has determined the first anomaly location, it extracts that first anomaly location and maintains the established correspondence between the instance identifier, the local identifier of the request object, the network task identifier, and the local identifier of the callback object. Event fields that have not actually been formed remain missing. After the fault diagnosis data is written and the write success result is obtained in the non-volatile storage area, the solidification completion flag is written, and then the temporary object association information corresponding to the current communication execution instance is released.
9. A method for diagnosing communication link anomalies in a mobile advertising SDK according to claim 8, characterized in that: When a network task is retried in the same communication execution instance, an independent network task identifier is created for each actual network task, and the correspondence between each network task identifier and the same instance identifier is maintained. The network task completion event that has been generated in the previous network task is retained. The subsequent network task continues to execute the adjacent program execution location verification and fault range determination based on the corresponding actual execution event. The fault diagnosis data of the previous network task that has been solidified is not overwritten by the subsequent network task and subsequent communication execution instances.
