Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worked with Faless(Fabio Alessandrelli) to update server platform. #16653

Merged
merged 7 commits into from
Feb 16, 2018

Conversation

fire
Copy link
Member

@fire fire commented Feb 13, 2018

For #8361

It's an updated version of the server platform. Uses dummy for the driver name. (Any name changes can be discussed elsewhere.)

Add dummy rasterizer driver.

Disable GLES builders and source from server compilation.

Add dummy texture handling.

Server platform now compiles and run on linux.

Seems to also be able to do exports of some demos I tried.

Fixes to OS_Server and DummyRasterizer to match new signatures.

Add dummy audio driver.

Update to newer api.

@Faless
Copy link
Collaborator

Faless commented Feb 13, 2018

I've rebased your changes on top of my commits so It's easier to review, and nicer for the commit log.
master...Faless:server_again_ifire (you can fetch it and for push it).
Additionally, I would discourage the usage of the override keyword as there is no need for it.

@fire
Copy link
Member Author

fire commented Feb 14, 2018

Looking for review and merge.

@akien-mga akien-mga added this to the 3.1 milestone Feb 14, 2018
@akien-mga
Copy link
Member

I don't understand, what branch should be considered for merging? ifire:server_again_2 from this PR or Faless:server_again_ifire linked by @Faless?

@@ -0,0 +1,539 @@
/*************************************************************************/
/* rasterizer.h */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be rasterizer_dummy.h (with the ending */ properly aligned after the edit).


Import('env')

env.add_source_files(env.drivers_sources,"*.cpp")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after , to respect PEP8.

/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018 :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind that's fixed in a later commit.

@@ -5,6 +5,8 @@ Import('env')

common_server = [\
"os_server.cpp",\
"#platform/x11/crash_handler_x11.cpp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for linuxbsd platform to cleanup this mess :P

@@ -0,0 +1,58 @@
/*************************************************************************/
/* audio_driver_dummy.h */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ending */ should be aligned with the rest.

@akien-mga
Copy link
Member

Looking for review and merge.

Need an answer to @Faless' comment before that:

Additionally, I would discourage the usage of the override keyword as there is no need for it.

@fire
Copy link
Member Author

fire commented Feb 14, 2018

Personal opinion, override (c++11) should be used whenever implementing a virtual function. It uses the compiler to help detect if the method made is the exact method overridden.

But consistency in the engine source is a good goal too.

@@ -39,584 +39,584 @@

class RasterizerSceneDummy : public RasterizerScene {
public:
/* SHADOW ATLAS API */
/* SHADOW ATLAS API */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something went wrong here. IDE misconfiguration, or wrong version of clang-format? (We need 5.0).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once fixed, please squash the fixups into the last commit, as we don't really need a specific commit for those.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual studio code wants to reformat everything, while msvc ide has my clang-format settings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashed.

@Faless
Copy link
Collaborator

Faless commented Feb 14, 2018 via email

@akien-mga
Copy link
Member

But consistency in the engine source is a good goal too.

For now consistency is more important, we shouldn't start doing such changes in some places based on personal preference.
If there's a reason to use those everywhere consistently, it should be discussed, agreed upon and added all at once.

void lightmap_capture_set_energy(RID p_capture, float p_energy) {}
float lightmap_capture_get_energy(RID p_capture) const { return 0.0; }
const PoolVector<RasterizerStorage::LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
PoolVector<RasterizerStorage::LightmapCaptureOctree> p;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there memory leak / memory allocation bug here?

@fire
Copy link
Member Author

fire commented Feb 14, 2018

Submitted the whitespace changes, removed override and added a comment on a pointer return that looks suspicious.

float lightmap_capture_get_energy(RID p_capture) const { return 0.0; }
const PoolVector<RasterizerStorage::LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
PoolVector<RasterizerStorage::LightmapCaptureOctree> p;
return &p;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there memory leak / memory allocation bug here?

No, but it returns an invalid pointer that might crash the engine or corrupts its memory if used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you fix it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, probably the safest way is to implement lightmap storage properly, like I did for texture (i.e. implement create, owner, and the like)

@fire
Copy link
Member Author

fire commented Feb 15, 2018

@Faless how does this look?

@fire fire force-pushed the server_again_2 branch 2 times, most recently from 3cb632f to 70a6b77 Compare February 15, 2018 04:02
@fire
Copy link
Member Author

fire commented Feb 15, 2018

Tried to export a project on WSL (Windows 10)'s Ubuntu.

$ ../fire-godot/bin/godot_server.server.tools.64 --export "Windows Desktop" ../Pong.exe
ERROR: initialize: AudioDriverManager: all drivers failed, falling back to dummy driver
   At: servers/audio_server.cpp:153.
ERROR: create: Cannot find path for config directory!
   At: editor/editor_settings.cpp:771.
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f6e2ad754b0] (??:0)
[2] ../fire-godot/bin/godot_server.server.tools.64() [0xd03853] (/mnt/d/Projects/fire-godot/editor/editor_file_system.cpp:1047)
[3] ../fire-godot/bin/godot_server.server.tools.64() [0xcfe067] (/mnt/d/Projects/fire-godot/editor/editor_file_system.cpp:279)
[4] ../fire-godot/bin/godot_server.server.tools.64() [0xcfe642] (/mnt/d/Projects/fire-godot/editor/editor_file_system.cpp:298)
[5] ../fire-godot/bin/godot_server.server.tools.64() [0xc6077d] (/mnt/d/Projects/fire-godot/drivers/unix/thread_posix.cpp:72)
[6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f6e2bbe76ba] (??:0)
[7] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f6e2ae473dd] (??:0)
-- END OF BACKTRACE --

