inspectdev / inspect-issues

Issue tracker for Inspect
23 stars 2 forks source link

iOS Maximum Stack Size Error Hangs Page #193

Closed JavaScriptDude closed 8 months ago

JavaScriptDude commented 8 months ago

I discovered a scenario where the webpage will completely hang when a "maximum stack size exceeded" error occurs.

Here is a basic Javascript that can be put on a web page with this script to illustrate the issue. This works without any issues when there is no debugger attached.

window.onload = function page_loaded(){
    console.log("page_loaded() called!")

    var btTest = document.createElement("button")
    btTest.style.fontSize = "2em"
    btTest.textContent = "CLICK ME"
    document.body.appendChild(btTest)

    btTest.addEventListener("click", function(e) {
        var div = document.createElement("div")
        div.innerText = "Button clicked"
        document.body.appendChild(div)
        console.log("btTest clicked")
        try {
            console.table(e)
        } catch (error) {
            console.log("This will not get logged")
        }
        console.log("This also will not get logged")
    })
}

I believe this stack size exception is related to a limit that apple put on maximum stack sizes several years back.

Hopefully this hanging issue is not on apples side of the fence and can be corrected in the inspectdev toolchain.

JavaScriptDude commented 8 months ago

My Setup is a Mint 21.3 Host with inspect.dev running on a windows Guest on VMWare Workstation.

JavaScriptDude commented 8 months ago

Same issue occurs using inspect.dev from Linux host using latest AppImage file.

It also occurs using the older remotedebug_ios_webkit_adapter from github.

auchenberg commented 8 months ago

Thanks for this report. We have been trying to chase this down but never got a repro. Might be the use of console.tab that fills up the stack. We will dive in

JavaScriptDude commented 8 months ago

No problem.

FYI - I tested this on a bare bones Mac using Chrome and I got the same issue. Since I was not using inspect.dev in that test, I suspect this is not an issue with your stack.

To get around this, I've put guards in my internal logging framework to detect and serialize event objects before sending to console.table.

auchenberg commented 8 months ago

Confirmed that this is Webkit stopping script execution, and not Inspect. Closing for now.