Esri / cityengine-sdk

CityEngine is a 3D city modeling software for urban design, visual effects, and VR/AR production. With its C++ SDK you can create plugins and standalone apps capable to execute CityEngine CGA procedural modeling rules.
https://esri.github.io/cityengine/cityenginesdk
Apache License 2.0
206 stars 64 forks source link

createValidatedOptionsAndStates crashes when setting "layerName" in AttributableMap for encoder options #23

Closed sandromartis closed 9 years ago

sandromartis commented 9 years ago

Hey

So I'm trying to export a CityEngineWebscene using the com.esri.prt.codecs.WebSceneEncoder. I'm using Procedural Runtime Version 1.3.1969.

I'm trying to add the layerName encoder option using an prt::AttributeMapBuilder. Program compiles perfectly fine but it crashes without an error message when it calls createValidatedOptionsAndStates from prt::EncoderInfo.

When I remove the layerName encoder option the program works fine and generates the .3ws, but of course the layer names are blank and thus the webscene does not load in the CityEngine Webscene Viewer.

Is this a bug in the prt::EncoderInfo or I am missing something here? My code works perfectly fine using the layerName encoder option with the Procedural Runtime Version 1.1.1471 and Version 1.3.1888. Only the latest Version 1.3.1969 causes problems. Has anything changed since then regarding the .3ws WebsceneEncoder?

Thank you very much for your help.

Best, Sandro

mistafunk commented 9 years ago

hi sandro,

are you able to create a minimal code example to reproduce the crash in createValidatedOptionsAndStates()? do you have special characters in your layer name array? also, please make sure that all the encoder array options prefixed with "layer" have the same length.

best, simon

sandromartis commented 9 years ago

Hey Simon

I changed the prt4cmd example to export a CityEngine Webscene instead of an .obj.

You can replace the prt4cmd.cpp with this gist to debug the issue: https://gist.github.com/SandroMartis/2f57a6833d481980f1ee

I only added a small piece of code to the example that creates the encoder options for the WebScene Encoder. (Instead of using the command line arguments from the example) The part ist marked with START DEBUG CODE and END DEBUG CODE. Additionally I added a LOG_DBG before and after the createValidatedOptionsAndStates call.

Just use the different versions of the CityEngine SDK binaries (PRT 1.3.1888 and 1.3.1969) in the cmake command and then run the example by using:

bin\prt4cmd -f CityEngAdvFx -l 1 \
    -g C:\Users\martissbc\Documents\Development\CityEngineSDKBug\data\candler_lot.obj \
    -p C:\Users\martissbc\Documents\Development\CityEngineSDKBug\data\candler.rpk \
    -a ruleFile:string=bin/candler.01.cgb \
    -a startRule:string=Default$Lot \
    -e com.esri.prt.codecs.WebSceneEncoder \
    -a /enc/layerName:string=DefaultLayer \
    -a /enc/layerUID:string=Layer1 \
    -a /enc/com.esri.prt.codecs.WebSceneEncoder/elevationMode:string=clampToGround

It should work with PRT 1.3.1888 but crash with 1.3.1969. It should also work with 1.3.1969 if you remove the ´layerName´ encoder option, but then the CityEngine Webscene will not load in the viewer since the layer names are set to empty strings.

To answer your questions: I made sure that all the options prefixed with layer have the same length. I also didn't use any special characters, just lower and upper case letters and numbers.

I'm running this on a Windows 8 machine using the binary esri_ce_sdk-1.3.1969-win32-vc110-x86_64-rel-opt.zip and MSVC 18.0.21005.1

I hope this helps in tackling this issue.

Best, Sandro

sandromartis commented 9 years ago

I just tried to run my original code (not the minimal example) in an Ubuntu VM and the same happens. segmentation fault (core dumped) crash when using PRT 1.3.1969 but working fine with PRT 1.3.1888.

mistafunk commented 9 years ago

hi sandro,

apologies for the delay, i was on the road. i can confirm this is a new bug in 1.3.1969 - the WebSceneEncoder is assuming the presence of another encoder option (layerGroup). I logged a ticket to make this more robust.

In the meantime, you should be able to work around this bug by adding this encoder option: const wchar_t *layerGroups = new const wchar_t [2]; layerGroups[0] = L"group1"; layerGroups[1] = L""; // empty = layer will not be part of a group encoderOptionsBuilder->setStringArray(L"layerGroup", layerGroups, 2); delete [] layerGroups;

with this change, your modified prt4cmd.cpp works for me.

sandromartis commented 9 years ago

Hey Simon

Thanks a lot for debugging this. I already suspected that some layerGroups need to be defined. You're workaround solves this for me.

Best, Sandro