culling of child in display group

At the bottom of the documentation on group programming,
https://docs.coronalabs.com/guide/graphics/group.html#offscreen-culling

It says “Solar2D will cull child objects that are outside the boundaries of the screen.”

Questions. How is this done? How do one know which child has been “culled”? How do one bring back the “culled” child, without recreating it? Can it be disabled (no culling) for a particular display group?

Background. I am writing an app which display a map that is larger than the screen size. The map is populated with touchable objects, which are all childs to a display group. One scrolls and navigates the map using touch and pinch-and-zoom to move the necessary area of interest (of map) onto the screen, pretty much like the google map app. All the touchable objects moved as a group.

The Problem. Some of the touchable objects, while was touchable earlier, seems to become un-touchable when it went off screen and brought back onto the screen (after navigating map). It seems so far, the objects that become un-touchable are quite random in nature. It is not always the same objects that become un-touchable. It is not always repeatable.

I am only guessing if this problem is due to the “culling” as above. Hence, the questions. Would appreciate any insights. If you think the problem lies elsewhere, please feel free to share. Thank you.

It’s done automatically, and I don’t believe there’s a way to “disable” it.

Culling relates to rendering and it basically just hides or excludes the object from the rendering process. It technically doesn’t unload any other data. When the object is brought back within a visible range and you can see it again it means that object is no longer being culled.

There might be something else in play here as moving an object far away from the visible viewport (under normal circumstances) should not result in deletion or modification of said object.

Are you by any chance using widgets or is it just a display group?

Track your objects and the screen dimensions. When objects go offscreen then disable them (remove listeners, unload assets, etc), do the inverse then the object are about to come onscreen.

Thanks for explaining the “culling” process. I had earlier thought that “culling” means “removing”.

On your question, “Are you by any chance using widgets or is it just a display group?”, well, it is a display.newGroup() with 273 childs, some childs are initially hidden (and shown when touch ended).

Thanks for your suggestion. This may be a good work-around, until I figure out the root cause of the problem.

Further Background. While in the process of coming out with various possible work-arounds, including the one suggested by “SGS”, I took a quick look at the “display group” object on Solar2D github, just out of curiosity. A block of codes there catches my attention (Disclaimer, I have not done any C or C++ work). It is around the “for loop” section and “canCull()” function. The link to the section,

https://github.com/coronalabs/corona/blob/master/librtt/Display/Rtt_GroupObject.cpp#L190C13-L190C13

Workaround. Hence, I decided to try out one possible workaround, which is to wrap all my 237 childs (was image, rect, circle or text) into a 237 groups (with just one child each). Then put these 237 mini-groups into the original upper-level group. To my surprise, the problem seems to go away, after testing out a couple of times.

I am not sure what causes the difference (is it because culling has been stopped to work? or other reasons?). While I have not found the root cause, I am glad I may have stumbled on a simple workaround. Of course, I would need to continue further testing and confirmation. Once again, thank you everyone.