YueChen-C / py-ios-device

IOS Professional Performance Testing Tool . You can get CPU, GPU, Memory , Lifecycle and other metrics from real iOS devices . IOS 专业性能测试工具
GNU General Public License v3.0
633 stars 179 forks source link

App lifecycle error #93

Open sanidhya-saraswat opened 1 year ago

sanidhya-saraswat commented 1 year ago

While running demo/app_lifecycle.py on the latest code, getting this error:

This issue also occurs, while using the pip module.


2023-02-24 15:42:06 [INFO] [LockDown] lockdown.py[line:73] Connecting Device xxxxxx-xxxxxxxx
2023-02-24 15:42:06 [INFO] [Instrument] Instrument.py[line:22] InstrumentServer init ...
2023-02-24 15:42:06 [INFO] [Instrument] dvt.py[line:167] set com.apple.instruments.server.services.coreprofilesessiontap callback ...
2023-02-24 15:42:06 [INFO] [LockDown] lockdown.py[line:73] Connecting Device xxxxx-xxxxxxx 
2023-02-24 15:42:06 [INFO] [Instrument] Instrument.py[line:22] InstrumentServer init ...
2023-02-24 15:42:06 [ERROR] [Instrument] dvt.py[line:252] could not find container end marker
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/servers/dvt.py", line 239, in _receiver
    self._channel_callbacks[(2 ** 32 - dtx.channel_code)](dtx)
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 32, in on_graphics_message
    demo(res.selector.data)
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 22, in demo
    for event in Kperf.to_dict(data):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kperf_data.py", line 1021, in to_dict
    for event in self.parse(kd_buf):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kperf_data.py", line 971, in parse
    yield kc_data_parse(buf_io.read())
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 1710, in kc_data_parse
    for i, kcdata_buffer in enumerate(iterate_kcdatas(data)):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 1667, in iterate_kcdatas
    kcdata_buffer.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 670, in ReadItems
    o.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 670, in ReadItems
    o.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 677, in ReadItems
    raise Exception(self.no_end_message)
Exception: could not find container end marker
start notion.id pid:22491```
YueChen-C commented 1 year ago

I need the iPhone model and os version to test

sanidhya-saraswat commented 1 year ago

iPhone 13, OS Version: 16.2

sanidhya-saraswat commented 1 year ago

One more error similar to this comes sometimes:


2023-02-27 11:44:55 [INFO] [Instrument] Instrument.py[line:22] InstrumentServer init ...
2023-02-27 11:44:55 [INFO] [Instrument] dvt.py[line:167] set com.apple.instruments.server.services.coreprofilesessiontap callback ...
2023-02-27 11:44:56 [INFO] [LockDown] lockdown.py[line:73] Connecting Device xxxxx-xxxxxxxx 
2023-02-27 11:44:56 [INFO] [Instrument] Instrument.py[line:22] InstrumentServer init ...
2023-02-27 11:44:56 [ERROR] [Instrument] dvt.py[line:252] unpack_from requires a buffer of at least 36 bytes for unpacking 36 bytes at offset 0 (actual buffer size is 0)
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/servers/dvt.py", line 239, in _receiver
    self._channel_callbacks[(2 ** 32 - dtx.channel_code)](dtx)
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 32, in on_graphics_message
    demo(res.selector.data)
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 22, in demo
    for event in Kperf.to_dict(data):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kperf_data.py", line 1021, in to_dict
    for event in self.parse(kd_buf):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kperf_data.py", line 971, in parse
    yield kc_data_parse(buf_io.read())
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 1710, in kc_data_parse
    for i, kcdata_buffer in enumerate(iterate_kcdatas(data)):
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 1667, in iterate_kcdatas
    kcdata_buffer.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 670, in ReadItems
    o.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 670, in ReadItems
    o.ReadItems(iterator)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 663, in ReadItems
    o = KCObject.FromKCItem(i)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 462, in FromKCItem
    return KCObject(kcitem.i_type, kcitem.i_data, kcitem.i_offset, kcitem.i_flags)
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 443, in __init__
    self.ParseData()
  File "/opt/homebrew/lib/python3.9/site-packages/ios_device/util/kc_data.py", line 519, in ParseData
    u_d = struct.unpack_from('32sI', self.i_data)
struct.error: unpack_from requires a buffer of at least 36 bytes for unpacking 36 bytes at offset 0 (actual buffer size is 0)
start notion.id pid:38207
^CTraceback (most recent call last):
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 63, in <module>
    app_launch_lifecyle(rpc, 'notion.id')
  File "/Users/sanidhya/repos/py-ios-device/demo/instrument_demo/app_lifecycle.py", line 56, in app_launch_lifecyle
    time.sleep(1000)
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py'>
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 1470, in _shutdown
    lock.acquire()
KeyboardInterrupt: ```
Ren-Qan commented 1 year ago

同无法获取app启动数据: 情况1:同上 情况2: image 情况3:只有整体启动耗时。

iPhone13 pro max - 16.1

YueChen-C commented 1 year ago

I don't know why. Sometimes the stackshot data is truncated, But not every time

erduoniba commented 7 months ago

同无法获取app启动数据: 情况1:同上 情况2: image 情况3:只有整体启动耗时。

iPhone13 pro max - 16.1

@Ren-Qan 情况 3 参考 https://github.com/YueChen-C/py-ios-device/pull/127 看是否能解决。