godot: Crash on do `OS::set_window_size(Vector2(1024, 680))` when changing scene
Godot version:
3.0
OS/device including version:
MacBook Pro (Retina, 13-inch, Early 2015) macOS 10.14.2 OpenGL ES 3.0 Renderer: Intel® Iris™ Graphics 6100
Issue description:
I’m in GDNative cpp.
Program crash on OS::set_window_size
when changing to another scene with owner->get_tree()->change_scene("res://AnotherScene.tscn");
.
The target scene’s base node code exmaple:
void LVBase::_ready()
{
OS::set_window_size(Vector2(1024, 680));
}
Steps to reproduce:
Given a GDNative base node of a Scene, a Node2D
#ifndef _LSBASE_H
#define _LSBASE_H
#include <Godot.hpp>
#include <Node2D.hpp>
#include <String.hpp>
using namespace godot;
class LSBase : public GodotScript<Node2D>
{
GODOT_CLASS(LSBase);
public:
LSBase() { }
void _ready()
{
OS::set_window_size(Vector2(640, 438));
OS::center_window();
}
void _process(float delta);
static void _register_methods() {
register_method("_ready", &LSBase::_ready);
register_method("_process", &LSBase::_process);
}
};
#endif
And another base node of another scene:
#ifndef _LVBASE_H
#define _LVBASE_H
#include <Godot.hpp>
#include <Node2D.hpp>
#include <String.hpp>
#include "WilDataLibrary.h"
using namespace godot;
class LVBase : public GodotScript<Node2D>
{
GODOT_CLASS(LVBase);
public:
LVBase() { }
WilDataLibrary* WilDataLib = nullptr;
void _ready()
{
OS::set_window_size(Vector2(1024, 680));
}
void _process(float delta);
static void _register_methods() {
register_method("_ready", &LVBase::_ready);
register_method("_process", &LVBase::_process);
}
};
#endif
change scene from one to another like:
owner->get_tree()->change_scene("res://AnotherScene.tscn");
Minimal reproduction project:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (16 by maintainers)
Commits related to this issue
- Avoid cyclic iteration check, fixes #24969 — committed to slapin/godot by reduz 5 years ago
- Avoid cyclic iteration check, fixes #24969 — committed to xsellier/godot by reduz 5 years ago
Simple interlocking of
iteration()
call fixes this and #23572 for me.I assume there’s no reason to add real mutex since this lock is single-threaded and only serve to prevent recursive
iteration()
calls.Would be very appreciated if you include operating system in your report, else it will be difficult to test