Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can not see console.log messages on logcat after upgrading to android@10.1.2 #1472

Closed
pliniofm opened this issue Aug 5, 2022 · 4 comments

Comments

@pliniofm
Copy link

pliniofm commented Aug 5, 2022

Bug Report

Problem

What is expected to happen?

In the previous Android Platform (8.1.0), I can reach the logs from console.log, using the command below:

adb logcat -v raw chromium:D SystemWebViewClient:D *:S

And it worked fine.

I updated Android Platform to an intermediate version and I had to change the command to: (sorry for do not remember the version)

adb logcat -v raw chromium:D SystemWebViewClient:D SystemWebChromeClient:D *:S

And it worked fine too.

What does actually happen?

I upgraded to Android Platform 10.1.2 and I cannot see my logs from console.log using the commands above.

I tried to catch all logs and looking for them after. But it didn't work.

adb logcat -v long > log.txt

I tried to ask for all logs from PID. I can see some log messages from plugins and others components, but I cannot see my console.log messages.

adb logcat -v long --pid=5111 *:V
[ 08-05 09:10:01.246  5111: 5144 W/System   ]
A resource failed to call close.

[ 08-05 09:10:01.328  5111: 5325 D/AudioPlayer ]
on completion is calling stopped

[ 08-05 09:10:02.505  5111: 5325 W/AudioManager ]
Use of stream types is deprecated for operations other than volume control

[ 08-05 09:10:02.505  5111: 5325 W/AudioManager ]
See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case

[ 08-05 09:10:02.506  5111: 5325 W/PluginManager ]
THREAD WARNING: exec() call to Media.startPlayingAudio blocked the main thread for 21ms. Plugin should use CordovaInterface.getThreadPool().

[ 08-05 09:10:02.507  5111: 5325 D/AudioPlayer ]
Send a onStatus update for the new seek

[ 08-05 09:10:03.248  5111: 5325 D/AudioPlayer ]
on completion is calling stopped

[ 08-05 09:10:13.910  5111: 5144 W/System   ]
A resource failed to call close.

[ 08-05 09:11:59.741  5111: 5111 I/FIAM.Display ]
Unbinding from activity: MainActivity

[ 08-05 09:11:59.741  5111: 5111 I/FIAM.Headless ]
Removing display event component

[ 08-05 09:11:59.741  5111: 5111 D/CordovaActivity ]
Paused the activity.

[ 08-05 09:11:59.764  5111: 5325 D/AudioPlayer ]
AudioPlayer Error: pausePlaying() called during invalid state: 3

[ 08-05 09:12:00.233  5111: 5111 D/CordovaActivity ]
Stopped the activity.

Has anyone had the same issue? What am I doing wrong? Or is it a bug?

Version information

Android Platform 10.1.2 (from cordova platform list)
Cordova CLI 11.0.0 (from cordova -v)
Android SDK 30
Android 10 (my mobile version)
Windows 10 (where is the SDK and logcat)

@breautek
Copy link
Contributor

breautek commented Aug 6, 2022

I'm unable to reproduce this on cordova-android@10 or cordova-android@11. I see log messages from chromium in logcat.

08-05 22:43:32.827  8768  8768 I chromium: [INFO:CONSOLE(31)] "LOG FROM CHROMIUM", source: https://localhost/js/index.js (31)

I have this log running on an interval. Are you sure you're actually logging something? I'd open the chrome web inspector to see.

@breautek breautek added the info-needed / awaiting response Further information is requested label Aug 6, 2022
@pliniofm
Copy link
Author

pliniofm commented Aug 7, 2022

For each initialized plugin, I log a message for success and for fail. I am sure I am logging some messages.

I guess I've found the problem.

According to Android documentation (link below), it needed to be implemented "onConsoleMessage" on a WebChromeClient.

https://developer.android.com/guide/webapps/debugging#WebView

I included manually this method locally in my environment, and it worked fine.

