GazePoint - OpenSesame: lxml.etree.XMLSyntaxError extracontent
Hi everyone!
I am a 1st year PhD student at La Sapienza University of Rome and I am using OpenSesame 3.3.14 running with Python 3.7 and GazePoint 6.9.0.
In my experiments including PyGaze, I start by downloading the lxml library as suggested in a previous thread (https://forum.cogsci.nl/discussion/4171/gazepoint-control-version-4-2-0-used-with-pygaze-and-opensesame-calibration-error).
However, when running any of the PyGaze experiments (with admin privileges), I got the following exception:
Exception in thread PyGaze_OpenGazeConnection_incoming: Traceback (most recent call last): File "C:\Program Files (x86)\OpenSesame\lib\threading.py", line 926, in _bootstrap_inner self.run() File "C:\Program Files (x86)\OpenSesame\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\pygaze\_eyetracker\opengaze.py", line 412, in _process_incoming command, msgdict = self._parse_msg(msg) File "C:\Program Files (x86)\OpenSesame\Lib\site-packages\pygaze\_eyetracker\opengaze.py", line 335, in _parse_msg e = lxml.etree.fromstring(xml) File "src\lxml\etree.pyx", line 3257, in lxml.etree.fromstring File "src\lxml\parser.pxi", line 1916, in lxml.etree._parseMemoryDocument File "src\lxml\parser.pxi", line 1796, in lxml.etree._parseDoc File "src\lxml\parser.pxi", line 1085, in lxml.etree._BaseParser._parseUnicodeDoc File "src\lxml\parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc File "src\lxml\parser.pxi", line 728, in lxml.etree._handleParseResult File "src\lxml\parser.pxi", line 657, in lxml.etree._raiseParseError File "<string>", line 2 lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 2, column 1
[ Note: in other cases, apparently randomly, the last line of the exception is lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1]
So it seems like there is an issue when reading/writing the xml file with the gaze coordinates.
Actually, the experiment keeps going, however it keeps lagging and bugging, being overall extremely slow. The bug starts from the calibration phase.
Can anybody help me to figure this out?
Thanks
Elena
Comments
Hi @_elena_ ,
Thanks for reporting this! We've done quite a bit of work on improving support for the GazePoint, but it's still pretty rocky. As a first step, let's try to figure out where this error comes from. If you open C:\Program Files (x86)\OpenSesame\Lib\site-packages\pygaze\_eyetracker\opengaze.py in a text editor and modify
_parse_msg()
around line 335 like this:This won't fix the issue, but it will print out the offending XML message. This should help to see what's wrong.
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan!
Thanks for your quickly reply :)
This is what I got after modifying "_parse_msg()":
Regards,
Elena
@_elena_ Thanks. It seems that the
xml
string contains two messages, rather than one, probably because they haven't been properly split. I think that's easy to fix, but again you'll have to test this for me because I don't experience this myself (maybe because for some reason messages rarely need to be split on our system). Around line 395 inopengaze.py
you will see this:Change this to:
Does this resolve the issue? (Or at least this particular issue.)
Check out SigmundAI.eu for our OpenSesame AI assistant!
@sebastiaan thank you again!
Unfortunately, after this replacement, I ran the experiment several times but the error message was always
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
.By contrast, I haven't seen the message
lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 2, column 1
since I made this last change.Hi @sebastiaan,
trying to figure out where the problem is, I printed the message to the console. It seems that something irregular is going on in splitting strings (see attached for the entire console output):
Using both versions of the message (
instring.split('\r\n')
andinstring.splitlines()
) I got the same output.Hope this can help you.
Thanks,
Elena
Hi @_elena_ ,
It's still difficult to tackle this, because I don't experience the issues myself. (Although I do experience the slowness, which is annoying.) What version of the OpenGaze SDK are you using? The latest version at the time of writing is 6.9.0, which is also what I'm using.
The fact that the messages are split is not the issue, or at least I don't think so. This simply results from the fact that messages arrive in chunks, which are then re-assembled.
Instead, the error message that you now see:
Is due to a message being completely empty. Perhaps this can be resolved simply by removing all empty lines during splitting, like so (again around line 395 in
opengaze.py
):— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan, thank you again!
This line solved the problem regarding the error message:
However, the experiment keeps lagging with my gaze contingency
inline_script
and runs correctly when I remove it (maybe the problem is due to if statements and while loops to be executed) .I am programming an eye-tracking change-detection experiment using the
inline_script
object to set a gaze-contingent duration of the encoding phase:contains() function is defined in another
inline_script
as helper function:The experiment runs and finishes correctly on a laptop which is much less performing than the pc where I'm experiencing this issue. Of course, versions of Windows, OpenSesame and GazePoint are the same in both computers.
I still can't figure out what's the problem.
Thank you in advance,
Elena
Hi @elena ,
However, the experiment keeps lagging with my gaze contingency
inline_script
and runs correctly when I remove it (maybe the problem is due to if statements and while loops to be executed) . (…) The experiment runs and finishes correctly on a laptop which is much less performing than the pc where I'm experiencing this issue.To narrow the issue down (if you haven't already), I would first test the gaze-contingency in the experiment with advanced dummy mode in
pygaze_init
. If the experiment also reacts slowly to the eye movements (which I assume is what you mean with laggy?) when the GazePoint is not connected, then clearly the problem is not the GazePoint. But if the experiment only reacts slowly when it is actually connected to the GazePoint, then of course the issue lies there.— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan, thank you again!
With advance dummy mode the experiment with gaze-contingency script runs correclty, therefore the problem concerns the connection with GazePoint.
Could you please give me some guidance on this issue?
Regards,
Elena
Hi @sebastiaan,
I finally managed to run the experiment on a third PC and the line
was essential to make it work properly. I think the issue was linked to the touchscreen monitor.
Anyway, hope this information can be useful to you.
I will be back in touch if there are other problems.
Thanks a lot.
Cheers,
Elena
@_elena_ Thanks, this is very useful 👍️ We'll include that fix in the next maintenance release of PyGaze.
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan,
I’m writing on this thread cause I’m having other issues with this experiment.
After all your suggestions, I managed to get it to run correctly on a pc (Windows 11, OpenSesame 3.3.14, GazePoint 6.9.0)
However, with another pc (same Windows, OpenSesame and GazePoint versions) the experiment runs correctly for some trials but then slows down (like few months ago) and I get the following error message on the console:
There should be some problem with the PyGaze library, but I can't figure out exactly what is it.
Could you please help me with this issue?
Thanks in advance,
Elena