Profiling / Debugging assist tools for iOS. (Memory Leak, OOM, ANR, Hard Stalling, Network, OpenGL, Time Profile ...)

Overview

MTHawkeye

Platform License PRs Welcome Version CI

Readme 中文版本

MTHawkeye is profiling, debugging tools for iOS used in Meitu. It's designed to help iOS developers improve development productivity and assist in optimizing the App performance.

During the App product development cycle, we introduced MTHawkeye to help us discover, find, analyze, locate, and solve problems faster.

  • Development phase, focusing on development and debugging assistance, detect problems in a timely manner, and prompt developers to deal with them.
  • Test phase, focusing on collecting performance data as much as possible from the test case, for generating automated test analysis reports.
  • Online phase, focusing on performance data that needs by our own business but missing from third party APM components.

MTHawkeye has built-in some common performance detection plug-ins. It also introduces and improves FLEX as a plug-in for debugging assistance. When you use MTHawkeye, you can customize and add the plug-ins you need.

The following are demo diagrams of some built-in plugins for View time-consuming methods on main Thread, View App memory allocations details, View network transaction records. See the post for more plugin instructions.

0x00 Features

MTHawkeye can be divided into upper, middle and lower layers. In addition to the bottom Base layer, the middle is the UI Skeleton and Desktop Adaptor, the uppermost plug-ins are internally split according to different scenarios. You can optionally add these plugins to your own scenario. The overall structure is as follows:

MTHawkeye overall structure

Base Feature

The Base layer mainly provides plugin management capabilities, storage API and util classes.

UI Skeleton provides an interface interaction framework for the development and testing phase. It includes a floating window, the main panels frame, and a setting panel, all of which can be modified, and the plug-in can integrate the interface interaction.

Optional plugins

The built-in plugins are divided into Memory, TimeConsuming, Energy, Network, Graphics, Storage, Utility according to the focus points.

Memory

# LivingObjectSniffer

LivingObjectSniffer is mainly used to track and observe objects directly or indirectly held by ViewController, as well as custom View objects. Detects whether these objects are unexpected alive, which may cause by leaks, not released in time, or unnecessary memory buffers.

In the development and testing phase, the detected unexpected alive objects can be prompted to the developer in the form of floating windows flash warning or toast.

In the automated test, the recorded unexpected alive objects can also be extracted for the further memory usage analysis.

# Allocations

Allocations is similar to the Instrument's Allocations module, It tracks the memory details actually allocated by the application. When the application memory usage is abnormal (abnormal rise, OOM exit), the recorded memory allocation details can be used to analyze specific memory usage issues.

TimeConsuming

# UITimeProfiler

UITimeProfiler is used to assist in optimizing the time-consuming tasks of the main thread.

The data collection part mainly includes two components, VC Life Trace and ObjC CallTrace. VC Life Trace tracking the time of each key node when opening ViewController, and when ObjC CallTrace is turned on, it can track Objective-C methods that are executed on the main thread and take longer than the specified threshold.

The interface layer part combines the two parts of data to make it easier for developers to find out the time-consuming details of the operations they are focusing on. The example diagram is as shown in the previous section, for a more detailed description, see the UITimeProfiler plugin documentation.

After enabling the plug-in on the automated test or online phase, without other code, you can continuously automate tracking the startup, page open, and other critical processes time-consuming.

# ANRTrace

ANRTrace is used to capture the stuck event, and will sample the main thread stack frame when the jam occurs.

# FPSTrace

FPSTrace is used to track the interface FPS and OpenGL flush FPS, and display the current value on the floating window.

Energy

# CPUTrace

CPUTrace is used to track the CPU's continuous high-load usage, and will recording which methods are mainly called during the high-load CPU usage.

# BackgroundTask Trace

BackgoundTask trace plugin will tracing the begin/end of UIBackgroundTaskIdentifier, it would be useful when try to find out the cause of crash 0xbada5e47. (see the code for usage directly)

Network

# NetworkMonitor

NetworkMonitor observes and records HTTP(S) network transactions with metrics info in the App. Providing built-in records viewing interface for a developer to troubleshoot network problems.

  1. Inherit FLEX's network recording logic, and optimize the initialization logic, greatly reducing the impact by hooking on startup time.
  2. For NSURLSession after iOS 9, add the URLSessionTaskMetrics record to view the time of each stage of the transaction.
  3. Add a waterfall view similar to Chrome network debugging based on transaction metrics, to view the queue and concurrency of network transactions, and do further optimization.
  4. Add the ability to detect duplicate unnecessary network transactions.
  5. Enhanced search bar to support multi-condition search (host filter, status filter)
  6. Record the network transaction with request header, request body, response body.
