PhantomJS performance - javascript

My question is, what is the most efficient configuration for PhantomJS tests.
Currently I have 1 instance of PhantomJS running and every instance can have 2 tabs opened (dev env).
Is it better to have more instance of phantomjs or opened tabs, and if tabs, what is the upper limit of PhantomJS.
CPU:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3210M CPU # 2.50GHz
stepping : 9
microcode : 0x19
cpu MHz : 2494.316
cache size : 3072 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc up rep_good nopl xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx rdrand hypervisor lahf_lm
bogomips : 4988.63
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Memory:
total used free shared buffers cached
Mem: 2515896 1155828 1360068 0 171648 622668
More information:
I would like to handle multiple tests at once with as less memory as possible. Now I am running two pages per phantom instance, and already I am having issues with network requests. I have a timeout of 20s and if a specific network request is not finished in that time, test fails.
Test is successful if I only run one page in one PhantomJS instance, but that is not optimal, because we will be running more then 1000 tests, and I would like to arrange tests in multiple pages across multiple phantomjs instances.
Example:
10 phantomjs instances
every phantomjs instance can run 30 pages
Now why when running multiple pages in one instance, does the network request lag so much?

Related

Get real architecture of M1 Mac regardless of Rosetta

I need to retrieve the real architecture of a Mac regardless of if the process is running through Rosetta or not.
Right now in Node.js, process.arch returns x64 and in shell, uname -m returns x86_64.
Thanks to #Ouroborus, this note describes how to figure out if your app is translated.
If it's translated:
$ sysctl sysctl.proc_translated
sysctl.proc_translated: 1
If not:
$ sysctl sysctl.proc_translated
sysctl.proc_translated: 0
On non-ARM Macs:
$ sysctl sysctl.proc_translated
sysctl: unknown oid 'sysctl.proc_translated'
As #Elmo's answer indicates, the command line sysctl -n sysctl.proc_translated or the native equivalent sysctlbyname() call will indicate whether you are running under Rosetta.
Two other sysctl values are relevant. On M1 hardware without Rosetta, these values are returned:
hw.cputype: 16777228
hw.cpufamily: 458787763
hw.cputype is 0x0100000C (CPU_TYPE_ARM64) and hw.cpufamily is 0x1b588bb3 (CPUFAMILY_ARM_FIRESTORM_ICESTORM).
However, when executed under Rosetta, the low-level machine code which collects CPUID takes precendence and following two values are returned, both via sysctlbyname() and the command line:
hw.cputype: 7
hw.cpufamily: 1463508716
These correspond to 0x7 (CPU_TYPE_X86) and 0x573b5eec (INTEL_WESTMERE).
It appears Rosetta reports an x86-compatible Westmere chip under Rosetta, but this choice seems consistent everywhere I've seen. This "virtual architecture" may be useful information for some programs.
Another possibility presents itself in the IO Registry. While the default IOService plane collects data in real-time, the IODeviceTree plane is stored at boot, and includes these entries in the tree (command line ioreg -p IODeviceTree or ioreg -c IOPlatformDevice):
cpu0#0 <class IOPlatformDevice, id 0x10000010f, registered, matched, active, busy 0 (180 ms), retain 8>
| | | {
...
| | | "compatible" = <"apple,icestorm","ARM,v8">
(for CPUs 0-3)
and
cpu4#100 <class IOPlatformDevice, id 0x100000113, registered, matched, active, busy 0 (186 ms), retain 8>
| | | {
...
| | | "compatible" = <"apple,firestorm","ARM,v8">
(for CPUs 4-7)
This clearly indicates the ARMv8 Firestorm + Icestorm M1 chip.
The same approach should work for the M1 Pro and M1 Max.

How to view the assembly code generated from my JavaScript (in Chrome)?

is it somehow possible, to view the final machine code (x86 instruction) that a browser generates from my Javascript? E.g.
--- Raw source ---
function add(a, b){
return a + b;
}
...
--- Code ---
source_position = 0
kind = FUNCTION
Instructions (size = 456)
0x36953100 0 8b4c2404 mov ecx,[esp+0x4]
0x36953104 4 81f991806049 cmp ecx,0x49608091 ;; object: 0x49608091 <undefined>
0x3695310a 10 750a jnz 22 (0x36953116)
0x3695310c 12 8b4e13 mov ecx,[esi+0x13]
0x3695310f 15 8b4917 mov ecx,[ecx+0x17]
0x36953112 18 894c2404 mov [esp+0x4],ecx
0x36953116 22 55 push ebp
Thanks!
Your script doesn't transform to machine code directly. JavaScript runs on virtual machine V8 (it's true for chrome and classic nodejs) and you can get VM byte code using:
node --print-bytecode script.js
Then V8 executes and optimizes the byte code and calls external C libraries and OS API (system calls) or WEB API. Final machine code may vary even with the same javascript code (for example before and after optimization).
You can also start Chrome from the command line with
--js-flags="--print-bytecode"
UPD:
As #PeterCordes noticed nodejs allow to see Turbofan generated machine code using
node --print-opt-code script.js
Chrome:
--js-flags="--print-opt-code"
Also you can use HTML visualizer like https://github.com/v8/v8/tree/master/tools/turbolizer

WebUSB will not connect because another device is using the same interface

So I'm trying to connect to openEEG upon running the claimInterface() function I get
NetworkError: Unable to claim interface
lsusb shows this problem is likely because some MSI driver is running on the same driver
Output of lsusb -v -s4
Bus 002 Device 004: ID 1770:ff00
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x1770
idProduct 0xff00
bcdDevice 1.10
iManufacturer 1 MSI EPF USB
iProduct 1 MSI EPF USB
iSerial 1 MSI EPF USB
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 33 US
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 57
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Device Status: 0xa630
(Bus Powered)
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6001 FT232 USB-Serial (UART) IC
bcdDevice 6.00
iManufacturer 1 FTDI
iProduct 2 FT232R USB UART
iSerial 3 A105XV9J
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 90mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2 FT232R USB UART
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
I originally tried adding 255 as the classCode on navigator.usb.requestDevice because the documentation said I can do that, but they don't have the same IDs so that was pointless. Also upon reconnecting I can only get lsusb to output of the MSI driver even though Chrome picks it up and I got an access denied error.
which is strange because I changed the udev rules and used sudo chmod -R 777 * In dev/bus/usb
I then found in folder "001" a file that I previously had to manually change the permissions of thinking it was the MSI driver but this time the original file was deleted in place of one named "007" instead of "005" (probably because I tried plugging the device in twice)
So this must be a combination of MSI security features? and OpenEEG creating a new file every time it's loaded?
The only solution I can think of is to delete a file that I don't understand and change the permissions every time it's plugged in. both of which are very prohibitive for uses especially since I want my website to work across a broad range of devices and operating systems
PS: Using Linux Mint if that's relevant and here is my code(I don't think it's the problem) that is being run with on local node.js server
document.addEventListener('DOMContentLoaded', event => {
let button = document.getElementById('connect')
button.addEventListener('click', async() => {
var device
const VENDOR_ID = 0x0403
const PRODUCT_ID = 0x6001
const CLASS_CODE = 255
device = await navigator.usb.requestDevice({
filters: [{
vendorId: VENDOR_ID,
productId: PRODUCT_ID,
classCode: CLASS_CODE
}]
})
console.log('opening..')
await device.open()
console.log('open!')
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(0)).catch(error => { console.log(error + 'eeeeeeerrrr ' + device.configuration.interfaces[0].interfaceNumber); });
console.log(device);
await device.close().catch(error => { console.log(error + 'eeeeeeerrrr'); });
});
})
EDIT/UPDATE: lsusb returns nothing when not connected the two drivers are coming from the same input???????
When you connect your device on the USB port Linux loads its driver and claim the device for itself.
If you want to use it somewhere else just unload the driver:
$ sudo modprobe -r ftdi_sio
If you reboot your computer the driver will load again and you'll have to unload it manually. If you want to keep it unloaded you can do:
$ echo "ftdi_sio" | sudo tee -a /etc/modules
I can understand why it got you confused, considering the output of lsusb is not that clear but I think the other MSI driver is for the root USB controller on your computer. If you remove it you won't be able to see your ports or anything connected to them.
If unloading the driver does not fix your problem maybe you're not claiming the correct device. You can find out more reading the log file if you write on your navigation bar chrome://device-log/

