CN109582565A - Prevent the method, terminal and computer storage medium of application crashes - Google Patents

Prevent the method, terminal and computer storage medium of application crashes Download PDF

Info

Publication number
CN109582565A
CN109582565A CN201811281060.XA CN201811281060A CN109582565A CN 109582565 A CN109582565 A CN 109582565A CN 201811281060 A CN201811281060 A CN 201811281060A CN 109582565 A CN109582565 A CN 109582565A
Authority
CN
China
Prior art keywords
function
main thread
view
application crashes
preset mark
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811281060.XA
Other languages
Chinese (zh)
Inventor
廖松茂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nubia Technology Co Ltd
Original Assignee
Nubia Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nubia Technology Co Ltd filed Critical Nubia Technology Co Ltd
Priority to CN201811281060.XA priority Critical patent/CN109582565A/en
Publication of CN109582565A publication Critical patent/CN109582565A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of method for preventing application crashes, terminal and computer storage mediums, by calling the function of each UI view of application to be tested;In test, main thread differentiation is carried out to the function of each UI view;When testing out a certain function and belonging to non-master threading operation, it is corresponding abnormal to record the function;By the exception throws recorded in test process to generate prompting message.In this way, in the test process of development phase, the method (i.e. function) for finding out which view of engineer couple has carried out non-master threading operation, and then the corresponding abnormity prompt engineer that dishes out, engineer is allowed to be clearly visible the illegal operation for oneself having carried out updating UI in sub thread, so that operation can be modified to main thread according to the prompt by engineer, the working efficiency and program stability of engineer the case where avoiding the occurrence of ncrash collapse, are improved with this.

Description

