Hosting PyAlembic example abcview viewer widget in Houdini

531 views
Skip to first unread message

Sam Hodge

unread,
Jun 11, 2016, 7:59:57 PM6/11/16
to alembic-discussion
Hi

Recently I have a use case where I need users to have an interactive OpenGL pick session of the contents of an Alembic archive inside Houdini to return a path to a PyQt4 (PySide) application hosted within Houdini.

So abcview's viewer widget seems to fit the bill.

But I get terrible performance of the PySide OpenGL window hosted in Houdini.

I feel I am doing something wrong.

In pure Python I get 60fps approx, in Houdini I get lag and then 2fps.

Can someone confirm they see similar behaviour.

My only test environment is a proprietary setup at my workplace. Where the PATH , LD_LIBRARY_PATH and PYTHONPATH are a combination of PySide from SideFX, Alembic from SideFX and custom built, Qt from SideFX, and Python interpreter from SideFX.

I will post a test script if there are any Houdini Alembic users up for testing.

Thanks in advance for any help, I have contacted SESI but they haven't been able to help as they are unfamiliar with PyAlembic.

Sam

Sam Hodge

unread,
Jun 13, 2016, 10:15:52 PM6/13/16
to alembic-discussion
OK

so if you save this into a file called example.py


import abcview.widget.viewer_widget
from PyQt4 import QtGui
import sys

import os
import sys
import math
import traceback
from functools import wraps

from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4 import uic
from PyQt4 import QtOpenGL

import numpy
import numpy.linalg as linalg
import OpenGL
OpenGL.ERROR_CHECKING = True
from OpenGL.GL import *
from OpenGL.GLU import *

# flag opengl errors
from OpenGL.arrays import numpymodule
numpymodule
.NumpyHandler.ERROR_ON_COPY = True

import imath
import alembic

import abcview
from abcview.io import Mode
from abcview.gl import GLCamera, GLICamera, GLScene
from abcview.gl import get_final_matrix
from abcview import log, style, config

class MyGLWidget(abcview.widget.viewer_widget.GLWidget):
   
def __init__(self, parent=None,state=None):
        abcview
.widget.viewer_widget.GLWidget.__init__(self,parent=parent,state=state)
   
def mouseDoubleClickEvent(self, event):
       
"""
        mouse double-click event handler
        """

       
if self.camera.mode == Mode.OFF:
           
return

       
# get scene selection hits
        hit
= None
       
for scene in self.state.scenes:
           
if scene.mode == Mode.OFF or not scene.visible:
               
continue
            x
, y = event.pos().x(), event.pos().y()
            camera
= self.camera.views[self]
            hit
= scene.selection(x, y, camera)

       
       
#HACK: need a better/faster way to find the object
       
if hit:
           
print "Shape node is called:", hit
            name
= hit.split("/")[-1]
           
self.signal_object_selected.emit(".*%s" % name)        

if __name__ == "__main__" and len(sys.argv) == 2:
    app
= QtGui.QApplication(sys.argv)
    blah
= MyGLWidget()
    blah
.add_file(sys.argv[1])
    blah
.show()
    sys
.exit(app.exec_())
else:
   
print "Usage: %s filename.abc" % sys.argv[0]

then you can do both

hython /path/to/octopus.abc

python /path/to/octopus.abc

and see which rough FPS you get out of houdini and out of the system Python.

Does anyone have any thoughts about making abcview support both PyQt4 and PySide out of the box?

Sam

Sam Hodge

unread,
Jun 13, 2016, 10:18:08 PM6/13/16
to alembic-discussion
of course I made a mess of that

hython example.py /path/to/octopus.abc

python example.py /path/to/octopus.abc

Sam Hodge

unread,
Jun 13, 2016, 10:58:13 PM6/13/16
to alembic-discussion
I accidentally tested with hython from Houdini 11 and got full frame rate, but with Houdini 15.0.459 I get bad performance.

Sam Hodge

unread,
Jun 13, 2016, 11:42:31 PM6/13/16
to alembic-discussion
Looking more closely Houdini 11 doesnt have Alembic .so files in its install.

So I guess what I am looking at it both SESI Alembic .so files being loaded AND, hand built Alembic .so files being loaded.

But I see that we could have clashes for GLEW, Alembic, IlmBase etc between the various /software paths and the houdini /software/houdini/15.0.459-
build3/arch/linux-any/x86_64/dsolib path.

So I guess the question comes down to how best manage custom installed versions of Alembic and the factory Houdini versions.

I think that Houdini is on IlmBase 2.2, where as the custom installed versions are 2.0

Would this result in no segfault but slow performance?

Sam

Lucas Miller

unread,
Jun 14, 2016, 12:11:54 PM6/14/16
to alembic-d...@googlegroups.com
> I think that Houdini is on IlmBase 2.2, where as the custom installed
> versions are 2.0
>
> Would this result in no segfault but slow performance?

