RemoteDebug/remotedebug-ios-webkit-adapter

Console.log ad error.log not showing

DStillingfleet opened this issue ยท 14 comments

Hi

Very nice bit of software, I've been looking for a solution to debug iOS safari from my PC for a long time.

However I suspect I'm doing something wrong. Whilst I have a mirror of the website being displayed in Chrome Inspect, and see XHR finished loading messages, I don't see any of the console.logs I have included in my javascript. Nor do I see any error logs when the brower crashes.

Any ideas?

Also, are there any instructions on how to use this for detecting memory leaks? There are no urls to select in the "Select JavaScript instance" section.

Many thanks

Derek

I am having the same issue when using async await.

+1 same issue, only seeing some warnings and not 90% of the console output

Same problem. I see some warnings, but no console logs.

I was able to fix this by making changes in onConsoleMessageAdded function in file ios.ts

Updated piece of code

        let message = msg.params.message;
        let type;
        let method = "Runtime.consoleAPICalled";
        if(message.type === "log") {
            switch(message.level) {
                    case "log": type = "log"; break;
                    case "info": type = "info"; break;
                    case "error": type = "error"; break;
                    default: type = "log";
            }
        } else {
            type = message.type;
        }

        const consoleMessage = {
            source: message.source,
            level: type,
            text: message.text,
            lineNumber: message.line,
            timestamp: (new Date).getTime(),
            url: message.url,
            stackTrace: message.stackTrace ? {
                callFrames: message.stackTrace
            } : undefined,
            args:message.parameters,
            networkRequestId: message.networkRequestId,
        };
        if(type == "error"){
            method = "Log.entryAdded"; 
            this._target.fireEventToTools(method, {entry:consoleMessage});
        }else
            this._target.fireEventToTools(method, consoleMessage);
        
        return Promise.resolve(null);
    }

@anurag-sudo the changes you propose already seem to be part of

npm\node_modules\remotedebug-ios-webkit-adapter\out\test\protocols\ios\ios.js

Copying that file to

npm\node_modules\remotedebug-ios-webkit-adapter\out\protocols\ios\

didn't make the problem go away for me unfortunately. Is there anything else I need to do in order to let this work?

A workaround would be to replace all console.log calls to console.error, as those do seem to be popping up in the console.

@MarByteBeep

I noticed that the file ios.ts in test folder is missing few items that I mentioned above.

  • The method name in the currrent scenario is Log.entryAdded however according to me it should be used for errors type only and for the rest type you can use method as Runtime.consoleAPICalled.

  • In the object consoleMessage there is a new property added args whose value is message.parameters.

  • And finally for logs type error object consoleMessage is wrapped in another object, however thats not the case for other log types. By following these steps I was able to arrive at the solution above.

Can you try these steps and lets see if that works ?

Hi @MarByteBeep

I followed your instructions and yes, I'm now seeing the console log messages.

So to clarify for others I replaced the onConsoleMessageAdded function with your code below in

C:\Users****\AppData\Roaming\npm\node_modules\remotedebug-ios-webkit-adapter\out\protocols\ios\ios.js

onConsoleMessageAdded(msg){
        let message = msg.params.message;
        let type;
        let method = "Runtime.consoleAPICalled";
        if(message.type === "log") {
            switch(message.level) {
                    case "log": type = "log"; break;
                    case "info": type = "info"; break;
                    case "error": type = "error"; break;
                    default: type = "log";
            }
        } else {
            type = message.type;
        }

        const consoleMessage = {
            source: message.source,
            level: type,
            text: message.text,
            lineNumber: message.line,
            timestamp: (new Date).getTime(),
            url: message.url,
            stackTrace: message.stackTrace ? {
                callFrames: message.stackTrace
            } : undefined,
            args:message.parameters,
            networkRequestId: message.networkRequestId,
        };
        if(type == "error"){
            method = "Log.entryAdded"; 
            this._target.fireEventToTools(method, {entry:consoleMessage});
        }else
            this._target.fireEventToTools(method, consoleMessage);
        
        return Promise.resolve(null);
}

Many thanks

Derek

@DStillingfleet before closing it, shouldn't this be part of a fix? Now the devs might think that this isn't an issue anymore, while the bug is still present in the codebase.

@DStillingfleet bug still exists, no console.log() lines show up

I've reopened the issue so that the developers can see it.

Console logs still don't show. Looks like the fix didn't help after all. I'm using version 0.4.2

Fix from @anurag-sudo still works and still not included into latest version.

This project is now super-seeded by https://inspect.dev/ โ€“ a new developer tool for macOS and Windows to inspect and debug your web apps and websites in Safari and WebViews on iOS devices.

RemoteDebug iOS WebKit Adapter is not proactively maintained or extended.