Prevent the method, terminal and computer storage medium of application crashes
Technical field
The present invention relates to fields of communication technology, more specifically to a kind of method for preventing application crashes, terminal and meter Calculation machine storage medium.
Background technique
There is a kind of ncrash (native in the recent period in Android (Android) app (Application, application program) Crash is a kind of C or C++ layers of collapse) collapse, this ncrash will lead to program crashing, and be different from common java's When crash (collapse), ncrash are generated, the crash of log (log) without image of Buddha java equally has apparent storehouse positioning can be very Smoothly navigate to the specifically code of program which lead to crash.That is ncrash can not position the obvious of specific crash Execution stack, and then it is very difficult to cause the later period to be repaired.By a large amount of practical investigation discoveries, the appearance of ncrash mainly due to In some sub threads of java, to the certain methods of view (view), (in actual operation, method corresponds to Developmental Engineer Function is realized by function) it is operated, and these are really illegal to the operation of sub thread, so as to cause ncrash Appearance.
Summary of the invention
The technical problem to be solved in the present invention is that: the collapse (ncrash) of C or C++ layers occurred at present can not position tool The obvious execution stack of body crash, and then it is very difficult to cause the later period to be repaired, and endangers larger.For the technical problem, the present invention A kind of method preventing application crashes, terminal and computer storage medium are provided.
In order to solve the above technical problems, the present invention provides a kind of method for preventing application crashes, it is described to prevent application crashes Method include:
The function of each user interface UI view of application is called to be tested;
In test, main thread differentiation is carried out to the function of each UI view;
When testing out a certain function and belonging to non-master threading operation, it is corresponding abnormal to record the function;
By the exception throws recorded in test process to generate prompting message.
Optionally, the corresponding exception of the function that records includes:
It is corresponding abnormal that the function is recorded in journal file.
Optionally, the exception throws that will be recorded in test process include: to generate prompting message
After being completed, by this test in all abnormal are packaged for recording dish out, to generate prompting message.
Optionally, before the function of each UI view for calling application is tested, further includes:
The function of UI view is counted;
Find out the function for not carrying out main thread operation;
Preset mark is added in the function for not carrying out main thread operation;
The function to each UI view carries out main thread differentiation
Main thread differentiation is carried out according to function of the preset mark to each UI view.
Optionally, described to include: to the function progress main thread differentiation of each UI view according to the preset mark
It detects in the function of each UI view of the application with the presence or absence of preset mark;If it exists, then determine currently to be sentenced Other function belongs to non-master threading operation;Otherwise, it determines determining that the function currently differentiated belongs to main thread operation.
Optionally, the preset mark of adding in the function for not carrying out main thread operation includes:
Pre-set code is added in the function for not carrying out main thread operation.
Optionally, described to include: to the function progress main thread differentiation of each UI view according to the preset mark
In test, if the pre-set code is performed, the implementing result of the pre-set code is that prompt is abnormal.
Optionally, it is described in the function for not carrying out main thread operation add preset mark after, further includes:
The function of the addition preset mark is saved in database;Or by the preset mark of addition and the function Corresponding relationship be saved in database.
Further, the present invention also provides a kind of terminal, the terminal includes processor, memory and communication bus;
The communication bus is for realizing the connection communication between processor and memory;
The processor is for executing one or more program stored in memory, to realize above-mentioned prevent using collapsing The step of routed method.
Further, the present invention also provides a kind of computer storage medium, the computer storage medium is stored with one A or multiple programs, one or more of programs can be executed by one or more processor, to realize above-mentioned prevent The step of method of application crashes.
Beneficial effect
The method for preventing application crashes, terminal and computer storage medium provided by the invention, for appearance at present C or C++ layers of collapse (ncrash) the obvious execution stack of specific crash can not be positioned, and then cause the later period repair very Difficulty endangers larger technical problem, by calling the function of each user interface UI view of application to be tested;It is testing When, main thread differentiation is carried out to the function of each UI view;When testing out a certain function and belonging to non-master threading operation, the letter is recorded Number is corresponding abnormal;By the exception throws recorded in test process to generate prompting message.In this way, in the test process of development phase In, that is, the method (i.e. function) for finding out which view of engineer couple has carried out non-master threading operation, and then it is corresponding different to dish out Engineer is often reminded, engineer is allowed to be clearly visible the illegal operation for oneself having carried out updating UI in sub thread, so that Operation can be modified to main thread according to the prompt by engineer, be avoided the occurrence of with this since engineer is accidentally in sub thread The case where updating UI, and then leading to be difficult to the appearance of ncrash collapse of analyzing and positioning, improve engineer working efficiency and Program stability.
Detailed description of the invention
Present invention will be further explained below with reference to the attached drawings and examples, in attached drawing:
The hardware structural diagram of Fig. 1 optional terminal of each embodiment to realize the present invention;
A kind of optional communications network system architecture diagram of Fig. 2 each embodiment to realize the present invention;
Fig. 3 is that a kind of basic procedure for preventing the method for application crashes for transmitting terminal that first embodiment of the invention provides shows It is intended to;
Fig. 4 is the interactive intention of a kind of test equipment and development equipment that first embodiment of the invention provides;
Fig. 5 is a kind of structural schematic diagram for terminal that third embodiment of the invention provides.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
In subsequent description, it is only using the suffix for indicating such as " module ", " component " or " unit " of element Be conducive to explanation of the invention, itself there is no a specific meaning.Therefore, " module ", " component " or " unit " can mix Ground uses.
Terminal can be implemented in a variety of manners.For example, terminal described in the present invention may include such as with bending Mobile phone, tablet computer, laptop, palm PC, personal digital assistant (the Personal Digital of function Assistant, PDA), portable media player (Portable Media Player, PMP), navigation device, wearable set The fixed terminals such as the mobile terminals such as standby, Intelligent bracelet, pedometer, and number TV, desktop computer.
It will be illustrated by taking mobile terminal as an example in subsequent descriptions, it will be appreciated by those skilled in the art that in addition to special Except element for moving purpose, the construction of embodiment according to the present invention can also apply to the terminal of fixed type.
Referring to Fig. 1, a kind of hardware structural diagram of its mobile terminal of each embodiment to realize the present invention, the shifting Dynamic terminal 100 may include: RF (Radio Frequency, radio frequency) unit 101, WiFi module 102, audio output unit 103, A/V (audio/video) input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, the components such as memory 109, processor 110 and power supply 111.It will be understood by those skilled in the art that shown in Fig. 1 Mobile terminal structure does not constitute the restriction to mobile terminal, and mobile terminal may include components more more or fewer than diagram, Perhaps certain components or different component layouts are combined.
It is specifically introduced below with reference to all parts of the Fig. 1 to mobile terminal:
Radio frequency unit 101 can be used for receiving and sending messages or communication process in, signal sends and receivees, specifically, by base station Downlink information receive after, to processor 110 handle;In addition, the data of uplink are sent to base station.In general, radio frequency unit 101 Including but not limited to antenna, at least one amplifier, transceiver, coupler, low-noise amplifier, duplexer etc..In addition, penetrating Frequency unit 101 can also be communicated with network and other equipment by wireless communication.Any communication can be used in above-mentioned wireless communication Standard or agreement, including but not limited to GSM (Global System of Mobile communication, global system for mobile telecommunications System), GPRS (General Packet Radio Service, general packet radio service), CDMA2000 (Code Division Multiple Access 2000, CDMA 2000), WCDMA (Wideband Code Division Multiple Access, wideband code division multiple access), TD-SCDMA (Time Division-Synchronous Code Division Multiple Access, TD SDMA), FDD-LTE (Frequency Division Duplexing-Long Term Evolution, frequency division duplex long term evolution) and TDD-LTE (Time Division Duplexing-Long Term Evolution, time division duplex long term evolution) etc..
WiFi belongs to short range wireless transmission technology, and mobile terminal can help user to receive and dispatch electricity by WiFi module 102 Sub- mail, browsing webpage and access streaming video etc., it provides wireless broadband internet access for user.Although Fig. 1 shows Go out WiFi module 102, but it is understood that, and it is not belonging to must be configured into for mobile terminal, it completely can be according to need It to omit within the scope of not changing the essence of the invention.
Audio output unit 103 can be in call signal reception pattern, call mode, record mould in mobile terminal 100 When under the isotypes such as formula, speech recognition mode, broadcast reception mode, by radio frequency unit 101 or WiFi module 102 it is received or The audio data stored in memory 109 is converted into audio signal and exports to be sound.Moreover, audio output unit 103 Audio output relevant to the specific function that mobile terminal 100 executes can also be provided (for example, call signal receives sound, disappears Breath receives sound etc.).Audio output unit 103 may include loudspeaker, buzzer etc..
A/V input unit 104 is for receiving audio or video signal.A/V input unit 104 may include graphics processor (Graphics Processing Unit, GPU) 1041 and microphone 1042, graphics processor 1041 is in video acquisition mode Or the image data of the static images or video obtained in image capture mode by image capture apparatus (such as camera) carries out Reason.Treated, and picture frame may be displayed on display unit 106.Through graphics processor 1041, treated that picture frame can be deposited Storage is sent out in memory 109 (or other computer storage mediums) or via radio frequency unit 101 or WiFi module 102 It send.Microphone 1042 can be in telephone calling model, logging mode, speech recognition mode etc. operational mode via microphone 1042 receive sound (audio data), and can be audio data by such acoustic processing.Audio that treated (voice) Data can be converted to the format that mobile communication base station can be sent to via radio frequency unit 101 in the case where telephone calling model Output.Microphone 1042 can be implemented various types of noises and eliminate (or inhibition) algorithm to eliminate (or inhibition) and receive and sending out The noise generated during sending audio signal or interference.
Mobile terminal 100 further includes at least one sensor 105, such as optical sensor, motion sensor and other biographies Sensor.Specifically, optical sensor includes ambient light sensor and proximity sensor, wherein ambient light sensor can be according to environment The light and shade of light adjusts the brightness of display panel 1061, and proximity sensor can close when mobile terminal 100 is moved in one's ear Display panel 1061 and/or backlight.As a kind of motion sensor, accelerometer sensor can detect in all directions (general For three axis) size of acceleration, it can detect that size and the direction of gravity when static, can be used to identify the application of mobile phone posture (such as horizontal/vertical screen switching, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, percussion) etc.; The fingerprint sensor that can also configure as mobile phone, pressure sensor, iris sensor, molecule sensor, gyroscope, barometer, The other sensors such as hygrometer, thermometer, infrared sensor, details are not described herein.
Display unit 106 is for showing information input by user or being supplied to the information of user.Display unit 106 can wrap Display panel 1061 is included, liquid crystal display (LiqUId Crystal Display, LCD), Organic Light Emitting Diode can be used Forms such as (Organic Light-Emitting Diode, OLED) configure display panel 1061.
User input unit 107 can be used for receiving the number or character information of input, and generate the use with mobile terminal Family setting and the related key signals input of function control.Specifically, user input unit 107 may include touch panel 1071 with And other input equipments 1072.Touch panel 1071, also referred to as touch screen collect the touch operation of user on it or nearby (for example user uses any suitable objects or attachment such as finger, stylus on touch panel 1071 or in touch panel 1071 Neighbouring operation), and corresponding attachment device is driven according to preset formula.Touch panel 1071 may include touch detection Two parts of device and touch controller.Wherein, the touch orientation of touch detecting apparatus detection user, and detect touch operation band The signal come, transmits a signal to touch controller;Touch controller receives touch information from touch detecting apparatus, and by it It is converted into contact coordinate, then gives processor 110, and order that processor 110 is sent can be received and executed.In addition, can To realize touch panel 1071 using multiple types such as resistance-type, condenser type, infrared ray and surface acoustic waves.In addition to touch panel 1071, user input unit 107 can also include other input equipments 1072.Specifically, other input equipments 1072 can wrap It includes but is not limited in physical keyboard, function key (such as volume control button, switch key etc.), trace ball, mouse, operating stick etc. It is one or more, specifically herein without limitation.
Further, touch panel 1071 can cover display panel 1061, when touch panel 1071 detect on it or After neighbouring touch operation, processor 110 is sent to determine the type of touch event, is followed by subsequent processing device 110 according to touch thing The type of part provides corresponding visual output on display panel 1061.Although in Fig. 1, touch panel 1071 and display panel 1061 be the function that outputs and inputs of realizing mobile terminal as two independent components, but in certain embodiments, it can The function that outputs and inputs of mobile terminal is realized so that touch panel 1071 and display panel 1061 is integrated, is not done herein specifically It limits.
Interface unit 108 be used as at least one external device (ED) connect with mobile terminal 100 can by interface.For example, External device (ED) may include wired or wireless headphone port, external power supply (or battery charger) port, wired or nothing Line data port, memory card port, the port for connecting the device with identification module, audio input/output (I/O) end Mouth, video i/o port, ear port etc..Interface unit 108 can be used for receiving the input from external device (ED) (for example, number It is believed that breath, electric power etc.) and the input received is transferred to one or more elements in mobile terminal 100 or can be with For transmitting data between mobile terminal 100 and external device (ED).
Memory 109 can be used for storing software program and various data.Memory 109 can mainly include storing program area The storage data area and, wherein storing program area can (such as the sound of application program needed for storage program area, at least one function Sound playing function, image player function etc.) etc.;Storage data area can store according to mobile phone use created data (such as Audio data, phone directory etc.) etc..In addition, memory 109 may include high-speed random access memory, it can also include non-easy The property lost memory, a for example, at least disk memory, flush memory device or other volatile solid-state parts.
Processor 110 is the control centre of mobile terminal, utilizes each of various interfaces and the entire mobile terminal of connection A part by running or execute the software program and/or module that are stored in memory 109, and calls and is stored in storage Data in device 109 execute the various functions and processing data of mobile terminal, to carry out integral monitoring to mobile terminal.Place Managing device 110 may include one or more processing units;Preferably, processor 110 can integrate application processor and modulatedemodulate is mediated Manage device, wherein the main processing operation system of application processor, user interface and application program etc., modem processor is main Processing wireless communication.It is understood that above-mentioned modem processor can not also be integrated into processor 110.
Mobile terminal 100 can also include the power supply 111 (such as battery) powered to all parts, it is preferred that power supply 111 Can be logically contiguous by power-supply management system and processor 110, to realize management charging by power-supply management system, put The functions such as electricity and power managed.
Although Fig. 1 is not shown, mobile terminal 100 further includes bluetooth module, and details are not described herein.
Referring to Fig. 2, Fig. 2 is a kind of communications network system architecture diagram provided in an embodiment of the present invention, the communication network system System is the LTE system of universal mobile communications technology, which includes UE (User EqUIpment, the use of successively communication connection Family equipment) (the land Evolved UMTS Terrestrial Radio Access Network, evolved UMTS 201, E-UTRAN Ground wireless access network) 202, EPC (Evolved Packet Core, evolved packet-based core networks) 203 and operator IP operation 204。
Specifically, UE201 can be above-mentioned terminal 100, and details are not described herein again.
E-UTRAN202 includes eNodeB2021 and other eNodeB2022 etc..Wherein, eNodeB2021 can be by returning Journey (backhaul) (such as X2 interface) is connect with other eNodeB2022, and eNodeB2021 is connected to EPC203, ENodeB2021 can provide the access of UE201 to EPC203.
EPC203 may include MME (Mobility Management Entity, mobility management entity) 2031, HSS (Home Subscriber Server, home subscriber terminal) 2032, other MME2033, SGW (Serving Gate Way, clothes Business gateway) 2034, PGW (PDN Gate Way, grouped data network gateway) 2035 and PCRF (Policy and Charging Rules Function, policy and rate functional entity) 2036 etc..Wherein, MME2031 is between processing UE201 and EPC203 The control node of signaling, provides carrying and connection management.HSS2032 is for providing some registers to manage such as homing position The function of register (not shown) etc, and preserve the dedicated letters of users such as some related service features, data rates Breath.All customer data can be sent by SGW2034, PGW2035 can provide UE 201 IP address distribution with And other functions, PCRF2036 are the strategy and charging control policy decision point of business data flow and IP bearing resource, it is plan Available strategy and charging control decision are slightly selected and provided with charge execution function unit (not shown).
IP operation 204 may include internet, Intranet, IMS (IP Multimedia Subsystem, IP multimedia System) or other IP operations etc..
Although above-mentioned be described by taking LTE system as an example, those skilled in the art should know the present invention is not only Suitable for LTE system, be readily applicable to other wireless communication systems, such as GSM, CDMA2000, WCDMA, TD-SCDMA with And the following new network system etc., herein without limitation.
Based on above-mentioned mobile terminal hardware configuration and communications network system, each embodiment of the method for the present invention is proposed.
First embodiment
The obvious execution stack of specific crash can not be positioned for the collapse (ncrash) of C or C++ layers occurred at present, And then it is very difficult to cause the later period to be repaired, and endangers larger technical problem, present embodiments provides a kind of application crashes that prevent Method.Shown in Figure 3, Fig. 3 is a kind of basic procedure schematic diagram for the method for preventing application crashes provided in this embodiment, packet It includes:
S301: the function of each UI (User Interface, user interface) view of application is called to be tested;
It should be noted that often relating to need in application initial development and later maintenance or new version development process Will to view each in UI method (in actual operation, method i.e. correspond to function, realized by function) operated, the operation For Developmental Engineer, what is be allowed to is operated in main thread, but in practical projects, Developmental Engineer is past It is careless or the case where accidentally carried out operation in sub thread toward being likely to occur, and the operation that these are carried out in sub thread Essence be it is illegal, may result in the appearance of C or C++ layers of collapse (i.e. ncrash).It should be noted ncrash Although appearance be caused by the operation carried out in sub thread Developmental Engineer, and it is not all in sub thread The operation of middle progress inevitably results in the appearance of ncrash, i.e., the appearance of ncrash is sporadic, rather than must show.
It should be understood that in order to control and guarantee product quality, in application initial development and later maintenance or new version It often can all be tested in development process, to find the various defects of product, and supervise corrective pitting.In the present embodiment, The illegal operation that Developmental Engineer carries out in sub thread can be found in test phase, so that Developmental Engineer be supervised to repair Change, to prevent the appearance of ncrash from the root.
S302: in test, main thread differentiation is carried out to the function of each UI view;
During the test, it would be desirable to which the method (function of i.e. each UI view) of each view in the UI of application is surveyed Examination.When test, can method to each view whether be that the main thread operation carried out judges, and then determines that Developmental Engineer is The no illegal operation being had in sub thread.
In the present embodiment, test when can it is conventional using Looper class by way of, using by checking The mode of the current thread of Thread class or the thread that the function currently tested is judged using the mode that thread handle judges are No is main thread.For using the mode of Looper class, can by with code Looper.myLooper ()!= Looper.getMainLooper () similar code is realized;For using the current thread by checking Thread class For mode, can by with code Thread.currentThread ()==Looper.getMainLooper () .getThread () similar code is realized;It, can be in advance by main line for the mode for using thread handle to judge The Thread.currentThread () of journey gets the current handle of main thread, saves, calling when needing to judge Thread.currentThread () compares therewith, that is, can determine whether current thread is main thread.
In the present embodiment, it can not also be realized through the above way when test.Specifically, can be regarded in advance in each UI Mark is arranged not in the function that main thread is operated by all in the function of figure, so in test by the mark come pair The function of each UI view carries out main thread differentiation.I.e. in the present embodiment, in step S301: calling the letter of each UI view of application It can also include: to be counted to the function of each UI view, and then find out and do not carry out main thread operation before number is tested Function, then preset mark is added in the function for not carrying out main thread operation.Main line is carried out in the function to each UI view in this way When journey differentiates, main thread differentiation can be carried out according to function of the preset mark to each UI view.
It should be noted that the certain methods (i.e. function) itself for view will grasp main thread in system code Judged as UI, and having certain methods then does not have, such as setScale this, it is therefore desirable to all meetings to view control The function for being related to UI is all counted, do not have in code carry out main thread operation method find out.
It should be noted that in the present embodiment, carrying out main thread differentiation according to function of the preset mark to each UI view It specifically may is that in the function of each UI view of detection application with the presence or absence of preset mark;If it exists, then determine currently to be differentiated Function belong to non-master threading operation;Otherwise, it determines determining that the function currently differentiated belongs to main thread operation.It should be understood that It is that can be in the function of each UI view of aforementioned detection application with the presence or absence of preset mark and executing the test to current function It is preceding that detection is just first marked, but be also possible in executing the test process to current function, the function of execution is carried out Label detection.
Especially, it should be noted that preset mark can be in a kind of feasible specific embodiment of the present embodiment Pre-set code.And in the case where not carrying out adding pre-set code in the function of main thread operation, it can be set in the present embodiment Pre-set code is the code that reports an error, and is differentiated to be performed the realization that directly reports an error in code.I.e. such situation is in test, if working as Pre-set code in preceding function is performed, then the implementing result of the pre-set code is that prompt is abnormal, to be directly realized by each UI The function of view carries out main thread differentiation.
In the present embodiment, it after adding preset mark in the function for not carrying out main thread operation, can also will add The function of preset mark is saved in database;Or the corresponding relationship of the preset mark of addition and the function is saved in database In.It should be understood that may have found that certain bug (loophole) needs in actual use due to after initial development Later maintenance or update are wanted, or needs to be updated application version according to actual operation, then in these later maintenance Or it when update, is actually developed engineer and needs to modify on the basis of original function, then at this time can be straight It connects and the corresponding preset mark of function for pre-saving each UI view in the application in the database is called to be added.
It should be understood that the scheme in above-mentioned addition database is more suitable for, there are the feelings of multiple and different preset marks Condition.In fact, preset mark can also only be arranged one in the present embodiment, i.e., identical pre- bidding is added to all functions Note, such benefit is that workload is smaller for test equipment, while being also more convenient for managing.
S303: when testing out a certain function and belonging to non-master threading operation, it is corresponding abnormal to record the function;
In the present embodiment, when testing out a certain function and belonging to non-master threading operation, the function is corresponding abnormal, the exception It can recorde in journal file.
S304: by the exception throws recorded in test process to generate prompting message.
It in the present embodiment, can be after testing out an exception, i.e., by the exception throws, it can testing out one The exception of dishing out after exception simultaneously generates the corresponding prompting message of the exception.But it can also after testing, by this All exceptions in test are packaged together dishes out, it can after being completed together by all exceptions in this test process Packing dishes out and generates a prompting message together.It should be understood that the terminal and work tested in the present embodiment The terminal for the operation that Cheng Shi is used to carry out function can be same terminal, but usually all be different terminal, such as shown in Fig. 4, Therefore the exception throws recorded in test process are usually tested to terminal 1 in the present embodiment different by what is recorded in test process Utility Engineers are often sent in the terminal 2 for the operation for carrying out function.
It should be understood that each step of the above-mentioned method for preventing application crashes can be by terminal 100 as shown in Figure 1 Independently to realize.Specifically, one or more programs of above-mentioned each step can be realized by storing in memory 109, The program is executed by processor 110, to realize each step of the above-mentioned method for preventing application crashes.Furthermore, it is necessary to pay attention to , the function of each user interface UI view of application is called to need to obtain the letter of each user interface UI view when being tested Number, the process of the acquisition data and after being completed by by the exception recorded in test process be sent to Utility Engineers in into The process of the terminal of the operation of line function can be through communications network system as shown in Figure 2 and realize.
It should be noted that the method for preventing application crashes provided in the present embodiment can be adapted for any be equipped with In the terminal of Android system, but also it is not excluded for can be applied to using on other such as terminal of IOS system.
The method provided in this embodiment for preventing application crashes, the function of each user interface UI view by calling application It is tested;In test, main thread differentiation is carried out to the function of each UI view;Belong to non-main thread testing out a certain function When operation, it is corresponding abnormal to record the function;By the exception throws recorded in test process to generate prompting message.In this way, opening In the test process in hair stage, that is, the method (i.e. function) for finding out which view of engineer couple has carried out non-master threading operation, And then the corresponding abnormity prompt engineer that dishes out, it allows engineer to be clearly visible and oneself has carried out updating the non-of UI in sub thread Method operation is avoided the occurrence of due to engineering with this so that operation can be modified to main thread according to the prompt by engineer Teacher accidentally updates UI in sub thread, and then the case where lead to be difficult to the appearance of ncrash collapse of analyzing and positioning, improves work The working efficiency and program stability of Cheng Shi.
Second embodiment
The present embodiment prevents the process from being on the basis of first embodiment, with a kind of C or C++ layers more specific of collapse Example, is illustrated mode of the invention.It is specific:
1, some classification are carried out to the method for view.
Main thread operation UI is judged because certain methods of view itself just have in system code, and has one A little methods do not have then, such as setScale this, need that all counting for UI can be related to all of view control, code In do not have main thread operate method find out.
2, Hook mechanism is introduced in our app, Hook mechanism is that one of android can cut method It obtains, then can add the code of oneself some program.
Due to the method that we have come out the operation UI that those do not carry out main thread judgement in step 1, because We can carry out successively hook to them for this, execute the judgement of main thread in corresponding before when hook, once Detect that current thread belongs to non-main thread, then program can dish out corresponding abnormity prompt Developmental Engineer, allow Developmental Engineer It is clearly visible this illegal operation for oneself having carried out updating UI in sub thread, so that Developmental Engineer can will be non- Method operation is modified to main thread, causes to be difficult to analyzing and positioning to avoid exploitation from accidentally updating UI by sub thread with this The appearance for the case where ncrash collapses directly fundamentally prevents occasionally existing ncrash as that must be handled first The possibility that ncrash occurs, the working efficiency and program for improving exploitation are stablized.
3rd embodiment
A kind of terminal is present embodiments provided, it is shown in Figure 5 comprising processor 501, memory 502 and communication Bus 503.Wherein:
Communication bus 503 is for realizing the connection communication between processor 501 and memory 502.
Processor 501 is for executing the one or more programs stored in memory 502, to realize above-mentioned first embodiment And/or each step of the method for application crashes is prevented in second embodiment.
It should be noted that terminal provided in the present embodiment can be any terminal for being equipped with Android system, but It is also to be not excluded for can be the terminal for being equipped with other systems.
The present embodiment provides a kind of computer storage medium, as floppy disk, CD, hard disk, flash memory, USB flash disk, CF card, SD card, Mmc card etc. is stored with one or more program for realizing above-mentioned each step in the computer storage medium, this or The multiple programs of person can be executed by one or more processor, be prevented with realizing in above-mentioned first embodiment and/or second embodiment Only each step of the method for application crashes.Details are not described herein.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or device.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a computer storage In medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal (can be mobile phone, computer is whole End, air conditioner or the network equipment etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much Form, all of these belong to the protection of the present invention.

Claims (10)

1. a kind of method for preventing application crashes, which is characterized in that the method for preventing application crashes includes:
The function of each user interface UI view of application is called to be tested;
In test, main thread differentiation is carried out to the function of each UI view;
When testing out a certain function and belonging to non-master threading operation, it is corresponding abnormal to record the function;
By the exception throws recorded in test process to generate prompting message.
2. the method for preventing application crashes as described in claim 1, which is characterized in that described to record the corresponding abnormal packet of the function It includes:
It is corresponding abnormal that the function is recorded in journal file.
3. the method for preventing application crashes as described in claim 1, which is characterized in that described different by what is recorded in test process Often dish out to generate prompting message and include:
After being completed, by this test in all abnormal are packaged for recording dish out, to generate prompting message.
4. the method as described in any one of claims 1-3 for preventing application crashes, which is characterized in that in the calling application Before the function of each UI view is tested, further includes:
The function of UI view is counted;
Find out the function for not carrying out main thread operation;
Preset mark is added in the function for not carrying out main thread operation;
The function to each UI view carries out main thread differentiation
Main thread differentiation is carried out according to function of the preset mark to each UI view.
5. as claimed in claim 4 prevent application crashes method, which is characterized in that it is described according to the preset mark to each The function of UI view carries out main thread differentiation
It detects in the function of each UI view of the application with the presence or absence of preset mark;If it exists, then determine currently to be differentiated Function belongs to non-master threading operation;Otherwise, it determines determining that the function currently differentiated belongs to main thread operation.
6. the method for preventing application crashes as claimed in claim 4, which is characterized in that described not carry out main thread behaviour described Preset mark is added in the function of work includes:
Pre-set code is added in the function for not carrying out main thread operation.
7. as claimed in claim 6 prevent application crashes method, which is characterized in that it is described according to the preset mark to each The function of UI view carries out main thread differentiation
In test, if the pre-set code is performed, the implementing result of the pre-set code is that prompt is abnormal.
8. the method for preventing application crashes as claimed in claim 4, which is characterized in that described not carry out main thread behaviour described In the function of work after addition preset mark, further includes:
The function of the addition preset mark is saved in database;Or by pair of the preset mark of addition and the function It should be related to and be saved in database.
9. a kind of terminal, which is characterized in that the terminal includes processor, memory and communication bus;
The communication bus is for realizing the connection communication between processor and memory;
The processor is for executing one or more program stored in memory, to realize as appointed in claim 1 to 8 The step of preventing the method for application crashes described in one.
10. a kind of computer storage medium, which is characterized in that the computer storage medium is stored with one or more journey Sequence, one or more of programs can be executed by one or more processor, to realize as any in claim 1 to 8 The step of method for preventing application crashes described in item.
CN201811281060.XA 2018-10-30 2018-10-30 Prevent the method, terminal and computer storage medium of application crashes Pending CN109582565A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811281060.XA CN109582565A (en) 2018-10-30 2018-10-30 Prevent the method, terminal and computer storage medium of application crashes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811281060.XA CN109582565A (en) 2018-10-30 2018-10-30 Prevent the method, terminal and computer storage medium of application crashes

Publications (1)

Publication Number Publication Date
CN109582565A true CN109582565A (en) 2019-04-05

Family

ID=65921339

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811281060.XA Pending CN109582565A (en) 2018-10-30 2018-10-30 Prevent the method, terminal and computer storage medium of application crashes

Country Status (1)

Country Link
CN (1) CN109582565A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175105A (en) * 2019-05-14 2019-08-27 维沃移动通信有限公司 A kind of collapse reminding method and terminal
CN113806189A (en) * 2020-06-16 2021-12-17 北京字节跳动网络技术有限公司 User interface operation monitoring method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110283262A1 (en) * 2010-05-11 2011-11-17 Luis Ceze Enhanced reliability using deterministic multiprocessing-based synchronized replication
US20140208083A1 (en) * 2013-01-18 2014-07-24 Morgan Stanley Multi-threaded logging
CN107967176A (en) * 2017-11-22 2018-04-27 郑州云海信息技术有限公司 A kind of Samba multi-threaded architectures abnormality eliminating method and relevant apparatus
CN108595236A (en) * 2018-03-27 2018-09-28 五八有限公司 A kind of method and device for preventing sub-line journey from carrying out operating user interface

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110283262A1 (en) * 2010-05-11 2011-11-17 Luis Ceze Enhanced reliability using deterministic multiprocessing-based synchronized replication
US20140208083A1 (en) * 2013-01-18 2014-07-24 Morgan Stanley Multi-threaded logging
CN107967176A (en) * 2017-11-22 2018-04-27 郑州云海信息技术有限公司 A kind of Samba multi-threaded architectures abnormality eliminating method and relevant apparatus
CN108595236A (en) * 2018-03-27 2018-09-28 五八有限公司 A kind of method and device for preventing sub-line journey from carrying out operating user interface

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175105A (en) * 2019-05-14 2019-08-27 维沃移动通信有限公司 A kind of collapse reminding method and terminal
CN113806189A (en) * 2020-06-16 2021-12-17 北京字节跳动网络技术有限公司 User interface operation monitoring method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109542689A (en) Applied program processing method, terminal and computer readable storage medium
CN109697010A (en) A kind of suspended window position control method, terminal and computer readable storage medium
CN109040441A (en) Using display methods of attending to anything else, mobile terminal and computer readable storage medium
CN108920306A (en) What is managed based on memory restarts localization method, mobile terminal and readable storage medium storing program for executing
CN109766080A (en) Micro services register method, device, electronic equipment and readable storage medium storing program for executing
CN110187808A (en) Dynamic wallpaper setting method, device and computer readable storage medium
CN110096213A (en) Terminal operation method, mobile terminal and readable storage medium storing program for executing based on gesture
CN110418004A (en) Screenshot processing method, terminal and computer readable storage medium
CN109582565A (en) Prevent the method, terminal and computer storage medium of application crashes
CN109725976A (en) A kind of display interface method for refreshing, mobile terminal and storage medium
CN108549587A (en) display module monitoring method, mobile terminal and computer readable storage medium
CN109739517A (en) Printed circuit board, terminal, firmware burning method and readable storage medium storing program for executing
CN109947519A (en) Hardware-accelerated control method, terminal and computer readable storage medium
CN110187934A (en) Application control method, terminal and computer readable storage medium
CN110096173A (en) Method for controlling mobile terminal, mobile terminal and computer readable storage medium
CN108833687A (en) Terminal prot open method, terminal and computer readable storage medium
CN110007817A (en) A kind of message treatment method and mobile terminal, computer readable storage medium
CN109714460A (en) Press key expansion device, terminal, key expansion method and storage medium
CN109683741A (en) Function triggering method, device and computer readable storage medium
CN109032621A (en) A kind of application program installation method, mobile terminal and computer storage medium
CN109739676A (en) A kind of operational monitoring method, mobile terminal and computer readable storage medium
CN110147291A (en) Terminal and its log management-control method, computer readable storage medium
CN110384928A (en) Consumer behavior monitoring method, terminal and computer readable storage medium in game
CN110069291A (en) A kind of display control method, mobile terminal and computer readable storage medium
CN109408184A (en) A kind of icon processing method, mobile terminal and computer storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20190405

RJ01 Rejection of invention patent application after publication