mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
add console logs for debugging extra frame
This commit is contained in:
parent
1b7ef52327
commit
6b1988f100
@ -2528,11 +2528,15 @@ jsPsych.pluginAPI = (function() {
|
|||||||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|
||||||
|
|
||||||
var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
|
var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
|
||||||
|
var raf_count;
|
||||||
module.setTimeout = function(callback, delay){
|
module.setTimeout = function(callback, delay){
|
||||||
// record the start time
|
// record the start time
|
||||||
var start_time = performance.now();
|
var start_time = performance.now();
|
||||||
|
raf_count = 0;
|
||||||
|
console.log('setTimeout start time: ', start_time);
|
||||||
var handle = requestAnimationFrame(function(timestamp) {
|
var handle = requestAnimationFrame(function(timestamp) {
|
||||||
|
raf_count++;
|
||||||
|
console.log('count: ', raf_count, ' time: ', performance.now() - start_time);
|
||||||
// setup the next rAF call to check for timeouts and update handle value
|
// setup the next rAF call to check for timeouts and update handle value
|
||||||
handle = requestAnimationFrame(function(timestamp) {
|
handle = requestAnimationFrame(function(timestamp) {
|
||||||
checkForTimeouts(timestamp, start_time, callback, delay, handle);
|
checkForTimeouts(timestamp, start_time, callback, delay, handle);
|
||||||
@ -2550,7 +2554,9 @@ jsPsych.pluginAPI = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkForTimeouts(timestamp, start_time, callback, delay, handle) {
|
function checkForTimeouts(timestamp, start_time, callback, delay, handle) {
|
||||||
|
raf_count++;
|
||||||
var curr_duration = performance.now() - start_time;
|
var curr_duration = performance.now() - start_time;
|
||||||
|
console.log('count: ', raf_count, ' time: ', curr_duration);
|
||||||
// check if the current duration is at least as long as the intended duration
|
// check if the current duration is at least as long as the intended duration
|
||||||
// minus half the typical frame duration (~16 ms). this helps avoid displaying the stimulus
|
// minus half the typical frame duration (~16 ms). this helps avoid displaying the stimulus
|
||||||
// for one too many frames.
|
// for one too many frames.
|
||||||
|
@ -69,6 +69,7 @@ jsPsych.plugins["html-keyboard-response"] = (function() {
|
|||||||
|
|
||||||
// draw
|
// draw
|
||||||
display_element.innerHTML = new_html;
|
display_element.innerHTML = new_html;
|
||||||
|
console.log('display time: ', performance.now());
|
||||||
|
|
||||||
// store response
|
// store response
|
||||||
var response = {
|
var response = {
|
||||||
@ -97,6 +98,7 @@ jsPsych.plugins["html-keyboard-response"] = (function() {
|
|||||||
|
|
||||||
// clear the display
|
// clear the display
|
||||||
display_element.innerHTML = '';
|
display_element.innerHTML = '';
|
||||||
|
console.log('clear display time: ', performance.now())
|
||||||
|
|
||||||
// move on to the next trial
|
// move on to the next trial
|
||||||
jsPsych.finishTrial(trial_data);
|
jsPsych.finishTrial(trial_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user