Google Chrome Crashes Memory leak or Any rendering issue

We have a SPA running on Chrome Browser. It is Crashing intermittently after using the application for some time. I am getting the Aw Snap error Page.
I enabled the logs in the Chrome and found out following information in the log files. Additionally, Google Chrome doesn't generate a Dump file even after enabling the Dump file setting in Chrome.
Error Message in Chrome Logs
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph 6f
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph b3
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph 11b
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph bf
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph 48
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph 46
[0226/100630:INFO:SkScalerContext.cpp(170)] --- no context for glyph 23
[0226/100630:INFO:SkCanvas.cpp(747)] Unable to create device for layer.
[0226/100630:INFO:SkCanvas.cpp(747)] Unable to create device for layer.
[0226/100630:INFO:SkCanvas.cpp(747)] Unable to create device for layer.
Can anyone give some pointers as to what the error message "Unable to create device for layer." and "no context for glyph" means and what can be the possible reasons for this error message?
Since the crash happens after using the application for some time, i am suspecting a memory leak. Is it possible that the error is happening because of memory leak?
EDIT 1:
There seems to be memory leak as the Javascript Memory is increasing. Also, the Heap Allocation shows the increasing memory which is not getting Cleared. However, the SPA itself is little complex and having a lot of Objects and i will analyze what Objects are Preventing other Objects from GC.
Additionally, the Chrome creates a 0Kb dump file in the CrashReports folder.
Moreover, i took a process dump and analyzed using windbg. Following is the output from !analyze-v command. I am analyzing the memory dumps and from the windbg it seems that an access violation exception is raised and it seems that no memory is available for allocating the Bitmap. Does this dump information point to any other useful information as well?
FAULTING_IP:
chrome_1490000!skia::CrashForBitmapAllocationFailure+70 [c:\b\build\slave\chrome-official\build\src\skia\ext\platform_canvas_win.cc # 46]
01956d67 mov dword ptr ds:[3],0
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 01956d67 (chrome_1490000!skia::CrashForBitmapAllocationFailure+0x00000070)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 00000003
Attempt to write to address 00000003
PROCESS_NAME: chrome.exe
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.
EXCEPTION_PARAMETER1: 00000001
EXCEPTION_PARAMETER2: 00000003
WRITE_ADDRESS: 00000003
FOLLOWUP_IP:
chrome_1490000!skia::CrashForBitmapAllocationFailure+70 [c:\b\build\slave\chrome-official\build\src\skia\ext\platform_canvas_win.cc # 46]
01956d67 mov dword ptr ds:[3],0
MOD_LIST: <ANALYSIS/>
NTGLOBALFLAG: 0
APPLICATION_VERIFIER_FLAGS: 0
FAULTING_THREAD: 00002fac
BUGCHECK_STR: APPLICATION_FAULT_NULL_CLASS_PTR_DEREFERENCE_INVALID_POINTER_WRITE
PRIMARY_PROBLEM_CLASS: NULL_CLASS_PTR_DEREFERENCE
DEFAULT_BUCKET_ID: NULL_CLASS_PTR_DEREFERENCE
LAST_CONTROL_TRANSFER: from 014ef4ed to 01956d67
STACK_TEXT:
003deb9c 014ef4ed 000004cc 000000d6 00000057 chrome_1490000!skia::CrashForBitmapAllocationFailure+0x70 [c:\b\build\slave\chrome-official\build\src\skia\ext\platform_canvas_win.cc # 46]
003debc0 0160893b 000004cc 000000d6 00000001 chrome_1490000!skia::PlatformCanvas::initialize+0x97 [c:\b\build\slave\chrome-official\build\src\skia\ext\platform_canvas_win.cc # 107]
003debe4 016086ef 000004cc 000000d6 003ded54 chrome_1490000!TransportDIB::GetPlatformCanvas+0x3f [c:\b\build\slave\chrome-official\build\src\ui\gfx\surface\transport_dib_win.cc # 74]
003dec04 0160696b 035f4774 000000d6 003dedd8 chrome_1490000!RenderProcessImpl::GetDrawingCanvas+0x4d [c:\b\build\slave\chrome-official\build\src\content\renderer\render_process_impl.cc # 169]
003ded80 01606488 035f4700 017ec98a 003def0c chrome_1490000!RenderWidget::DoDeferredUpdate+0x49b [c:\b\build\slave\chrome-official\build\src\content\renderer\render_widget.cc # 843]
003ded88 017ec98a 003def0c 035f4700 03606ab8 chrome_1490000!RenderWidget::DoDeferredUpdateAndSendInputAck+0x8 [c:\b\build\slave\chrome-official\build\src\content\renderer\render_widget.cc # 731]
003dedb4 017ec725 015d826f 1d660a04 035f4700 chrome_1490000!RenderWidget::OnUpdateRectAck+0xe1 [c:\b\build\slave\chrome-official\build\src\content\renderer\render_widget.cc # 383]
003dedb8 015d826f 1d660a04 035f4700 035f4700 chrome_1490000!IPC::Message::Dispatch<RenderWidget,RenderWidget>+0x1a [c:\b\build\slave\chrome-official\build\src\ipc\ipc_message.h # 138]
003def0c 015c10c8 1d660a04 1d660a04 1d660a04 chrome_1490000!RenderWidget::OnMessageReceived+0xb0 [c:\b\build\slave\chrome-official\build\src\content\renderer\render_widget.cc # 201]
003df420 0154d34f 1d660a04 03613d84 0154d329 chrome_1490000!RenderViewImpl::OnMessageReceived+0x1381 [c:\b\build\slave\chrome-official\build\src\content\renderer\render_view_impl.cc # 764]
003df42c 0154d329 1d660a04 0150aed5 1d660a04 chrome_1490000!MessageRouter::RouteMessage+0x23 [c:\b\build\slave\chrome-official\build\src\content\common\message_router.cc # 47]
003df434 0150aed5 1d660a04 003df510 00000000 chrome_1490000!MessageRouter::OnMessageReceived+0x1b [c:\b\build\slave\chrome-official\build\src\content\common\message_router.cc # 39]
003df490 014c39f0 1d660a04 00000002 014c0c8a chrome_1490000!ChildThread::OnMessageReceived+0x178 [c:\b\build\slave\chrome-official\build\src\content\common\child_thread.cc # 201]
003df49c 014c0c8a 1d6609f0 00000000 1d6609f4 chrome_1490000!base::internal::Invoker<2,base::internal::BindState<base::internal::RunnableAdapter<void (__thiscall quota::QuotaManagerProxy::*)(GURL const &)>,void __cdecl(quota::QuotaManagerProxy *,GURL const &),void __cdecl(quota::QuotaManagerProxy *,GURL)>,void __cdecl(quota::QuotaManagerProxy *,GURL const &)>::Run+0x16 [c:\b\build\slave\chrome-official\build\src\base\bind_internal.h # 1254]
003df4e8 014c0962 003df748 003df510 003df748 chrome_1490000!MessageLoop::RunTask+0x21e [c:\b\build\slave\chrome-official\build\src\base\message_loop.cc # 460]
003df758 01493ffd 0a805c60 00000051 00000004 chrome_1490000!MessageLoop::DoWork+0x2d1 [c:\b\build\slave\chrome-official\build\src\base\message_loop.cc # 661]
003df860 014a5d87 035f0780 035f0788 035f0788 chrome_1490000!tcmalloc::ThreadCache::Deallocate+0x2c [c:\b\build\slave\chrome-official\build\src\third_party\tcmalloc\chromium\src\thread_cache.h # 346]
003df930 014a86c6 00000014 0000001f 03613d84 chrome_1490000!std::_Allocate<unsigned short>+0x71 [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xmemory # 44]
003df98c 014b03f0 00000000 00000008 00000000 chrome_1490000!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::compare+0x4b [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xstring # 2051]
003df9a8 014b1fe4 003dfa20 003dfab0 00000000 chrome_1490000!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::compare+0x26 [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xstring # 2027]
003df9bc 014a54b4 003dfa78 003dfa20 003dfab0 chrome_1490000!`anonymous namespace'::RunNamedProcessTypeMain+0x42 [c:\b\build\slave\chrome-official\build\src\content\app\content_main.cc # 264]
003dfa98 014a5244 01360000 003dfb98 003dfab0 chrome_1490000!content::ContentMain+0x224 [c:\b\build\slave\chrome-official\build\src\content\app\content_main.cc # 457]
003dfacc 01385239 01360000 003dfb98 003dfba0 chrome_1490000!ChromeMain+0x1e [c:\b\build\slave\chrome-official\build\src\chrome\app\chrome_main.cc # 28]
003dfb44 0138471d 01360000 003dfb98 fffffffe chrome!MainDllLoader::Launch+0xf1 [c:\b\build\slave\chrome-official\build\src\chrome\app\client_util.cc # 343]
003dfba4 013a33ff 01360000 00000000 005e2fa4 chrome!wWinMain+0x60 [c:\b\build\slave\chrome-official\build\src\chrome\app\chrome_exe_main_win.cc # 37]
003dfc34 76fb343d 7efde000 003dfc80 777f9832 chrome!__tmainCRTStartup+0x112 [f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c # 263]
003dfc40 777f9832 7efde000 77d58cd7 00000000 kernel32!BaseThreadInitThunk+0xe
003dfc80 777f9805 013a346a 7efde000 00000000 ntdll!__RtlUserThreadStart+0x70
003dfc98 00000000 013a346a 7efde000 00000000 ntdll!_RtlUserThreadStart+0x1b
STACK_COMMAND: ~0s; .ecxr ; kb
FAULTING_SOURCE_CODE:
No source found for 'c:\b\build\slave\chrome-official\build\src\skia\ext\platform_canvas_win.cc'
SYMBOL_STACK_INDEX: 0
SYMBOL_NAME: chrome!skia::CrashForBitmapAllocationFailure+70
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: chrome_1490000
IMAGE_NAME: chrome.dll
DEBUG_FLR_IMAGE_TIMESTAMP: 4f331615
FAILURE_BUCKET_ID: NULL_CLASS_PTR_DEREFERENCE_c0000005_chrome.dll!skia::CrashForBitmapAllocationFailure
BUCKET_ID: APPLICATION_FAULT_NULL_CLASS_PTR_DEREFERENCE_INVALID_POINTER_WRITE_chrome!skia::CrashForBitmapAllocationFailure+70
WATSON_STAGEONE_URL: http://watson.microsoft.com/StageOne/chrome_exe/18_0_1025_11/4f331682/chrome_dll/18_0_1025_11/4f331615/c0000005/004c6d67.htm?Retriage=1
Followup: MachineOwner
---------
Note: This error in not coming in the latest Chrome & Canary Build. We are getting this error on the Older version of Chrome (32 bit).
The messages you see in the log file are probably unrelated and not serious, considering that they say INFO at the beginning.
A memory leak could absolutely be what's causing the tab crashes. As a quick test, you can open Chrome's process manager and check if memory consumption of the tab in question grows over time.
Once you have confirmed the suspicion that there is a memory leak, the DevTools are your best friend for figuring out what's going on. Two approaches that are often useful are:
Take a heap snapshot, perform some sequence of operations where afterwards memory consumption should be the same as it was before you started (i.e. navigate somewhere and back, or the like), take a second heap snapshot, and use the comparison tool to compare them. Anything that's in the second snapshot but not in the first could point you towards the leak.
Use the "allocation timeline" feature. It indicates when objects are allocated, and which of them are still around.
If you believe that the leak is in Chrome rather than your own app, please file a bug at crbug.com/new and include instructions on how to reproduce the problem. If you post the bug number here, I can make sure it gets looked at. A quick test to determine whether the cause is likely your own app or the browser is to run it in another browser and see if you observe the same crash (and/or increase in memory consumption) there.

0x8badf00d in React native iOS

I am developing a React Native (0.45.0) application and once in a couple of hours my application crashes (or rather gets killed by watchdog) with 0x8badf00d. I understand why watchdog kills the application; the main thread takes longer than 20 seconds to respond to an event. But I have no idea how to debug this in React Native. Everything is in Javascript and in promises so I am assuming that the network execution that I am doing is already asynchronous.
The application seems to be only crashing while it's in the background. However, the crash reports role states Foreground. We are using background fetch and background geolocation which both do a network request. I have measured the time from event trigger to finish and it does not take longer than one second in total.
I read that the most common problem for this error to happen is a network request on the main threat. Could it be that it tries to load the js bundle synchronously and hangs? How can I debug this problem when all my code is in Javascript?
Thank you very much in advance.
Incident Identifier: 36E63A5F-7C40-40C0-9914-2C9EAE494C11
Beta Identifier: 3C432B54-1947-470E-A387-6566A494E145
Hardware Model: iPhone7,2
Process: [993]
Path: /private/var/containers/Bundle/Application/70B3363C-32E9-4D26-B6C6-DB51304D46C7/.app/
Identifier: org.reactjs.native.example.Test3
Version: 20 (1.4)
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: org.reactjs.native.example.Test3 [703]
Date/Time: 2017-07-17 21:31:33.1931 -0400
Launch Time: 2017-07-17 19:18:30.9574 -0400
OS Version: iPhone OS 10.3.2 (14F89)
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib
0x0000000182a07224 0x182a06000 + 4644
1 libsystem_kernel.dylib
0x0000000182a0709c 0x182a06000 + 4252
2 CoreFoundation
0x00000001839d8e90 0x1838fe000 + 896656
3 CoreFoundation
0x00000001839d6ae4 0x1838fe000 + 887524
4 CoreFoundation
0x0000000183906da4 0x1838fe000 + 36260
5 GraphicsServices
0x0000000185370074 0x185364000 + 49268
6 UIKit
0x0000000189bc1058 0x189b4c000 + 479320
7
0x00000001000bfa08 0x1000b8000 + 31240
8 libdyld.dylib
0x000000018291559c 0x182911000 + 17820
Update, symbolized part of the crash log:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000182faf224 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000182faf09c mach_msg + 72
2 CoreFoundation 0x0000000183f80e90 __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x0000000183f7eae4 __CFRunLoopRun + 1060
4 CoreFoundation 0x0000000183eaeda4 CFRunLoopRunSpecific + 424
5 GraphicsServices 0x0000000185918074 GSEventRunModal + 100
6 UIKit 0x000000018a169058 UIApplicationMain + 208
7 0x0000000100063294 0x10005c000 + 29332
8 libdyld.dylib 0x0000000182ebd59c start + 4

Categories

Resources