Probably not. I would guess that it had more to do with GLEW or some
other related graphics issue.

Alvaro Castaneda

unread,
Jun 14, 2016, 12:31:20 PM6/14/16
to alembic-d...@googlegroups.com
I know that SideFX Switched to PySide in version 14 if I remember correctly, that might have something to do as well


--
You received this message because you are subscribed to the Google Groups "alembic-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alembic-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Hodge

unread,
Jun 14, 2016, 5:11:46 PM6/14/16
to alembic-discussion
I profiled it with Zoom (http://www.rotateright.com/)  and it was spending a lot of time ~50% in the destructor for https://github.com/alembic/alembic/blob/master/lib/Alembic/AbcCoreOgawa/CprImpl.h

which is 

CprData::~CprData()
{
if ( m_propertyHeaders )
{
delete [] m_propertyHeaders;
}
}

from 



Anyhow, if anybody want to give my test a go with hython, I would be really really really happy to hear any results.

I am meant to be working on other things today, but if I get a chance I will compile Alembic against PyIlmbase 2.2 and IlmBase 2.2 and OpenEXR 2.2

and put that in the PATH/LD_LIBRARY_PATH and profile it and see where the time is being spent.

It could be that the event loop with modifier keys is the issue, you need to hold down ALT to tumble the viewport.

Anyway, we have some tools to do further dissection of the problem, so I haven't lost hope.

Sam Hodge

unread,
Jun 14, 2016, 5:19:39 PM6/14/16
to alembic-discussion
obviously with this example you need the source for abcview in your python path.

Lucas Miller

unread,
Jun 14, 2016, 5:23:15 PM6/14/16
to alembic-d...@googlegroups.com
Hmmmm, that looks like something isn't holding onto the properties.

Is something walking the hierarchy over and over, and then throwing
the results away?

Lucas

Sam Hodge

unread,
Jun 14, 2016, 7:49:05 PM6/14/16
to alembic-discussion
Shouldnt imagine it would be:

it is in

https://github.com/alembic/alembic/blob/master/python/examples/AbcView/lib/abcview/widget/viewer_widget.py

probably within this decorator

def update_camera(func):
    """
    GL camera update decorator
    """
    @wraps(func)
    def with_wrapped_func(*args, **kwargs):
        func(*args, **kwargs)
        wid = args[0]
        wid.camera.apply()
        wid.updateGL()
        wid.signal_camera_updated.emit(wid.camera)
        wid.state.signal_state_change.emit()
    return with_wrapped_func

within

@update_camera def mouseMoveEvent(self, event): """ mouse move event handler """ # alt key is required to move the camera if not event.modifiers() & QtCore.Qt.AltModifier: return newPoint2D = event.pos() if ((newPoint2D.x() < 0) or (newPoint2D.x() > self.width()) or (newPoint2D.y() < 0) or (newPoint2D.y() > self.height())): return value_y = 0 newPoint_hitSphere, newPoint3D = self.map_to_sphere(newPoint2D) dx = float(newPoint2D.x() - self.__last_p2d.x()) dy = float(newPoint2D.y() - self.__last_p2d.y()) w = float(self.width()) h = float(self.height()) self.makeCurrent() if (((event.buttons() & QtCore.Qt.LeftButton) and (event.buttons() & QtCore.Qt.MidButton)) or (event.buttons() & QtCore.Qt.LeftButton and event.modifiers() & QtCore.Qt.ControlModifier) or (event.buttons() & QtCore.Qt.RightButton and event.modifiers() & QtCore.Qt.AltModifier)): self.camera.dolly(dx, dy) elif (event.buttons() & QtCore.Qt.MidButton or (event.buttons() & QtCore.Qt.LeftButton and event.modifiers() & QtCore.Qt.ShiftModifier)): self.camera.track(dx, dy) elif event.buttons() & QtCore.Qt.LeftButton: self.__rotating = True self.camera.rotate(dx, dy) # TODO: replace with global state (with these as attrs) self.__last_p2d = newPoint2D self.__last_p3d = newPoint3D self.__last_pok = newPoint_hitSphere

So that shouldnt be hammering through reloading the file as far as I can see.

Sam Hodge

unread,
Jul 3, 2016, 11:51:53 PM7/3/16
to alembic-discussion
I seems that the Qt in Houdini 15 used a modified Qt 4.8.5 one of the modifications is to change the mouse events so that they are compressed for smoother painting.

This makes the PyQt4 or PySide window from abcview, laggy and horrible when using the mouse to rotate the view.

here is the work around from SideFX

set an environment variable called QT_MOUSE_COMPRESS_LIMIT to greater than 0, values in the range 5-100 seems to work well.



On Sunday, June 12, 2016 at 9:29:57 AM UTC+9:30, Sam Hodge wrote:
Reply all
Reply to author
Forward
0 new messages