> adb logcat -v threadtime chromium:D SystemWebViewClient:D SystemWebChromeClient:D *:S
--------- beginning of crash
--------- beginning of system
--------- beginning of main
08-07 17:57:36.469 26669 26669 D SystemWebChromeClient: https://localhost/js/labels.js: Line 321 : Language (window.localStorage.lang): pt
08-07 17:57:37.054 26669 26669 D SystemWebChromeClient: https://localhost/js/index.js: Line 16 : Event [onload page]
08-07 17:57:37.054 26669 26669 D SystemWebChromeClient: https://localhost/js/notification.js: Line 18 : [notification.local] NOT FOUND
08-07 17:57:37.055 26669 26669 D SystemWebChromeClient: https://localhost/js/stats.js: Line 20 : firebase initCrashlytics: not found
08-07 17:57:37.055 26669 26669 D SystemWebChromeClient: https://localhost/js/stats.js: Line 33 : firebase initAnalytics: not found
08-07 17:57:37.055 26669 26669 D SystemWebChromeClient: https://localhost/js/stats.js: Line 46 : firebase initPerformance: not found
08-07 17:57:37.056 26669 26669 D SystemWebChromeClient: https://localhost/js/utils.js: Line 43 : [Insomnia] keepAwake call...
08-07 17:57:37.059 26669 26669 D SystemWebChromeClient: https://localhost/js/stats.js: Line 215 : Device info: 10.1.2
. . .

But it was removed from Cordova in his commit below.

6d451bc

Please, could you give me the context for this commit? I will try to fix my environment to work without this method.

@breautek
Copy link
Contributor

breautek commented Aug 8, 2022

Please, could you give me the context for this commit? I will try to fix my environment to work without this method.

Regarding 6d451bc I was the one who committed but it's been awhile but if I recall correctly, Cordova logged to logcat, then proceeded to the super, which would also call to logcat, resulting in duplicate logging.

The relevant PR can be found at #950 which has comments describing your issue, I think. It seems like the base class only logs to logcat while the app is in debug mode, but does nothing in release mode.

Can you confirm that your issue only occurs while your app is in release mode? Do you get log messages in logcat while the app is in debug mode? If so, #950 (comment) would likely be a path forward.

@pliniofm
Copy link
Author

pliniofm commented Aug 8, 2022

Bingo, that is the point.

In debug mode, it worked. Another log format. but it works. In release mode, it does not show any log. Ok. Now, it is clear.

>adb logcat -v raw chromium:D SystemWebViewClient:D SystemWebChromeClient:D *:S
--------- beginning of crash
--------- beginning of system
--------- beginning of main
08-07 23:33:10.873 26032 26032 I chromium: [INFO:CONSOLE(321)] "Language (window.localStorage.lang): pt", source: https://localhost/js/labels.js (321)
08-07 23:33:11.461 26032 26032 I chromium: [INFO:CONSOLE(16)] "Event [onload page]", source: https://localhost/js/index.js (16)
08-07 23:33:11.461 26032 26032 I chromium: [INFO:CONSOLE(18)] "[notification.local] NOT FOUND", source: https://localhost/js/notification.js (18)
08-07 23:33:11.462 26032 26032 I chromium: [INFO:CONSOLE(20)] "firebase initCrashlytics: not found", source: https://localhost/js/stats.js (20)
08-07 23:33:11.462 26032 26032 I chromium: [INFO:CONSOLE(33)] "firebase initAnalytics: not found", source: https://localhost/js/stats.js (33)
08-07 23:33:11.462 26032 26032 I chromium: [INFO:CONSOLE(46)] "firebase initPerformance: not found", source: https://localhost/js/stats.js (46)
08-07 23:33:11.462 26032 26032 I chromium: [INFO:CONSOLE(43)] "[Insomnia] keepAwake call...", source: https://localhost/js/utils.js (43)
08-07 23:33:11.466 26032 26032 I chromium: [INFO:CONSOLE(215)] "Device info: 10.1.2", source: https://localhost/js/stats.js (215)

I will close this issue. Thank you very much.

@pliniofm pliniofm closed this as completed Aug 8, 2022
@breautek breautek removed the info-needed / awaiting response Further information is requested label Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants