-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
I exported a function on my controller:
- (void)loadMesh:(NSString *)path {
RCT_EXPORT();
node.mesh = [REMeshCache meshNamed:path];
}
This is called when selecting an item from a list:
var controller = require('NativeModules').TeapotController;
// ....
selectModel: function(file) {
controller.loadMesh(file);
},
I've been trying to debug why OpenGL crashes, and I finally realized that my OpenGL context doesn't exist. Which made me realize that this method in Obj-C is not running on the main thread. It's running in a different thread which all calls into Obj-C seem to run on.
I'm not familiar with iOS, so this is over my head. Is there a simple pattern I can use to interact with the main thread? How do I send a message to it?
I realize this not usually needed, and most custom native modules can probably be run standalone, but I'm basically implementing a custom view that needs to render on the main thread (not technically true, just a custom controller to a normal view, but still).