I post two messages.
1)Message to go inside proxy.
2)Message to disable proxy.
My go not received message 1. Looks like it already disabled.
If i comment 2 message i receive 1 message in go.
Is system messages, works before all other messages?
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("#collectionproxy", "load")
end
function on_message(self, message_id, message, sender)
if message_id == hash("proxy_loaded") then
msg.post(sender, "enable")
end
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.released then
msg.post("proxy:/go#proxy", "do_something")
msg.post("main:/main#collectionproxy", "disable")
end
end
proxy.script
function on_message(self, message_id, message, sender)
pprint(message_id)
end
And this is the output I’m getting when I click (bound to hash("touch")):
INFO:DLIB: Log server started on port 57805
INFO:ENGINE: Engine service started on port 57806
INFO:ENGINE: Defold Engine 1.2.123 (46d8b7e)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device 'default'
...
DEBUG:SCRIPT: hash: [do_something]
Does this roughly correspond to your setup? Am I missing something?
I think both disable and unload will be handled at the very end of the frame, so “do_something” will arrive since it’s being sent the same frame.
Ok.So why message can be disappeared?=)
Go not receive message, only if it not existed or disabled in previous frame, right? But if go not exist i will get error in log. But i don’t have any errors
If you send both a “disable” message and another regular message the same frame, both of these will be received.
If you send both a “disable” and a “unload” message, plus another regular message the same frame, all of these will be received.
If you send a “disable” message one frame, then a regular message the frame after, the regular message will be queued and processed next time the collection proxy is enabled.
If you send a “disable” and a “unload” message one frame, then a regular message the frame after you will get an error since the proxy will no longer be loaded.
I found problem.
Send message “start_unload_proxy” to go.
Then when go received that message.Try send msg then disable. Your go will not receive do_something msg.
It’s not really clear what you wish to do. It feels kinda dangerous to be so reliant on this behaviour where messages are posted to a collection the same instance that it is unloaded or disabled. Can you create a minimal example and share it?
I don’t think it is dangerous to post msg to go inside proxy then post unload to proxy. It is message queue, they should execute one after other.
My use case.
1)In any go i can call change scene method.
2)Message to change scene will be send to some msg proxy on main collection. I need this msg proxy to get proxy_loaded messages, and transition done message.
3)This proxy send show_out msg to scene1://controller
4)scene1://controller received show_out message and start show out animation
5)when animation done. It send to main://msg_proxy transition_done msg.
6)main://msg_proxy received transition_done msg. Send 2 messages.
scene1://controller save_state
main://scene_1#collection_proxy unload
The problem, that scene1 not received message save_state.
Looks like scene_1 unloaded. But if it unload i should get error in log. I don’t have any warning or error in logs, but msg save_state is missed.
So i don’t understand what is happened.
I think it is strange behavior, when messages not delivered. I don’t think that i am doing something strange or dangerous. If i do, i should see warnings or errors in console, that message not delivered.
I add save_state_done msg. Now all work.
I think this is indeed a bug. As part of the finalization-stage of the scene1 collection (if I understand your setup collection), the message queue of that collection should be dispatched before the collection is finally deleted and unloaded. This does not currently happen. @Johan_Beck-Noren could you file an issue for this?