# NetworkInspect

NetworkInspect is based on NetworkMonitor. Depending on the actual of the network transaction, checking whether the network request can be improved according to the inspection rules, and you can add your own inspection rules by yourself.

Graphics

# OpenGLTrace

OpengGLTrace is used to track the memory usage of OpenGL resources, and to help find OpenGL API error calls and exception parameter passing.

Storage

# DirectoryWatcher

DirectoryWatcher is used to track the size of the specified sandbox folders, it also integrates FLEX's sandbox file browser.

Utility

# FLEX

FLEX is commonly used in daily development, MTHawkeye adds it as a plugin and extends the use of AirDrop for sandboxed files.

Desktop Extension

If you need to extend the plugin to the desktop, such as viewing and processing the data on the desktop collected by the plugins, you can get the data based on the interface provided by each plugin, and then bridge to the protocol provided by the third-party desktop client. Such as

0x01 Usage

Use during development

First, add an MTHawkeye reference to the project podfile:

  #< Only used during Debug
  #< Since the podfile dependency doesn't support environment configuration, 
  #< the dependent pods also need to be explicitly configured as Debug.
  
  def hawkeye
    pod 'MTHawkeye', :configurations => 'Debug'

    pod 'FLEX', :configurations => ['Debug']
    pod 'FBRetainCycleDetector', :configurations => ['Debug']
    pod 'fishhook', :configurations => ['Debug']
    pod 'CocoaLumberjack',
    '3.6.0', :configurations => ['Debug'] # CocoaLumberjack is optional, change to `MTHawkeye/DefaultPluginsWithoutLog` if don't need.
    # pod 'MTGLDebug', :configurations => ['Debug'] # MTGLDebug is exclude by default, change `MTHawkeye` to `MTHawkeye/DefaultPlugins` to include.

    pod 'MTAppenderFile', :configurations => ['Debug']
  end

  target "YourProject" do
    hawkeye

    # ...
  end

Attention:CocoaLumberjack must <~3.6.0

Then, turn on the MTHawkeye service when the App starts, You can use all the plugins as default, or choose the plugins you need to start.

A: Quickly integrate all default plugins and start:

#ifdef DEBUG
  #import <MTHawkeye/MTRunHawkeyeInOneLine.h>
#endif

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef DEBUG
  [MTRunHawkeyeInOneLine start];
#endif
  // ...
}
B: Select the required plugins, insert new plugins externally:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [self startCustomHawkeye];
  // ...
}

- (void)startCustomHawkeye {
#ifdef DEBUG
  [[MTHawkeyeClient shared]
    setPluginsSetupHandler:^(NSMutableArray<id<MTHawkeyePlugin>> *_Nonnull plugins) {
      [MTHawkeyeDefaultPlugins addDefaultClientPluginsInto:plugins];

      // add your additional plugins here.
    }
    pluginsCleanHandler:^(NSMutableArray<id<MTHawkeyePlugin>> *_Nonnull plugins) {
      // if you don't want to free plugins memory, remove this line.
      [MTHawkeyeDefaultPlugins cleanDefaultClientPluginsFrom:plugins];

      // clean your additional plugins if need.
    }];

  [[MTHawkeyeClient shared] startServer];

  [[MTHawkeyeUIClient shared]
    setPluginsSetupHandler:^(NSMutableArray<id<MTHawkeyeMainPanelPlugin>> *_Nonnull mainPanelPlugins, NSMutableArray<id<MTHawkeyeFloatingWidgetPlugin>> *_Nonnull floatingWidgetPlugins, NSMutableArray<id<MTHawkeyeSettingUIPlugin>> *_Nonnull defaultSettingUIPluginsInto) {
      [MTHawkeyeDefaultPlugins addDefaultUIClientMainPanelPluginsInto:mainPanelPlugins
                                    defaultFloatingWidgetsPluginsInto:floatingWidgetPlugins
                                          defaultSettingUIPluginsInto:defaultSettingUIPluginsInto];


        // add your additional plugins here.
    }
    pluginsCleanHandler:^(NSMutableArray<id<MTHawkeyeMainPanelPlugin>> *_Nonnull mainPanelPlugins, NSMutableArray<id<MTHawkeyeFloatingWidgetPlugin>> *_Nonnull floatingWidgetPlugins,NSMutableArray<id<MTHawkeyeSettingUIPlugin>> *_Nonnull defaultSettingUIPluginsInto) {
      // if you don't want to free plugins memory, remove this line.
      [MTHawkeyeDefaultPlugins cleanDefaultUIClientMainPanelPluginsFrom:mainPanelPlugins
                                      defaultFloatingWidgetsPluginsFrom:floatingWidgetPlugins
                                            defaultSettingUIPluginsFrom:defaultSettingUIPluginsInto];

      // clean your additional plugins if need.
    }];

  dispatch_async(dispatch_get_main_queue(), ^(void) {
    [[MTHawkeyeUIClient shared] startServer];
  });
#endif
}

