Static detection method and system for low-efficiency display problem of mobile application picture
By conducting code analysis and pattern matching on the installation files of mobile applications, the problem of inefficient display of pictures in mobile applications is identified and reported, which solves the problem of being unable to detect the inefficient display of pictures in mobile applications in the existing technology, and realizes the inefficient display of pictures in mobile applications. System identification and detection of problems.
Patent Information
- Application Number
- CN202410830331.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-22
AI Technical Summary
The existing technology lacks an analysis and summary of the system characteristics of the inefficient display of mobile application images, and cannot detect the inefficient display of mobile application images during the testing process.
By traversing the installation files of mobile applications, identify and record the call statements of the image decoding API, conduct data flow and control flow analysis, obtain contextual information, and match the preset mode rules to identify and report inefficient image display problems.
It realizes systematic identification and accurate detection of inefficient image display problems in mobile applications, and provides code feature analysis to help developers diagnose and repair problems.
Smart Images

Figure CN118820084A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software engineering, and in particular to a static detection method and system for inefficient display problems of mobile application images. Background Art
[0002] Media-intensive mobile application software needs to carefully implement its image display function that consumes high CPU and memory resources. Inefficient image display function implementation will cause significant resource overhead and seriously affect the performance of mobile software, thereby greatly affecting the user experience. For example, the existing invention patent application document "Image Transmission Method, System and Device" with publication number CN103200251A, the existing method includes: the server encodes the image to generate a binary image file; the server sends the binary image file to the client through a response message according to the client's request message, and adds identification information in the response message; the client calls the decoding API interface to decode the binary image file according to the identification information; the client calls the image display API interface to display the decoded image. The inefficiently displayed images in the above-mentioned prior art will cause many problems such as mobile application operation crashes, UI interface display delays, memory consumption expansion or battery exhaustion, and ultimately cause users to abandon and uninstall the mobile application. Existing studies have shown that the problem of inefficient image display in mobile application software is widespread. In order to ensure the performance of the image display function of mobile software and the user experience, it is necessary to systematically test the image display function of mobile software to avoid the problem of inefficient image display. However, existing research lacks systematic detection technology for the problem of inefficient display of mobile application images, and related method research is still ongoing. The main shortcoming of existing technology in the problem of inefficient display of mobile application images is the lack of systematic feature analysis and summary of such problems, and thus the inability to systematically detect such problems during the testing of mobile applications.
[0003] In summary, the existing technology lacks a systematic feature analysis and summary of the problem of inefficient display of mobile application images, and is unable to detect the technical problem of inefficient display of mobile application images during the mobile application testing process. Summary of the invention
[0004] The technical problem to be solved by the present invention is: how to solve the technical problem that the prior art lacks a systematic feature analysis and summary of the problem of inefficient display of mobile application images, and cannot detect the problem of inefficient display of mobile application images during the mobile application testing process.
[0005] The present invention adopts the following technical solutions to solve the above technical problems: A static detection method for inefficient display of mobile application pictures includes:
[0006] S1. Using the installation file of the mobile application as input data, traversing and scanning the code information of the installation file, identifying and obtaining the local code of the non-third-party library as the developer code;
[0007] S2. Locate the image decoding API in the developer code to obtain and record the call statement of the image decoding API;
[0008] S3. Perform data flow analysis and control flow analysis on each statement that calls the image decoding API to obtain context information related to the image decoding API.
[0009] S4, performing a rule matching operation on the image decoding API and the context information and the pattern rule of the image inefficient display problem, so as to identify and obtain the image inefficient display problem in the mobile application;
[0010] S5. For each inefficient image display problem, output anti-pattern category information according to a preset anti-pattern of the inefficient image display problem, and organize problem reports related to the problem accordingly.
[0011] The present invention analyzes and summarizes the common code patterns of this type of problem to obtain the code features of this type of problem, and then systematically identifies the problem of inefficient image display in mobile applications through systematic code feature analysis.
[0012] In a more specific technical solution, in S1, the local logic code of the mobile application is taken as the analysis object.
[0013] In a more specific technical solution, S2 includes:
[0014] S21. According to the image decoding API listed in the API column in Table 1 “Pattern rules for inefficient image display problems”, the code in the mobile app is scanned to obtain all program statements that call the image decoding API.
[0015] In a more specific technical solution, S21 includes:
[0016] S211, traversing the developer code line by line;
[0017] S212. When a program statement calls an image decoding API in a preset API column, the current statement calling the image decoding API and the specific location information of these program statements in the mobile app are recorded as context analysis input data.
[0018] In more specific technical solutions, S3 includes:
[0019] S31, in the process of obtaining context information related to the image decoding API, firstly perform control flow analysis on the mobile app;
[0020] Specifically, the aforementioned control flow analysis operation includes:
[0021] Constructing a control flow graph: Identify all basic blocks and control flow transfer points in the mobile application; a basic block can be a sequence of statements that are executed continuously; control flow transfer points include but are not limited to: conditional branches and loops;
[0022] Locate the statement that calls the image decoding API: Locate the node that calls the image decoding API in the control flow graph;
[0023] Control flow path: Analyze all control flow paths from the program entry to the image decoding API call node;
[0024] Conditional analysis: For conditional branches in the control flow, analyze which conditions will affect the call of the image decoding API.
[0025] Specifically, the operations for performing the aforementioned data flow analysis include:
[0026] Variable tracking: First, for a statement that calls the image decoding API (such as Bitmap bitmap = BitmapFactory.decodeResource (getResources (), R.drawable.image)); track all variables used in the API call (such as the return value of getResources () and R.drawable.image);
[0027] Data dependencies: Analyze the data flow to determine which variables or data are inputs to the image decoding API or affect the decoding results;
[0028] Path analysis: Track the data flow path to determine which code paths may lead to the call of the image decoding API. The program statements involved in the path analysis process are the context information related to the image decoding API;
[0029] S32. In the process of obtaining context information related to the picture decoding API, the present invention refers to all statements that are dependent on the picture decoding API program statements as code slices related to the picture decoding API.
[0030] Aiming at the problem of inefficient image display in mobile software, the present invention uses a static program analysis method, takes the program statement that calls the image decoding API as the starting point, and uses program slicing technology to obtain program context information related to the image display function, thereby providing a basis for subsequent detection of inefficient image display problems.
[0031] In a more specific technical solution, S4 includes:
[0032] S41, obtaining an image decoding API-context pair from a preset list to obtain a context in the predefined question information;
[0033] S42, using the predefined question information, performing a rule matching operation on the image decoding API and the context information associated with the image decoding API according to a preset detection rule;
[0034] S43. Use the preset analysis tool to perform code slicing on the mobile application;
[0035] S44. If the context defined in the picture decoding API-context pair is detected in the code slice, it is determined that the current mobile application has an inefficient picture display problem.
[0036] In a more specific technical solution, in S42, the preset detection rules include: a first rule, a second rule, a third rule, a fourth rule, a fifth rule, a sixth rule and a seventh rule.
[0037] Specifically, in the process of checking the call graph reachability of the second, third, and fourth rules, the method call graph is traversed forward and backward starting from the node where the image decoding API is called. If, during the traversal process, a node where the target method is called is reached, it indicates that the image decoding API and the target method are reachable.
[0038] The present invention aims at the problem of inefficient image display in mobile software, systematically summarizes its common problem patterns, and performs feature analysis on the obtained context information related to the image display function based on these problem patterns to achieve accurate detection of such problems.
[0039] In a more specific technical solution, in S43, the preset analysis tools include: Soot program analysis framework.
[0040] In a more specific technical solution, S44 includes:
[0041] S441, comparing the picture decoding API-context pairs in the preset list, checking the call point of the picture decoding API corresponding to each potential problem;
[0042] S442, for each call point, obtain a call graph and a data flow graph of the image display related method parameters through backward slicing;
[0043] S443. For each call point, obtain a call graph and a data flow graph related to the use of the decoded picture object through forward slicing;
[0044] S444. Detect the problem of inefficient display of images in the mobile application by referring to the preset anti-pattern of inefficient display of images.
[0045] In a more specific technical solution, the static detection system for inefficient display of mobile application images includes:
[0046] The developer code identification module is used to use the installation file of the mobile application as input data, traverse and scan the code information of the installation file, identify and obtain the local code of the non-third-party library as the developer code;
[0047] The image decoding API positioning module is used to locate the image decoding API in the developer code to obtain and record the call statement of the image decoding API. The image decoding API positioning module is connected to the developer code identification module;
[0048] A context information acquisition module is used to perform data flow analysis and control flow analysis on each call to the picture decoding API to obtain context information related to the picture decoding API. The context information acquisition module is connected to the picture decoding API positioning module;
[0049] An image inefficient display problem detection module is used to perform a rule matching operation on the image decoding API, context information, and the image inefficient display problem pattern rule to identify and obtain the image inefficient display problem in the mobile application. The image inefficient display problem detection module is connected to the context information acquisition module and the image decoding API positioning module;
[0050] The image inefficient display problem reporting module is used to output anti-pattern category information for each image inefficient display problem according to the preset image inefficient display problem anti-pattern, and to organize problem reports related to the problem. The image inefficient display problem reporting module is connected to the image inefficient display problem detection module.
[0051] Compared with the prior art, the present invention has the following advantages:
[0052] The present invention analyzes and summarizes the common code patterns of this type of problem to obtain the code features of this type of problem, and then systematically identifies the problem of inefficient image display in mobile applications through systematic code feature analysis.
[0053] Aiming at the problem of inefficient image display in mobile software, the present invention uses a static program analysis method, takes the program statement that calls the image decoding API as the starting point, and uses program slicing technology to obtain program context information related to the image display function, thereby providing a basis for subsequent detection of inefficient image display problems.
[0054] The present invention aims at the problem of inefficient image display in mobile software, systematically summarizes its common problem patterns, and performs feature analysis on the obtained context information related to the image display function based on these problem patterns to achieve accurate detection of such problems.
[0055] The present invention solves the technical problems in the prior art of lacking a systematic feature analysis and summary of the problem of inefficient display of mobile application images, and being unable to detect the problem of inefficient display of mobile application images during mobile application testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is a schematic diagram of the basic steps of a static detection method for inefficient display of mobile application images according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described in combination with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] Example 1
[0059] like Figure 1 As shown, the static detection method for the inefficient display problem of mobile application pictures provided by the present invention includes the following basic steps:
[0060] S1. Identify the developer code implementation in Android applications;
[0061] In this embodiment, the installation file of the mobile application is used as input, the code in the installation file is scanned, and the local code that is not a third-party library is identified;
[0062] In this embodiment, an .apk file of a tested mobile application is used as input; the codes involved in the application are traversed and scanned. In this embodiment, a large amount of third-party library code will be used in the implementation of the mobile application, and the code in these third-party libraries may involve the implementation of the image display function. In this embodiment, since the mobile application developer is not familiar with the specific implementation in the process of using the third-party library code, in order to facilitate manual verification of the detected inefficient image display problem, the object of analysis is the local logic code of the mobile application, and the code in the third-party library will not be analyzed. Specifically, a whitelist of third-party libraries commonly used by mobile applications is prepared, and the code parts related to the third-party libraries in the whitelist are ignored in the process of traversing the application code.
[0063] S2. Locate the image decoding API in the developer code;
[0064] In this embodiment, during the process of traversing the local logic code of the mobile application line by line, a program statement that calls a specific image decoding API is identified;
[0065] In this embodiment, for the image display function, the image data is first decoded; the decoded image data is subsequently processed and displayed on the mobile device. In this embodiment, the local logic code of the mobile application is first traversed line by line. If it is found that a program statement calls the image decoding API involved in the API column in Table 1 below, it indicates that the statement should be recorded for subsequent context analysis.
[0066] S3, obtaining context information for realizing the picture display function;
[0067] In this embodiment, for each recorded statement that calls the picture decoding API, context information related to the picture decoding API in the statement is obtained through data flow and control flow analysis;
[0068] In this embodiment, for each recorded statement that calls the picture decoding API, context information related to the picture decoding API in the statement is continuously obtained; by analyzing the statements that the statement that calls the picture decoding API depends on and is depended on, forward and backward code slicing between procedures is performed with the calling point of the picture decoding API as the starting point, and code slices related to the picture decoding API are obtained;
[0069] Specifically, the initial code slice only contains statements that call the image decoding API; the program dependency graph and call graph of the mobile application are traversed; if the sliced statement is dependent on or is dependent on by the traversed statement, the statement is added to the code slice. Repeat the above traversal process until the code slice size converges. The obtained code slice is the context information related to the image decoding API.
[0070] S4, detection of inefficient image display problems based on rule matching;
[0071] In this embodiment, the acquired picture decoding API and the context information related thereto are matched with the pattern rules of the inefficient picture display problem to identify the inefficient picture display problem existing in the mobile application;
[0072] In this embodiment, the obtained picture decoding API and the context information related thereto are matched with the problem triggering context defined in the picture decoding API-context pair in Table 1; if the context defined in the picture decoding API-context pair is checked in the code slice, it is considered that there is an inefficient picture display problem in the mobile application;
[0073] In this embodiment, the correctness of the code slicing results usually depends on the accuracy of the statically constructed program dependency graph and method call graph. In this embodiment, the widely used Soot program analysis framework is used to perform code slicing on mobile applications to ensure the accuracy of the analysis results;
[0074] In this embodiment, each potential picture decoding API call point that causes the problem of inefficient picture display is checked by comparing the picture decoding API-context pair in Table 1 below. In this embodiment, for each picture decoding API call point, the call graph and data flow graph of the method parameters related to picture display are obtained through backward slicing; the call graph and data flow graph related to the use of decoded picture objects are obtained through forward slicing; in this embodiment, the problem of inefficient picture display in mobile applications is detected by referring to the summarized anti-pattern of inefficient picture display problem;
[0075] Table 1. Pattern rules for inefficient image display problems
[0076]
[0077]
[0078] Table 1 summarizes seven sets of anti-pattern rules for inefficient image display problems. Each anti-pattern consists of an image decoding API and a program context related to the image decoding API. The API column in the table is the image decoding API related to the inefficient image display problem, and the context column is the code context for determining whether a mobile application has an inefficient image display problem. Taking the image decoding API-context described in the second row (serial number 1) in the table as an example, for any API in the API item, if it is found that the mobile application code involves calling these APIs, and the API has the parameter BitmapFactory.Options, and the parameter meets the conditions described in the context item, then it is reported that the detected mobile application has an inefficient image display problem. If it is found that any API in the API item does not have the parameter BitmapFactory.Options, it is directly reported that the detected mobile application has an inefficient image display problem.
[0079] In this embodiment, the detection rules include but are not limited to:
[0080] First rule: Perform data flow analysis on the Option parameters of the un-downsampled picture decoding API; if it is found that the picture decoding API lacks the Option parameter or it is found that the parameter meets the context conditions listed in Table 1 below, then report the problem of inefficient picture display; here, focus on the parameters for obtaining context information, and perform data flow analysis between processes;
[0081] The second rule and the third rule: Check whether the related methods in the loop body structure and the picture decoding API are reachable in the method call graph; if they are reachable and the analysis shows that there is no data flow relationship between the picture object data returned by the picture decoding API and the picture cache related functions or parameters, then report that there is an inefficient picture display problem; in this embodiment, the data flow relationship includes but is not limited to: LruCache.put and DiskCacheStrategy.All;
[0082] The fourth rule is to decode the image in the UI thread and check the call graph reachability between the image decoding API call and the background thread related method call. If it is not reachable, it will report the problem of inefficient image display; in this embodiment, the background thread related method call includes but is not limited to: Thread.run, AsyncTask.DoInBackground and IntentService.onHandleIntent;
[0083] Rules 5, 6, and 7, which perform uncapped image caching, follow the same pattern, i.e., checking whether a series of specified method calls are reachable in the call graph.
[0084] In this embodiment, for each image decoding API, if its context matches a code anti-pattern rule, an image inefficient display problem warning will be generated. At the same time, the data flow and method call information related to the image decoding API call will also be output to assist mobile application developers in further manual verification of the reported image inefficient display problem.
[0085] S5. Generate a report on inefficient display of images used by public developers.
[0086] In this embodiment, for each detected inefficient display problem of an image, a problem report related to the problem is collated;
[0087] In this embodiment, for each detected image inefficient display problem, the detection result includes but is not limited to: the error type of the image inefficient display problem, the image decoding API and call location related to the image inefficient display problem, and context information of the image inefficient display problem;
[0088] In the detection of the error type of the inefficient image display problem in this embodiment, for each detected inefficient image display problem, the type of anti-pattern to which it belongs will be output, so that it is convenient for developers to diagnose and repair the inefficient image display problem according to the output error type prompt;
[0089] In the detection of the image decoding API and the calling location related to the image inefficient display problem in this embodiment, for each image inefficient display problem, the image decoding API related to the problem and the location of the API in the mobile application source code are reported;
[0090] In the context information detection of the inefficient image display problem in this embodiment, in order to provide more information to assist in diagnosing and repairing the inefficient image display problem, a forward and backward method call chain starting from the statement where the image decoding API is located will also be provided. The aforementioned method call chain information will help users understand the execution logic of the inefficient image display problem at runtime, and help understand and repair the inefficient image display problem.
[0091] Through the above steps, it is possible to implement a systematic detection of the inefficient display problem of images in mobile applications, and the generated detection results can help mobile application developers diagnose and repair the inefficient display problem of images in mobile applications.
[0092] In summary, the present invention analyzes and summarizes the common code patterns of this type of problem, obtains the code features of this type of problem, and then systematically identifies the problem of inefficient image display in mobile applications through systematic code feature analysis.
[0093] Aiming at the problem of inefficient image display in mobile software, the present invention uses a static program analysis method, takes the program statement that calls the image decoding API as the starting point, and uses program slicing technology to obtain program context information related to the image display function, thereby providing a basis for subsequent detection of inefficient image display problems.
[0094] The present invention aims at the problem of inefficient image display in mobile software, systematically summarizes its common problem patterns, and performs feature analysis on the obtained context information related to the image display function based on these problem patterns to achieve accurate detection of such problems.
[0095] The present invention solves the technical problems in the prior art of lacking a systematic feature analysis and summary of the problem of inefficient display of mobile application images, and being unable to detect the problem of inefficient display of mobile application images during mobile application testing.
[0096] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A static detection method for inefficient display of mobile application images, characterized in that: The method comprises: S1. Using the installation file of the mobile application as input data, traversing and scanning the code information of the installation file, identifying and obtaining the local code of the non-third-party library as the developer code; S2. performing a positioning operation on the image decoding API in the developer code to obtain and record a statement for calling the image decoding API; S3. Perform data flow analysis and control flow analysis on each of the statements for calling the picture decoding API to obtain context information related to the picture decoding API; S4, performing a rule matching operation on the image decoding API, the context information, and the image inefficient display problem pattern rule to identify and obtain the image inefficient display problem in the mobile application; S5. For each of the problems of inefficient image display, output anti-pattern category information according to preset anti-patterns of the problem of inefficient image display, and organize problem reports related to the problem accordingly.
2. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: In S1, the local logic code of the mobile application is taken as an analysis object.
3. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: The S2 includes: S21. According to the magic rules for the inefficient display of images in the preset table, the image decoding API listed in the API column is used to scan the codes in the mobile app to obtain all program statements that call the image decoding API.
4. The static detection method for inefficient display of mobile application images according to claim 3 is characterized in that: The S21 includes: S211, traversing the developer code line by line; S212. When a program statement calls the image decoding API in the preset API column, record the current program statement that calls the image decoding API and the specific location information of the program statement in the mobile app as context analysis input data.
5. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: The S3 includes: S31, in the process of obtaining context information related to the image decoding API, performing control flow analysis and data flow analysis on the mobile app; S32. Use statements that are dependent on the picture decoding API program statements as code slices related to the picture decoding API.
6. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: The S4 includes: S41, obtaining an image decoding API-context pair from a preset list to obtain a context in the predefined question information; S42, using the predefined question information, performing the rule matching operation on the picture decoding API and the context information associated with the picture decoding API according to a preset detection rule; S43, using a preset analysis tool to perform code slicing on the mobile application; S44: If the context defined in the picture decoding API-context pair is detected in the code slice, it is determined that the current mobile application has the problem of inefficient picture display.
7. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: In S42, the preset detection rules include: a first rule, a second rule, a third rule, a fourth rule, a fifth rule, a sixth rule and a seventh rule.
8. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: In S43, the preset analysis tools include: Soot program analysis framework.
9. The static detection method for inefficient display of mobile application images according to claim 1 is characterized in that: The S44 includes: S441, comparing the picture decoding API-context pairs in the preset list, checking the call point of the picture decoding API corresponding to each potential problem; S442, for each of the call points, obtain a call graph and a data flow graph of the image display related method parameters through backward slicing; S443. For each of the call points, obtain a call graph and a data flow graph related to the use of the decoded picture object through forward slicing; S444: Detect the image inefficient display problem in the mobile application by referring to a preset anti-pattern of the image inefficient display problem.
10. A static detection system for inefficient display of mobile application images, characterized in that: The system comprises: A developer code identification module is used to use the installation file of the mobile application as input data, traverse and scan the code information of the installation file, identify and obtain the local code of the non-third-party library as the developer code; A picture decoding API positioning module, used for positioning the picture decoding API in the developer code to obtain and record a statement for calling the picture decoding API, wherein the picture decoding API positioning module is connected to the developer code identification module; A context information acquisition module, used for performing data flow analysis and control flow analysis on each of the statements for calling the picture decoding API, and acquiring context information related to the picture decoding API, wherein the context information acquisition module is connected to the picture decoding API positioning module; An image inefficient display problem detection module is used to perform a rule matching operation on the image decoding API, the context information, and the image inefficient display problem pattern rule to identify and obtain the image inefficient display problem in the mobile application, and the image inefficient display problem detection module is connected to the context information acquisition module and the image decoding API positioning module; The image inefficient display problem reporting module is used to output anti-pattern category information for each of the image inefficient display problems according to the preset image inefficient display problem anti-pattern, and to organize problem reports related to the problem. The image inefficient display problem reporting module is connected to the image inefficient display problem detection module.
Citation Information
Patent Citations
Static occupancy picture detection method and device
CN107122247A
Source code static analysis method
CN111240982A
Picture processing method, device and equipment
CN112562024A
Code analysis method and system and readable storage medium
CN117193852A
API Rules Verification Platform
US20140372985A1
