Page MenuHome

X3D import is broken
Closed, ResolvedPublic

Description

System Information
Operating system: Win10 x64
Graphics card: Nvidia 1070

Blender Version
Broken:
version: 2.79 (sub 6), branch: blender2.8, commit date: 2018-12-14 16:39, hash: 4e3562f45ad, type: Release
build date: 14/12/2018, 17:17

Short description of error
Exporting Suzanne (or any other object) and importing Suzanne.x3d back results in broken import process. I tried this many times. I cant tell if this is an issue with the export or the import. The file format looks fine.

Exact steps for others to reproduce the error

  • Add Suzanne or any other object
  • Open export menu (file) and choose x3d
  • Choose selected (defaults produce the same result)
  • Give and name and export
  • Import the exported .x3d from the "import" menu.

And you should get something like this

location: <unknown location>:-1
Info: starting X3D export to 'T:\\tmo\\_tmp_local\\untitled.x3d'...
Info: finished X3D export to 'T:\\tmo\\_tmp_local\\untitled.x3d'
Traceback (most recent call last):
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 956, in send
    self.connect()
  File "C:\dev\blender-nightly\2.79\python\lib\http\client.py", line 928, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\dev\blender-nightly\2.79\python\lib\socket.py", line 727, in create_connection
    raise err
  File "C:\dev\blender-nightly\2.79\python\lib\socket.py", line 716, in create_connection
    sock.connect(sa)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\dev\blender-nightly\2.79\scripts\addons\io_scene_x3d\__init__.py", line 81, in execute
    return import_x3d.load(context, **keywords)
  File "C:\dev\blender-nightly\2.79\scripts\addons\io_scene_x3d\import_x3d.py", line 3601, in load
    global_matrix=global_matrix,
  File "C:\dev\blender-nightly\2.79\scripts\addons\io_scene_x3d\import_x3d.py", line 3468, in load_web3d
    root_node, msg = x3d_parse(filepath)
  File "C:\dev\blender-nightly\2.79\scripts\addons\io_scene_x3d\import_x3d.py", line 1443, in x3d_parse
    doc = xml.dom.minidom.parseString(data, parser)
  File "C:\dev\blender-nightly\2.79\python\lib\xml\dom\minidom.py", line 1972, in parseString
    {'parser': parser})
  File "C:\dev\blender-nightly\2.79\python\lib\xml\dom\minidom.py", line 1949, in _do_pulldom_parse
    toktype, rootNode = events.getEvent()
  File "C:\dev\blender-nightly\2.79\python\lib\xml\dom\pulldom.py", line 259, in getEvent
    self.parser.feed(buf)
  File "C:\dev\blender-nightly\2.79\python\lib\xml\sax\expatreader.py", line 217, in feed
    self._parser.Parse(data, isFinal)
  File "..\Modules\pyexpat.c", line 666, in ExternalEntityRef
  File "C:\dev\blender-nightly\2.79\python\lib\xml\sax\expatreader.py", line 413, in external_entity_ref
    "")
  File "C:\dev\blender-nightly\2.79\python\lib\xml\sax\saxutils.py", line 364, in prepare_input_source
    f = urllib.request.urlopen(source.getSystemId())
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 543, in _open
    '_open', req)
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 1345, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\dev\blender-nightly\2.79\python\lib\urllib\request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions>

Related Objects

Event Timeline

kursad k (kursadk) updated the task description. (Show Details)
kursad k (kursadk) renamed this task from X3D is broken to X3D import is broken.
Philipp Oeser (lichtwerk) triaged this task as Needs Information from User priority.

Cannot reproduce here.

Havent looked at the code, but as it seems to have to do with permissions [or another process using that port already]

  • Could you try running blender with "Run as administrator"?
  • Try (temporarily) disabling antivirus?
  • any other known process blocking a port possibly?

Marking as incomplete until we have those tried...

Brecht Van Lommel (brecht) raised the priority of this task from Needs Information from User to Confirmed, Medium.

It can be reproduced by disabling your network connection. Any code that does network access needs to handle exceptions.

Maybe we don't really need network access to import an X3D file? Not sure if the DTD's are needed for parsing or just some validation that we don't care about.

Seems like this is only done for reporting the linenumbers... [without this x3d import is heaps quicker btw...]
Assume this is taken from here https://stackoverflow.com/questions/4789171/python-reporting-line-column-of-origin-of-xml-node

Not sure if this parser = xml.sax.make_parser() can be tweaked to not require a network connection though...

we could encapsulate with try/except urllib.error.URLError?
(and in that case just parse without this special parser?)
(that would require some tweaks in the code to not hadle/report linenumbers then...)

This seems to do the trick:

1
2
3diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
4index 903222cf..efcbb64e 100644
5--- a/io_scene_x3d/import_x3d.py
6+++ b/io_scene_x3d/import_x3d.py
7@@ -1413,6 +1413,7 @@ def x3d_parse(path):
8 """
9 import xml.dom.minidom
10 import xml.sax
11+ from xml.sax import handler
12
13 '''
14 try: doc = xml.dom.minidom.parse(path)
15@@ -1438,6 +1439,8 @@ def x3d_parse(path):
16
17 parser = xml.sax.make_parser()
18 orig_set_content_handler = parser.setContentHandler
19+ parser.setFeature(handler.feature_external_ges, False)
20+ parser.setFeature(handler.feature_external_pes, False)
21 parser.setContentHandler = set_content_handler
22
23 doc = xml.dom.minidom.parseString(data, parser)

kursad k (kursadk) added a comment.EditedJan 31 2019, 5:15 PM

It can be reproduced by disabling your network connection. Any code that does network access needs to handle exceptions.

Really good catch! My desktop indeed does not have any internet connection, well rather has very restricted firewall, so Blender or any other spawn processes can`t make non Lan connections

I did not think about mentioning it in the original report.

@John W Carlson (yottzumm) : no, this still needs additional porting to 2.8...