For the test, online

There may be special requirements during the test phase, or may not need to retain the code for the interface while publishing the App. At this point, you can create a new podspec according to the needs, introduce the needed sub-spec to the pod-spec, and then add it into the podfile.

  pod 'YourOnlineHawkeye', :podspec => 'xxx/yourOwnHawkeyeOnline.podspec', :configurations => 'Release'

Then in the initialization, load the plugin as your needs, configure whether the plugin should start. such as

#ifdef Release
  [MTHawkeyeUserDefaults shared].allocationsTraceOn = YES; // trun on allocations this time.

  [[MTHawkeyeClient shared]
    setPluginsSetupHandler:^(NSMutableArray<id<MTHawkeyePlugin>> *_Nonnull plugins) {
      [plugins addObject:[MTHAllocationsHawkeyeAdaptor new]];

      // add your additional plugins here.
    }
    pluginsCleanHandler:^(NSMutableArray<id<MTHawkeyePlugin>> *_Nonnull plugins) {

    }];

  [[MTHawkeyeClient shared] startServer];
#endif

0x02 Interaction

  • Floating window
    • Show and hide floating window: three-finger long press gesture for two seconds or a three-finger left swipe gesture.
    • Show and hide floating window widget: Enter Setting view, then select Floating Window, switch the widget to show or hide.
  • Main panels: tap the floating window to view the plugin panel you viewed last time.
  • Setting view: Enter the main panel, tap the title unfold the switching module view, top the Setting on the upper right corner.

Interface interaction documentation for each plugin: see links above

0x03 Develop your own plugins

If you have a module that needs to avoid a lot of pits during development, or if you have a lot of debugging/optimization related logging code during development, consider writing a debugging aid and then importing this component into MTHawkeye based on the MTHawkeye API. Used in the framework to unify interactions and interfaces.

If the performance metrics you care about are not continuously tracked during automated testing, consider writing a profiling plugin to collect performance data.

For detail: MTHawkeye plugin development Guide

0x04 Contribute to MTHawkeye

For more information about contributing issues or pull requests, see MTHawkeye Contributing Guide

0x05 Thanks

0x06 License

MTHawkeye is under MIT license,See the LICENSE file for details.

