Analysis of timing problems in cocos2dx
Today, we have encountered a problem. For UIListView, if you operate it immediately after the initialization (pushBackCustomItem), it may cause some strange problems because the original is not re-deployed. After checking the code, we found that doLayout and forceDoLayout can be re-deployed, and the caller is the visit function. Therefore, after the ListView is initialized, use visit immediately and then perform the listView operation. However, you must note that visit is also called during OnEnter, that is, visit is actually more than once. If the results of the first visit and the second visit are the same, that is, the results are correct, then there is no problem. Otherwise, the result is incorrect after manual visit. Therefore, manual visit call is useless. Another problem is that after visit, if you perform synchronization operations, there is no problem. If the latency operation is performed and the items of ListView is changed before the delay ends, the DoLayout operation will be performed again. Some parameters will change, and the subsequent delay operation will deviate from the original setting, an error occurred. If visit is unavailable, a callback must be provided after the notification is fully loaded (that is, visit). The notification can be followed by the next step, otherwise, it is impossible to make some operations such as the sequence after loading and re-computing is complete. There is no such callback, so you can only use visit.