Safari Web inspector keeps disconnecting

前端 未结 15 968
醉话见心
醉话见心 2021-01-30 10:27

I\'ve Safari 8.0.6 with iOS 8.3 on my iPad, while debugging through Web Inspector on my Mac (10.10.3), the connection keeps on

相关标签:
15条回答
  • 2021-01-30 10:48

    There are a few things to try:

    1. Test on the Xcode Simulator:

    Open the iPhone simulator in Xcode and debug there with Safari Web Inspector.

    Sidenote: Maybe you need to download the Safari Technology Preview

    2. Reset your location and privacy settings on your device.

    Settings > General > Reset > Reset Location & Privacy

    3. Debugging on a real device

    With this configuration it seems to work right now.

    iPhone X, iOS Version 12.1.3 macOS Mojave Version 10.14.2 (18C54) Safari Version 12.0.2 (14606.3.4)

    Edit 2019.08.13

    Settings -> Safari -> Advanced -> Check that Webinformation is toggled on.

    It was suddenly toggled off and I couldn't connect via the Web Inspector. After toggling it on, it worked.

    For other devices / versions, please read further down (Maybe you can decrease your build size).


    EDIT: 2018.09.20

    @Chet found out, the Web Inspector keeps disconnecting for too large JS files and map files

    https://stackoverflow.com/a/52338231/4641479

    Issue on Github:

    https://github.com/google/ios-webkit-debug-proxy/issues/275

    https://github.com/google/ios-webkit-debug-proxy/issues/274

    I could confirm this on a real device with a production build (1.8 MB + 2.4 MB files), the Safari Web Inspector stays always connected.

    Since for the development build it is not:


    Before my web inspector very rarely worked and often just stopped working - but was still open. After the safari update the web inspector opens and closes immediately. If you encounter such problems..

    This will work:

    Step 1. Get the latest Safari Browser

    Safari: 11.1 (12605.1.33.1.2)

    https://developer.apple.com/safari/download

    macOS Sierra and OS X El Capitan (I assume macOS high Sierra is also supported)

    Maybe you need to download the Safari Technology Preview


    Step 2. Reset your location and privacy settings

    On your device go to:

    Settings > General > Reset > Reset Location & Privacy

    Source: https://forums.developer.apple.com/thread/87181


    Step 3. Connect your device

    Open Safari on OS X If you had connected your iPhone device with an usb cable, disconnect it first. Now plug it in.

    On OS X Safari go to:

    Develop > Device name > Apply for development

    Now on your phone there is a permission question. Choose trust and now you can choose the open tab on your devices safari and debug.


    Happy debug!

    Now the web inspector stays connected.

    0 讨论(0)
  • 2021-01-30 10:48

    Sounds strange but it may be happening due to the battery being full triggering a disconnect: https://forums.developer.apple.com/thread/92290

    The disconnection seems to occur when the battery of the Iphone is full. (So for the moment we turn the flash and the camera on to kill the battery while inspecting ...)

    0 讨论(0)
  • 2021-01-30 10:49

    MacOS Mojave / Catalina Solution

    For me the issue started right after I upgraded to the new macOS Mojave, this might have been mentioned somewhere above but for me I just needed to download the new "Safari Technology Preview" app that is built for Mojave.

    Safari Download Page

    https://developer.apple.com/safari/download/

    Direct Download for Mojave

    https://secure-appldnld.apple.com/STP/041-71285-20190604-6d0dcb17-07e5-40a0-b418-dba732cefe64/SafariTechnologyPreview.dmg

    0 讨论(0)
  • 2021-01-30 10:50

    When using a content-blocker (e.g. 1Blocker) on your iOS device, make sure it is disabled for the domain you want to debug.

    Disabling 1Blocker stopped the Web Inspector (Mac) from closing immediately after opening it, and allowed me to get back to work.

    0 讨论(0)
  • 2021-01-30 10:53

    I can't say I have a solution, but a step in the right direction.

    I tried using ios-webkit-debug-proxy so I can use the Chrome Dev Tools instead of Safari Dev Tools.

    Note, in order to get it to work, I can to upgrade my iOS to the latest 11.4.1 and MacOS 10.13.65, then reinstall the latest versions:

    brew update
    brew install ios-webkit-debug-proxy
    brew reinstall --HEAD libimobiledevice
    brew reinstall -s ios-webkit-debug-proxy
    
    ios_webkit_debug_proxy
    

    After running ios_webkit_debug_proxy, I was able to try to connect through chrome://inspect and it disconnected immediately again:

    Listing devices on :9221
    Connected :9222 to Chet's Phone (6a028994cf281be807bf80c5557c3f2eb3fbb8b0)
    Invalid packet header 0x1ffffff91ffffffa0ffffff9d == .... == 26321053
    Disconnected :9222 from Chet's Phone (6a028994cf281be807bf80c5557c3f2eb3fbb8b0)
    

    However, we have a clue! Invalid packet header. Sounds like a lower level bug somewhere. Not sure where to submit this but to though...

    0 讨论(0)
  • 2021-01-30 10:56

    Do you have a lot of backgrounded apps running on your iPhone? Kill them and try again.

    We showed this issue to Apple developers at WWDC, and they suspected it was due to memory constraints on the iPhone. Sure enough, killing most of our backgrounded apps resolved the issue for us.

    0 讨论(0)
提交回复
热议问题