Advanced Camera Tools won't cooperate with Ruby

When an Advanced Camera is created, SketchUp stops sending viewpoint updates to extensions through ViewObserver#onViewChanged. Even if I delete the advanced camera and go back to the normal one, there are still no view updates coming. The only way to get back to normal is to close and reopen SketchUp. Observed in SketchUp 2018 and 2019 on Windows 8.1. Has anyone else had this problem? Is it a known bug?

The old shipped extensions are known to be something of troublemakers with their global variables and monkey patching. I haven’t heard of this specific issue though, but then I have used the ViewObserver very little and not used Advanced Camera Tools at all.

I think it’s best to ask someone with access ton the source code as well as Trimble bug tracker. @tt_su

1 Like

I tested this - happened to work on an extension myself that use onViewChanged. And I see what you observe.

Logged in the issue tracker:

1 Like

Some more findings:

I didn’t have to restart SketchUp for the event to trigger.

I had in my own extension a debug puts to see when the event triggers:

    def onViewChanged(view)
      p [:onViewChanged, view.vpwidth, view.vpheight]
      return if self.height == view.vpheight

That worked fine until I create a new Advanced Camera. But, when you do that ACT will activate a Ruby tool - this is what displays the camera info in the bottom right of the screen. As I orbit onViewChanged to my extension isn’t called. But the moment I activate another tool the callback works again.

This gave me a clue. I enabled Sketchup.debug_mode = true. After that, when you create a new Advanced Camera you will see in the Ruby Console:

SketchUp: warning: Ruby operation left open: "Edit Camera"

As of SU2016, observer events are queued up while an operation is open, and dispatched when the operation is committed. This was done in order to address a host of issues and potential crashes. Before that observers was able to modify the model while an operation was using them.

It appear that Advanced Camera Tools is leaving an operation open - which means any observer notifications are suspended until a new operation starts and implicitly closes the open operation.

From a quick glance it appear that it leaves the operation open when the tool activates because while it’s active ACT will update attributes and the geometry representing the camera. Not ideal. I don’t see a quick fix for this so this will have to go to further investigation.

Meanwhile the only workaround I can suggest is making sure the Advanced Camera Tool’s custom tool isn’t active. It activates when you create a camera and when you select the page for that camera.

1 Like