You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Whenever I enable or disable a component within a no_readonly system, between defer_suspend + defer_resume calls, the world stays deferred after running progress().
Briefly, this is what I'm trying to do:
m_world
.system()
.no_readonly()
.iter([&](flecs::iter& it) {
m_world.defer_suspend();
entity.disable<MyComponent>(); // This somehow causes the world to stay deferred after progress().
m_world.defer_resume();
});
To Reproduce
This is a complete repro case, reduced from a larger project:
#include"flecs.h"
#include<iostream>usingnamespaceflecs;structMyComponent {
int value = 0;
};
intmain() {
// Create the world.
world m_world;
// Register a component.
m_world.component<MyComponent>();
// Create an entity with the component.auto entity = m_world.entity();
entity.set<MyComponent>({});
// Register a system that tries to disable the component while deferring is suspended.
m_world
.system()
.no_readonly()
.iter([&](flecs::iter& it) {
m_world.defer_suspend();
entity.disable<MyComponent>(); // This somehow causes the world to stay deferred after progress().
m_world.defer_resume();
});
// Precondition: is_deferred correctly outputs false.
std::cout << "m_world.is_deferred(): " << m_world.is_deferred() << std::endl;
// Run the system.
m_world.progress();
// BUG: is_deferred incorrectly outputs true. World unexpectedly stays deferred after progress().
std::cout << "m_world.is_deferred(): " << m_world.is_deferred() << std::endl;
// Trying to run again will assert: !ecs_is_deferred(world) because the world stayed deferred.
m_world.progress();
}
Steps to reproduce the behavior:
Compile and run the code against latest flecs main (37233f1). I'm on Mac, so I used: clang -c flecs.c -o flecs.o && clang++ -std=c++17 flecs.o main.cpp -o program && ./program
The output is:
m_world.is_deferred(): 0
m_world.is_deferred(): 1
fatal: flecs.c: 62749: assert: !ecs_is_deferred(world) INVALID_OPERATION
1 program 0x00000001040673fc flecs_log_msg + 1644
2 program 0x0000000104091324 ecs_printv_ + 204
3 program 0x00000001040361b0 ecs_log_ + 100
4 program 0x000000010402cdb4 ecs_assert_log_ + 272
5 program 0x00000001040d4934 flecs_workers_progress + 572
6 program 0x00000001040d6254 ecs_progress + 348
7 program 0x0000000104122dbc _ZNK5flecs5world8progressEf + 36
8 program 0x0000000104122a78 main + 428
9 dyld 0x00000001807250e0 start + 2360
Abort trap: 6
Expected behavior
I expected output of:
m_world.is_deferred(): 0
m_world.is_deferred(): 0
Additional context
It seems like the enabling / disabling of components is causing trouble. When I simply create entities or add components, the behavior is good.
The text was updated successfully, but these errors were encountered:
This is confirmed fixed on my end with the v4 branch, against both the minimal repro case and my larger project. I'll go ahead and close this bug. This fix makes a huge difference in my project. Many thanks @SanderMertens!
Describe the bug
Whenever I enable or disable a component within a no_readonly system, between defer_suspend + defer_resume calls, the world stays deferred after running progress().
Briefly, this is what I'm trying to do:
To Reproduce
This is a complete repro case, reduced from a larger project:
Steps to reproduce the behavior:
clang -c flecs.c -o flecs.o && clang++ -std=c++17 flecs.o main.cpp -o program && ./program
The output is:
Expected behavior
I expected output of:
Additional context
It seems like the enabling / disabling of components is causing trouble. When I simply create entities or add components, the behavior is good.
The text was updated successfully, but these errors were encountered: