console.log may not print

Asked 2 years ago, Updated 2 years ago, 95 views

We are making a trial production of an app for iPhone in Monaca Cloud.
When I run the following code in the iPhone monaca debugger, neither success nor error appears in the App Log.If you remove the alert comment and issue an alert, the App Log will also be displayed.

I thought it might be unstable because there were times when it was difficult to track the code because there were no items to appear in the App Log, but I think I have created a pattern to reproduce clearly this time.

"Maybe it's my ignorance, but I'm afraid, but I'll be prepared to scold you and ask you questions."
If you know anything, please take good care of me.

iPhone 5/iOS 8.1.3, Monaca Debugger 4.0.0, Cordova 4.1.0 Platform 3.7.0

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<!DOCTYPE HTML>
<html>
<head>
    <metacharset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scale=no">
    <script src="components/loader.js"></script>
    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="css/style.css">

    <!--user-->
    <script>
        "use strict";
        document.addEventListener('DOMContentLoaded', function(){
                document.addEventListener('deviceready', onDeviceReady);
            });
        
        function onDeviceReady() {
            console.log('start');

            navigator.device.capture.captureVideo(function(mediaFiles){
                // alert('success');
                console.log('success');
            }, function(){
                // alert('error');
                console.log('error');
            }, {limit:1, duration:120});
        }
    </script>
    <!--user-->

</head>
<body>
</body>
</html>

May 1, 2015 at 9:00 p.m. Additional
When I tried it, both success and error were executed in the following code, and there was no 1

.

function onDeviceReady(){
  console.log('start');

  navigator.device.capture.captureVideo(function(mediaFiles){
    console.log('success');
    alert('success2');
    console.log('success3');
  }, function(){
    console.log('error');
    alert('error2');
    console.log('error3');
  }, {limit:1, duration:120});
}

May 1, 2015 10:00 postscript
I tried setTimeout to see if it was another callback, but there was no problem.

However, when we implemented setTimeout and captureVideo at the same time as the code below, if the video had finished when the timeout occurred, the log would show timeout 1,3, but not when the video was running.

From this, I imagine that the console.log does not output during or immediately after captureVideo.
I don't know if it's a specification, a defect, or a mistake, so please let me know if you know anything.

It was the same in camera.I will add cordova to the tag.

function onDeviceReady(){
  console.log('start');

  setTimeout(function(){
    console.log('timeout1');
    alert('timeout2');
    console.log('timeout3');
  }, 1000);

  navigator.device.capture.captureVideo(function(mediaFiles){
    console.log('success1');
    alert('success2');
    console.log('success3');
  }, function(){
    console.log('error1');
    alert('error2');
    console.log('error3');
  }, {limit:1, duration:120});
}

May 1, 2015 12:00 postscript

I learned that there is a plug-in called cordova-plugin-console.I'd like to try
If monaca is not a GOLD plan, it seems that the cordova plug-in cannot be added, so I cannot try it now.

monaca cordova

2022-09-30 16:00

2 Answers

Does it mean that console.log has a filter function, so it is not output?


2022-09-30 16:00

You can read alert() or setTimeout() as successful by delaying execution timing.
Why don't you follow the Cordova documentation and wait until onload?

Dear Re:TRNK,


2022-09-30 16:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.