Chrome违规:[Violation]处理程序花费了83ms的运行时间 [英] Chrome violation : [Violation] Handler took 83ms of runtime

查看:96
本文介绍了Chrome违规:[Violation]处理程序花费了83ms的运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中实现Facebook的注销功能.登录就可以了.但是我面临着带有注销代码的JavaScript控制台中的以下消息.

I'm trying to implement the Facebook's logout functionality in my project. Login works just fine. But I'm facing the getting the following message in JavaScript console with the logout code.

[违规]长时间运行的JavaScript任务花费了318ms session.php:51 1 sdk.js:135

[Violation] Long running JavaScript task took 318ms session.php:51 1 sdk.js:135

[Violation]处理程序花费了83ms的运行时间(允许50ms)

[Violation] Handler took 83ms of runtime (50ms allowed)

我尝试搜索其他类似的线程,但这些解决方案对我而言并不奏效.我试着删除部分代码,然后看看哪个部分出了问题.很明显,由于消息中显示的Facebook的JS SDK,它收到了错误.我还禁用了我所有的Chrome扩展程序.

I've tried to search for other similar threads and those solutions didn't work out for me. I tried removing parts of my code and see which part is giving problem. Its quite clear that its getting the error due to Facebook's JS SDK as seen in the message. I've also disabled all of my Chrome extensions.

该代码在Firefox中运行正常,但在Chrome中也不在Opera中运行.我有什么方法可以延长此超时时间吗?或任何其他方法可修复Chrome中的此问题.这是我的注销代码.

The code works fine in Firefox but not in Chrome, nor in Opera. Is there any method for me to extend this timeout duration? Or any other method to fix this issue in chrome. Here is my code for logout.

<?php
    session_start();
    //echo $_SESSION["current_user"];
    //echo $_COOKIE["current_user"];
    session_destroy();
    unset($_COOKIE["current_user"]);
    setcookie("current_user","",time() -3600, "/","", 0);
    //header("location: login.php");
?>

<!doctype html>

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

<script>

    // Default settings
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '<app-id>',
            cookie     : true,
            xfbml      : true,
            version    : 'v2.8'
        });
        FB.AppEvents.logPageView();   
    };

    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

    window.onload = function(){
        logout();
    }
    function logout(){
        console.log("1");
        FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            FB.logout();
            console.log("2");
            window.location="login.php";
            console.log("3");
        }
        else{
            console.log("4");
            window.location="login.php";
            console.log("5");
        }
        });
    }
</script>
</body>
</html>

出于明显的原因,我从代码中删除了App-Id.任何帮助表示赞赏. :)

For obvious reasons I've removed the App-Id from the code. Any help is appreciated. :)

推荐答案

"Chrome违规"不代表Chrome或您自己的网络应用程序中的错误.相反,它们是警告,可以帮助您改善应用程序.在这种情况下,Long running JavaScripttook 83ms of runtime会提醒您可能有机会加速脚本.

"Chrome violations" don't represent errors in either Chrome or your own web app. They are instead warnings to help you improve your app. In this case, Long running JavaScript and took 83ms of runtime are alerting you there's probably an opportunity to speed up your script.

("Violation"不是最好的术语;在这里用来暗示脚本违反"预定义的准则,但是警告"或类似的词会更清晰.这些消息最早于2017年初出现在Chrome中,应该理想情况下,会显示更多信息"提示以详细说明含义并向开发人员提供建议的操作.希望将来会添加这些操作.)

("Violation" is not the best terminology; it's used here to imply the script "violates" a pre-defined guideline, but "warning" or similar would be clearer. These messages first appeared in Chrome in early 2017 and should ideally have a "More info" prompt to elaborate on the meaning and give suggested actions to the developer. Hopefully those will be added in the future.)

这篇关于Chrome违规:[Violation]处理程序花费了83ms的运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