Jump to content

plugin architecture as serious problem


photo

Recommended Posts

Posted

In current engine design all plugins are called before the interpreter init, and all plugins init() function are called in systems init function, and these init functions are called at last of system init function, see the log

13:56:51 Loading "SQLPlugin_x64.dll"...
13:56:51 Using SQLite 3.7.7.1
13:56:51 Using MySQL Client version 5.5.15
13:56:51
13:56:51 ---- Interpreter ----
13:56:51 Version: 2.46

 

plugins are called before interpreter, this will cause a big problem, if I modified data/core/unigine.cpp and load world at system's init function and when this world need some functions exported from the plugin, unigine will crash. just simple reason, you can not load the world at system's init function because all functions or classes from plugins haven't be initialized or exported to interpreter.

 

so in current design, the only way to load a world script that uses plugin exported function is using the command line or write your own startup application.

Posted

well, strange things still happened, I've studied the source code, the plugins init code ARE called at plugin loading but why I can not load world at system's init function?

 

I've also tried to modify engine.cpp to put plugin's initalization after interpreter, I still can not load world at system's init function. got same error, some classes or functions from plugins not defined. :huh:

Posted

That's strange. I could not reproduce this issue.

I tried to load network sample from custom system script and everything worked fine.

Could you please attach a small sample that reproduces this issue?

Posted

I also thought, that this issue can be possibly caused by another world that starts loading before calling system's init. Could you please check your log file if there are other "world_load" commands called?

  • 2 weeks later...
Posted

thanks anet, my mistake, its not related to plugin architecture design, I created a debug version and run a trace, I found my plugin calls Unigine::Engine::get()->getDataPath(), but when system init script function running, the engine interface isn't fully initalized.

 

in these code of Unigine.cpp

  	 	virtual const char *getDataPath() const { return engine->getDataPath(); }

 

engine object is invalid pointer when EngineInterface's constructor not finished. hope I cleared myself, the real problem is when a application initalize, it calls EngineInterface's contructor to create a new engine, but during the creating process, my plugins call's EngineInterface's getDataPath, at this time the engine member still not contructed, so engine crash...

×
×
  • Create New...