Comments
  • ANR Trace crash

    ANR Trace crash

    Describe the bug 为了测试ANR 在点击事件中做了100w次循环 然后crash了

    Log

    *** Assertion failure in -[MTHawkeyeStorage syncStoreValue:withKey:inCollection:], /Pods/MTHawkeye/MTHawkeye/Core/MTHawkeyeStorage.m:123 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'line lenght should less than 16KB' *** First throw call stack: ( 0 CoreFoundation 0x00000001158626fb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x0000000113ab9ac5 objc_exception_throw + 48 2 CoreFoundation 0x0000000115862482 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000113507927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194 4 MTHawkeye 0x0000000110b661d1 -[MTHawkeyeStorage syncStoreValue:withKey:inCollection:] + 993 5 MTHawkeye 0x0000000110b65d23 __57-[MTHawkeyeStorage asyncStoreValue:withKey:inCollection:]_block_invoke + 51 6 libdispatch.dylib 0x0000000117d82d7f _dispatch_call_block_and_release + 12 7 libdispatch.dylib 0x0000000117d83db5 _dispatch_client_callout + 8 8 libdispatch.dylib 0x0000000117d8b225 _dispatch_lane_serial_drain + 778 9 libdispatch.dylib 0x0000000117d8be9c _dispatch_lane_invoke + 425 10 libdispatch.dylib 0x0000000117d95ea3 _dispatch_workloop_worker_thread + 733 11 libsystem_pthread.dylib 0x0000000118231611 _pthread_wqthread + 421 12 libsystem_pthread.dylib 0x00000001182313fd start_wqthread + 13 ) To Reproduce

    点击事件中做了100w次循环

    Environment (please complete the following information):

    • Device: iphone6s模拟器
    • OS: 12.2
    • Xcode Version: 10.2.1

    Additional context 用的是swift4

    opened by guesspalm 5
  • 调用栈回溯问题

    调用栈回溯问题

    前提:新建项目,仅仅导入mth_stack_backtrace.h与mth_stack_backtrace.mm文件,然后回溯主线程的调用栈,发现当回溯到mth_stack_backtrace_of_thread方法后便停止了,后发现mth_stack_backtrace_of_thread方法的偏移不在主项目的Image范围内。

    后尝试使用pod直接导入MTHawkeye,然后使用同样的代码回溯主线程调用栈,发现可以正常回溯,同时mth_stack_backtrace_of_thread方法的偏移在主项目的Image范围呢。

    猜测是在编译选项中做了处理,可以解释一下MTHawkeye有做何种特殊处理吗?

    opened by mademao 4
  • 在使用过程中关闭性能检测crash

    在使用过程中关闭性能检测crash

    Describe the bug 在使用过程中,调用stop方法,停止检测时crash To Reproduce Steps to reproduce the behavior:

    1. 程序正常启动,并开启性能检测
    2. 在使用过程中调用stop方法停止检测
    3. 程序crash ,以下是调用堆栈信息 2019-04-28 17:32:53.221379+0800 StarMaker[564:102528] dynamic_cast error 2: One or more of the following type_info's has hidden visibility. They should all have public visibility. N10__cxxabiv116__shim_type_infoE, id, N10__cxxabiv117__pbase_type_infoE. 2019-04-28 17:32:53.221538+0800 StarMaker[564:102528] dynamic_cast error 2: One or more of the following type_info's has hidden visibility. They should all have public visibility. N10__cxxabiv116__shim_type_infoE, id, N10__cxxabiv117__pbase_type_infoE. 2019-04-28 17:32:53.221894+0800 StarMaker[564:102528] [Bugly][Info] Handle the crash scene in callback 2019-04-28 17:32:53.253270+0800 StarMaker[564:103034] [Bugly][Info] MemoryMonitorThread is canceled 2019-04-28 17:32:53.346582+0800 StarMaker[564:102528] [Bugly] Trapped uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MTHawkeyeUIClient 0x1c40f7980> for the key path "window" from <GUL_AppDelegate-7CC4C951-CAEF-4111-A255-CD1A9498CA5F 0x1c40963a0> because it is not registered as an observer.' ( 0 CoreFoundation 0x0000000181fd2da4 + 252 1 libobjc.A.dylib 0x000000018118c5ec objc_exception_throw + 56 2 CoreFoundation 0x0000000181fd2c6c + 0 3 Foundation 0x000000018296e10c + 496 4 Foundation 0x000000018296dbfc + 92 5 StarMaker 0x0000000102e10120 hook_Objc_msgSend + 136 6 libdispatch.dylib 0x000000010ab011dc _dispatch_call_block_and_release + 24 7 libdispatch.dylib 0x000000010ab0119c _dispatch_client_callout + 16 8 libdispatch.dylib 0x000000010ab05d2c _dispatch_main_queue_callback_4CF + 1180 9 CoreFoundation 0x0000000181f7b070 + 12 10 CoreFoundation 0x0000000181f78bc8 + 2272 11 CoreFoundation 0x0000000181e98da8 CFRunLoopRunSpecific + 552 12 GraphicsServices 0x0000000183e7d020 GSEventRunModal + 100 13 UIKit 0x000000018beb5758 UIApplicationMain + 236 14 StarMaker 0x0000000100c384d8 main + 124 15 libdyld.dylib 0x0000000181929fc0 + 4 ) Screenshots image

    Environment (please complete the following information):

    • Device: 6sp
    • OS: 11.4
    • Xcode Version: 10.2.1
    bug 
    opened by zhipengbird 4
  • 'FLEX/FLEXImagePreviewViewController.h' file not found

    'FLEX/FLEXImagePreviewViewController.h' file not found

    In Swift project

     pod 'MTHawkeye', :configurations => 'Debug'
    
     pod 'FLEX', :configurations => ['Debug']
     pod 'FBRetainCycleDetector', :configurations => ['Debug']
     pod 'fishhook', :configurations => ['Debug']
     pod 'CocoaLumberjack', '3.6.0', :configurations => ['Debug'] # CocoaLumberjack is optional, change to `MTHawkeye/DefaultPluginsWithoutLog` if don't need.
     # pod 'MTGLDebug', :configurations => ['Debug'] # MTGLDebug is exclude by default, change `MTHawkeye` to `MTHawkeye/DefaultPlugins` to include.
    
     pod 'MTAppenderFile', :configurations => ['Debug']
    

    Build fail: 'FLEX/FLEXImagePreviewViewController.h' file not found

    opened by NicolasKim 3
  • README上没有找到注册插件的方法

    README上没有找到注册插件的方法

    Describe the bug A clear and concise description of what the bug is.

    Log There are two ways to get the running log of MTHawkeye: A: Filter the Xcode Console log, they are start with [hawkeye] B: Under the com.meitu.hawkeye folder in sandbox, the log was store as log.mtlog & log.mmap2

    To Reproduce Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior A clear and concise description of what you expected to happen.

    Screenshots If applicable, add screenshots to help explain your problem.

    Environment (please complete the following information):

    • Device: [e.g. iPhone6]
    • OS: [e.g. iOS8.1]
    • Xcode Version: [e.g. 10.2]

    Additional context Add any other context about the problem here.

    opened by cjlcooper 3
  • 使用该库进行pod install时生成以下提示信息

    使用该库进行pod install时生成以下提示信息

    Describe the bug 在不添加该库时,不会产生以下信息,只有在添加该库时出现 Log [!] The StarMakerLite [Release] target overrides the CLANG_CXX_LANGUAGE_STANDARD build setting defined in Pods/Target Support Files/Pods-StarMakerLite/Pods-StarMakerLite.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the$(inherited)` flag, or - Remove the build settings from the target.

    目前项目中CLANG_CXX_LANGUAGE_STANDARD的值为 CLANG_CXX_LANGUAGE_STANDARD = c++11

    暂时不清楚是本库是否有某些参数与项目的设置有冲突

    opened by zhipengbird 3
  • 使用FLEX heap Objects 必crash

    使用FLEX heap Objects 必crash

    Describe the bug 使用内置的FLEX查看Heap Object必crash

    Screenshots image

    Environment (please complete the following information):

    • Device: iphone6sp
    • OS: 11.4
    • Xcode Version: 10.2.1
    opened by zhipengbird 3
  • 请问为什么pod后使用OneLine start没有内置Graphics(0.12版本)

    请问为什么pod后使用OneLine start没有内置Graphics(0.12版本)

    这是Pod的内容

    pod 'MTHawkeye', :configurations => 'Debug'

    pod 'FLEX', :configurations => ['Debug'] pod 'FBRetainCycleDetector', :configurations => ['Debug'] pod 'fishhook', :configurations => ['Debug']

    pod 'CocoaLumberjack', :configurations => ['Debug'] # CocoaLumberjack is optional, change to MTHawkeye/DefaultPluginsWithoutLog if don't need.

    pod 'MTGLDebug', :configurations => ['Debug'] # MTGLDebug is exclude by default, change MTHawkeye to MTHawkeye/DefaultPlugins to include. pod 'MTAppenderFile', :configurations => ['Debug']

    opened by LeeYZ 2
  • 工程接入AFNetworking,同时使用AFURLSessionManager得到NSURLSessionDownloadTask,在iOS8下面会unrecognized selector崩溃

    工程接入AFNetworking,同时使用AFURLSessionManager得到NSURLSessionDownloadTask,在iOS8下面会unrecognized selector崩溃

    Describe the bug 工程接入AFNetworking,同时使用NSURLSessionDownloadTask,在iOS8下面会崩溃

    Log *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFLocalDownloadTask _hawkeye_swizzle_e8dba47d_resume]: unrecognized selector sent to instance 0x103c0440'

    Last Exception Backtrace: 0 CoreFoundation 0x28634f87 0x2852d000 + 1081223 1 libobjc.A.dylib 0x35c57c77 0x35c51000 + 27767 2 CoreFoundation 0x2863a37d 0x2852d000 + 1102717 3 CoreFoundation 0x28638259 0x2852d000 + 1094233 4 CoreFoundation 0x28569d68 0x2852d000 + 249192 5 MTHawkeye 0x054c81cb __54+[MTHNetworkObserver injectIntoNSURLSessionTaskResume]_block_invoke_2 (MTHNetworkObserver.m:256) 6 MTHawkeye 0x054c81cb __54+[MTHNetworkObserver injectIntoNSURLSessionTaskResume]_block_invoke_2 (MTHNetworkObserver.m:256) 7 MTHawkeye 0x054c81cb __54+[MTHNetworkObserver injectIntoNSURLSessionTaskResume]_block_invoke_2 (MTHNetworkObserver.m:256) 8 ThirdBase 0x059077d9 -[_AFURLSessionTaskSwizzling af_resume] (AFURLSessionManager.m:456)

    Additional context 使用[AFURLSessionManager downloadTaskWithRequest:progress:destination:completionHandler]得到NSURLSessionDownloadTask,这是个类簇,实际得到__NSCFLocalDownloadTask,调用resume的时候崩溃 。

    继承关系如下: iOS8:__NSCFLocalDownloadTask -> __NSCFLocalSessionTask -> NSURLSessionTask; iOS8以上:__NSCFLocalDownloadTask -> __NSCFLocalSessionTask -> __NSCFURLSessionTask-> NSURLSessionTask;

    在MTHNetworkObserver中(大概240行左右),通过NSURLSessionDownloadTask拿到的是__NSCFLocalDataTask(继承关系和__NSCFLocalDownloadTask同一个层级 )。你们处理了iOS8以上的直接用__NSCFURLSessionTask及更底层的NSURLSessionTask进行方法交换. iOS8及已下没处理。

    Question 1.是否特意这样处理(用硬编码的方式进行处理)。如果是的话,修改方法:在iOS的情况下,currnetClass = NSStringFromString("__NSCFLocalSessionTask") 2.是否想hook对应的resume方法,插入对应的MT框架的代码,如果是的话可以尝试AFURLSessionManager的方式。(我看了代码AFURLSessionManager的代码,和你们的处理逻辑相仿,但是不明白为什么写到后面的方法交换没有用AF那套逻辑,我试了改写代码用AFNetworking这套逻辑是可以正常工作的)

    很多地方可能有错误,请指正。

    opened by lalalafq 2
  • add buffer cache on ANRTracing to capture hard stall.

    add buffer cache on ANRTracing to capture hard stall.

    增加跟踪卡死的记录

    • 新增 MTHANRTracingBufferRunner 用于记录最近发生的 Runloop Activities, AppLifeActivities 及卡顿发生时主线程采样的调用栈
    • 下次启动时,如果读取到 App 未正常退出( AppLife Activities),可读取最后采样到的调用栈的时间点,和最后记录到的 Runloop Activity 时间点,如果为卡死状态被杀,会有个时间差。这个时间差即为卡死的时间,这段区间内 MTHANRDetectThread 定时采样到的主线程堆栈,即为卡死期间主线程在做的事。
    • 增加对应的 UI 展示视图,卡死发生后,下一次进入应用。进入到 Hawkeye ANR Records 界面,即可看到卡死的记录。
    • 修正进入后台后,App 挂起的时间也被记录到 ANR 时间的错误 #28 commit: e8c97bdde389e9c56f678b82bd9d30756c0c868a

    @panmingyang2009 @hello-david

    opened by euanchan 2
  • 长时间后台进入前台,偶现ANR记录异常

    长时间后台进入前台,偶现ANR记录异常

    Describe the bug 长时间后台进入前台,偶现ANR记录异常

    Log custom-time-event,1562657739.233881,{"event":"App::DidEnterBackground","time":1562657739.233881} (中间大量CPU,MEM已忽略) custom-time-event,1562671401.548742,{"event":"App::WillEnterForeground","time":1562671401.5487421} view-ctrl,8,{"loadViewExit":1562671401.5686679,"didLoadExit":1562671401.568696,"loadViewEnter":1562671401.568583,"didAppearExit":1562671401.688776,"initExit":1562671401.567296,"willAppearExit":1562671401.5822461,"didLoadEnter":1562671401.568692,"willAppearEnter":1562671401.5822361,"name":"HXKaiPingAdRootViewController","didAppearEnter":1562671401.6887641} custom-time-event,1562671401.795998,{"event":"App::DidBecomeActive","time":1562671401.7959981} anr,1562671401.899392,{"biases":"4.884004592895508","duration":"5023540.706038475","stacks":[{"titleframe":"0x104b9565f","time":1562671401.796412,"stackframes":"0x2063cfea4,0x2063cf37b,0x20624f603,0x20624faa3,0x206497e9f,0x20740aab7,0x2071d256b,0x2071e0333,0x207410a63,0x210d07bdb,0x20627e483,0x20625e743,0x210d07a77,0x210d05747,0x233a3faf3,0x104b9565f,0x2067b483b,0x2067b4807,0x2067b3cf7,0x2067b39a3,0x20672bb7f,0x2067b342f,0x2071c4c9f,0x233a16a63,0x2332bdfc3,0x2332bee23,0x2332bdd7b,0x2332c2c67,0x233608727,0x20927d6e3,0x20627e483,0x2062553df,0x2092bba9b,0x2092bb727,0x2092bbd43,0x2067d60df,0x2067d605f,0x2067d5943,0x2067d080f,0x2067d00df,0x208a49583,0x233a20bff,0x1024472eb,0x20628ebb3"}]}

    To Reproduce

    1. 进入后台
    2. 等待一段时间
    3. 在WillEnterForeground,代码执行开屏广告处理
    4. 出现异常ANR

    Expected behavior 没有这条ANR信息

    Additional context 1.为什么会有一条长达5023540.706038475耗时的ANR信息 2.为什么这段耗时和前后台切换的差值出入较大

    opened by lalalafq 2
  • MTHNetworkObserver类ReceiveData里面appendData的时候,会报NSMallocException内存错误

    MTHNetworkObserver类ReceiveData里面appendData的时候,会报NSMallocException内存错误

    作者你好: 我这边监听直播推流请求的时候,发现会crash,看了崩溃日志,提示NSMallocException 错误

    代码定位到

    - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data impl:(id)impl
    

    函数是

    [NSConcreteMutableData  appendbytes:length]
    [NSConcreteMutableData  appendData:]
    

    我看dataAccumulator逻辑是 didReceiveResponse 初始化 didReceiveData 里面拼接 didCompleteWithError 后面计算大小,移除

    有没可能一开始dataAccumulator这个初始化的时候申请内存小了,然后后面不断拼返回的data,造成内存OOM了,直播的时候可能时间很长,导致数据越来越大,dataAccumulator这部分内存没有到didCompleteWithError就没有清除

    opened by qcliwei 3
  • Ability to use MTHawkeye on jailbroken phones without app modifications

    Ability to use MTHawkeye on jailbroken phones without app modifications

    Is your feature request related to a problem? Please describe. When reviewing iOS apps with the FLEX bar, there are limitations to the Network Monitoring functionality. i.e. Not able to export all captured traffic, no persistence if the app crashes, no detailed filter like MTHawkeye.

    Describe the solution you'd like I would like MTHawkeye releases to include a .deb file, to be released in github and idelally also a Cydia repo. The goal would be to be able to use MTHawkeye functionality while performing security audits of mobile apps. For this purpose, MTHawkeye could be a standalone tweak or be somehow integrated into the FLEX bar.

    Describe alternatives you've considered The FLEX bar is currently insufficient for this as described in the problem description above.

    Additional context MTHawkeye seems great for situation where developers manually add this to their apps, it would be great to be able to use MTHawkeye at runtime to audit any app without having the source code, i.e. at runtime using the FLEX bar or similar.

    opened by 7a 1
Releases(0.12.7)
Owner
meitu
Meitu ❤️ Open Source
meitu
Network debugging made easy,This network debugging tool is developed based on the swift version of Wormholy.

Start debugging iOS network calls like a wizard, without extra code! Wormholy makes debugging quick and reliable. What you can do: No code to write an

null 21 Dec 14, 2022
Chisel is a collection of LLDB commands to assist debugging iOS apps.

Chisel Chisel is a collection of LLDB commands to assist in the debugging of iOS apps. [Installation • Commands • Custom Commands • Development Workfl

Facebook 8.9k Jan 6, 2023
Demonstrates a memory leak bug SwiftUI's toolbar APIs exhibit on macOS

Mac SwiftUI Toolbar Memory Leak Demo On Big Sur (macOS 11), SwiftUI's APIs for adding toolbar items to a window have (at least) two bugs around view r

Matt Curtis 6 Aug 6, 2022
Remote network and data debugging for your native iOS app using Chrome Developer Tools

PonyDebugger PonyDebugger is a remote debugging toolset. It is a client library and gateway server combination that uses Chrome Developer Tools on you

Square 5.9k Dec 24, 2022
Set of easy to use debugging tools for iOS developers & QA engineers.

DBDebugToolkit DBDebugToolkit is a debugging library written in Objective-C. It is meant to provide as many easily accessible tools as possible while

Dariusz Bukowski 1.2k Dec 30, 2022
A collection of tools for debugging, diffing, and testing your application's data structures.

Custom Dump A collection of tools for debugging, diffing, and testing your application's data structures. Motivation customDump diff XCTAssertNoDiffer

Point-Free 631 Jan 3, 2023
A lightweight, one line setup, iOS / OSX network debugging library! 🦊

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from

Christos Kasketis 3.4k Dec 28, 2022
iOS network debugging, like a wizard 🧙‍♂️

Start debugging iOS network calls like a wizard, without extra code! Wormholy makes debugging quick and reliable. What you can do: No code to write an

Paolo Musolino 2.1k Jan 8, 2023
An in-app debugging and exploration tool for iOS

FLEX FLEX (Flipboard Explorer) is a set of in-app debugging and exploration tools for iOS development. When presented, FLEX shows a toolbar that lives

FLEXTool 13.3k Dec 31, 2022
Next generation debugging framework for iOS

Alpha is the idea of a next generation debugging framework for iOS applications. It combines multiple debugging tools built on top of a simple, unifie

Dal Rupnik 733 Oct 29, 2022
Dotzu In-App iOS Debugging Tool With Enhanced Logging, Networking Info, Crash reporting And More.

Dotzu In-App iOS Debugging Tool With Enhanced Logging, Networking Info, Crash reporting And More. The debugger tool for iOS developer. Display logs, n

Remi ROBERT 1.8k Jan 3, 2023
Free macOS app for iOS view debugging.

Introduction You can inspect and modify views in iOS app via Lookin, just like UI Inspector in Xcode, or another app called Reveal. Official Website:h

Li Kai 575 Dec 28, 2022
Droar is a modular, single-line installation debugging window

Droar is a modular, single-line installation debugging window. Overview The idea behind Droar is simple: during app deployment stages, adding quick ap

Myriad Mobile 55 Sep 24, 2022
Convenient debugging button.

FunnyButton Example 在平时开发,运行期间有时候想中途看一下某个视图或变量的信息,虽说打断点是可以查看,但有时候断点调试有时候会卡住好一会才能看到(尤其是大项目经常卡很久),极度影响效率。 基于这种情况,FunnyButton就是为了能够便捷调试的全局按钮,添加好点击事件,就能随时

健了个平_(:з」∠)_ 2 Sep 20, 2022
In-app console and debug tools for iOS developers

LocalConsole Welcome to LocalConsole! This Swift Package makes on-device debugging easy with a convenient PiP-style console that can display items in

Duraid Abdul 650 Jan 1, 2023
a iOS network debug library, monitor HTTP requests

NetworkEye README 中文 NetworkEye,a iOS network debug library,monitor HTTP requests. It can be detected HTTP request include web pages, NSURLConnection,

coderyi 1.4k Dec 31, 2022
A swift network profiler built on top of URLSession.

By Xmartlabs SRL. Introduction Xniffer is a non-intrusive framework for intercepting outgoing requests and their responses between your app and any ex

xmartlabs 498 Dec 24, 2022
Observable Object Debugger - Watch for ObservableObject in real time

Observable Object Debugger Watch for ObservableObject in real time. (This is the Alpha version) Quick Start Add package to you project.

Yusuke Hosonuma 3 Jun 19, 2022
Customizable Console UI overlay with debug log on top of your iOS App

AEConsole Customizable Console UI overlay with debug log on top of your iOS App AEConsole is built on top of AELog, so you should probably see that fi

Marko Tadić 142 Dec 21, 2022