@fire
Copy link
Member Author

fire commented Feb 15, 2018

virtual bool has_environment(const String &p_var) const;
virtual String get_environment(const String &p_var) const;
virtual String get_locale() const;

virtual int get_processor_count() const;

Aren't implemented.

[Actually, don't know. These are inherited from OS_unix.]

@fire
Copy link
Member Author

fire commented Feb 15, 2018

https://github.com/godotengine/godot/blob/master/editor/editor_file_system.cpp#L278

Removing these lines allowed the export to finish.

f->close();
memdelete(f);

@fire
Copy link
Member Author

fire commented Feb 15, 2018

diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index dca32d749..1251a0e56 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -276,8 +276,6 @@ void EditorFileSystem::_scan_filesystem() {
 
 	f = FileAccess::open(fscache, FileAccess::WRITE);
 	_save_filesystem_cache(new_filesystem, f);
-	f->close();
-	memdelete(f);
 
 	scanning = false;
 }
@@ -1044,6 +1042,10 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir,
 
 	if (!p_dir)
 		return; //none
+
+	if (!p_file)
+		return; //none
+
 	p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time));
 
 	for (int i = 0; i < p_dir->files.size(); i++) {

This is not correct, but the problem is around here.

@akien-mga
Copy link
Member

Well your problem is:

ERROR: create: Cannot find path for config directory!
   At: editor/editor_settings.cpp:771.

Then all files it tries to open will be invalid, and if there aren't null checks (like here), it will crash. But that's likely unrelated to this PR and just related to caveats of running Linux binaries on WSL.

@akien-mga akien-mga merged commit da612c3 into godotengine:master Feb 16, 2018
@fire fire deleted the server_again_2 branch February 16, 2018 16:04
@@ -31,6 +28,7 @@ def get_opts():
def get_flags():

return [
("module_mobile_vr_enabled", False),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this? There is a problem here. The mobile_vr module registers the class MobileVRInterface. By only enabling it on some platforms, this breaks API portability. This is specially harmful for GDNative and C#.

The code that registers the class is the following:

void register_mobile_vr_types() {
ClassDB::register_class<MobileVRInterface>();
Ref<MobileVRInterface> mobile_vr;
mobile_vr.instance();
ARVRServer::get_singleton()->add_interface(mobile_vr);
}

I can imagine three different situations and the possible solutions:
Can the MobileVRInterface class be used directly, or can it only be used through the ARVRInterface interface?

  • If the MobileVRInterface class cannot be used directly from scripts and scripts only use the ARVRInterface interface then this class must not be registered manually. register_class will expose the class to the scripting API, which must be portable. When you create an instance, the class will be registered automatically without exposing it to the scripting API.

  • If MobileVRInterface or any of its methods from that are not registered by ARVRInterface can be used directly from scripts, then we have a different problem. One of the possible solution could be to create a dummy class.

  • What confuses me the most though is that this class is not actually disabled on the desktop, only on server builds. I think this is because of the gl code in this class, am I right? If that is the case, then perhaps the solution is to surround such parts of the code with #ifdefs and maybe to not call ARVRServer::get_singleton()->add_interface(mobile_vr) either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you missed the irc conversation, fales replied.

<fales> neikeq seems like VR module uses GLES header

<fales> which is of course not avail in server platform

<fales> it uses LensDistortedShaderGLES3 which is defined "shaders/lens_distorted.glsl.gen.h" maybe we could guard the functions by defines. Not sure what the best solution is. There's also a comment from Mux213 about that shader and its todo state for GLES2 support. Not sure if anything changed

Copy link
Contributor

@neikeq neikeq Sep 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be the third possibility I mentioned.
Can't we ifdef that code or add a dummy class?

Copy link
Collaborator

@Faless Faless Sep 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neikeq yes to both.
I think we should ask @BastiaanOlij about the GLES2 comment.
He mentions some refactoring about the shader there.

// build our shader
if (lens_shader == NULL) {
///@TODO need to switch between GLES2 and GLES3 version, Reduz suggested moving this into our drivers and making this a core shader
// create a shader
lens_shader = new LensDistortedShaderGLES3();

In the meantime I'll see if we can have a dummy implementation of the interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope to finally have time for this on my trip to Europe next week.

That said, for the server platform, why not change the detect.py so the module is not included on the server installation? VR is not really applicable on the server so..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BastiaanOlij we're already doing that right now, and that's the problem. The mobile_vr module exposes the class MobileVRInterface to the scripting API. By disabling the module the scripting API for server builds becomes different to that of other target platforms. That breaks API portability. This hurts specially GDNative and C#, which rely on generating bindings.
Also doesn't this break GDScript scripts that make use MobileVRInterface as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also doesn't this break GDScript scripts that make use MobileVRInterface as well?

Yes, for people who uses the server platform for exporting the game (e.g. in CI).

@BastiaanOlij
Copy link
Contributor

BastiaanOlij commented Sep 26, 2018 via email

@neikeq
Copy link
Contributor

neikeq commented Sep 26, 2018

Meanwhile, do you think #22422 can be a good temporary solution?

@akien-mga
Copy link
Member

I merged #22422 for now as it's an OK workaround for the issue until something better can be implemented. It might be worth it to open a new issue to keep track of what needs to be done (and remember to revert/undo #22422 at that time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants