我有兴趣创建一个基于HTML5地理位置的网络应用程序,当手机屏幕关闭时,该应用程序仍然可以运行(例如,跟踪手机放在口袋里时的运行距离).
有没有办法让应用程序继续运行,但屏幕关闭,或者在使用其他应用程序时让应用程序在后台运行?至少在某些流行的移动设备上是否可行(特别是较新的iOS和Android设备?)
我正在开发一个从头开始用纯JavaScript编写的小型画布游戏.
该游戏涉及类似于此的2d照明算法,但是具有一个光源和25个多边形,这使得每帧大约30,000次计算.
我的帧速率在Safari中非常棒,在Chrome中也是如此,在Firefox中无法播放.但是,如果我在玩游戏时使用Chrome开发人员控制台,则帧速率与Safari相同.
这可能是什么原因?
在评论建议窗口大小可能影响帧速率后,我发现窗口越小,游戏运行越平滑,但仅限于chrome.屏幕上绘制的数量或游戏使用的任何计算完全不依赖于屏幕尺寸.
我只用眼睛测量帧速率差异,你可以在这些gif中看到效果:
糟糕的大窗户:
好,小窗口:
浏览器中的游戏运行比这些GIF中显得更顺畅,但效果仍然明显.
我可以通过我发布的链接中的第一个示例获得相同的效果.它只是我或其他人是否有同样的效果?
更奇怪的是......当我滚动主页时,我在其他几个网站上也有同样的效果,比如Facebook.窗口越大,滚动越陡.这是Chrome特定的东西,是否有人得到类似的结果?
javascript performance html5 google-chrome google-chrome-devtools
我刚刚开始使用mongodb,但是在尝试在集合上使用.find()时遇到了问题.
我创建了一个DataAccessObject,它打开一个特定的数据库,然后让你对它执行操作.这是代码:
该构造函数:
var DataAccessObject = function(db_name, host, port){
this.db = new Db(db_name, new Server(host, port, {auto_reconnect: true}, {}));
this.db.open(function(){});
}
Run Code Online (Sandbox Code Playgroud)
一个getCollection函数:
DataAccessObject.prototype.getCollection = function(collection_name, callback) {
this.db.collection(collection_name, function(error, collection) {
if(error) callback(error);
else callback(null, collection);
});
};
Run Code Online (Sandbox Code Playgroud)
一个保存功能:
DataAccessObject.prototype.save = function(collection_name, data, callback){
this.getCollection(collection_name, function(error, collection){
if(error) callback(error);
else{
//in case it's just one article and not an array of articles
if(typeof (data.length) === 'undefined'){
data = [data];
}
//insert to collection
collection.insert(data, …
Run Code Online (Sandbox Code Playgroud) I'm deploying a Django project on an ubuntu machine using gunicorn and nginx, following this tutorial to do it.
I have a gunicorn service that looks like this, similar to the one in the tutorial:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/project/mysite
EnvironmentFile=/home/ubuntu/.virtualenvs/projectenv/bin/postactivate
ExecStart=/home/ubuntu/.virtualenvs/projectenv/bin/gunicorn --access-logfile - --workers 10 --bind unix:/home/ubuntu/project/mysite.sock mysite.wsgi:application
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
Since, as I understand, the gunicorn service is run in a completely new environment instead of my project's virtual environment I need to find another way …
javascript ×3
html5 ×2
android ×1
database ×1
django ×1
geolocation ×1
gunicorn ×1
ios ×1
mongodb ×1
node.js ×1
performance ×1
python ×1
ubuntu ×1