__rhoGetCallbackObject invalid index --

J Jon Tara 3 years 7 months ago
1 1 0

This is a longshot, but hoping maybe some of the Rhodes developers see this and the error looks familiar:

2015-05-06 12:24:19.962 rhorunner[34751:8385679] I 05/06/2015 12:24:19:962 16b0b000           HttpServer| GC End.
2015-05-06 12:24:19.962 rhorunner[34751:8385679] I 05/06/2015 12:24:19:962 16b0b000           HttpServer| Process URI: '/app/Settings/on_bonjour_browser_service_callback'
2015-05-06 12:24:19.962 rhorunner[34751:8385679] I 05/06/2015 12:24:19:962 16b0b000                  APP| RHO serve: /app/Settings/on_bonjour_browser_service_callback
2015-05-06 12:24:19.963 rhorunner[34751:8385679] I 05/06/2015 12:24:19:963 16b0b000                  APP| App error: __rhoGetCallbackObject invalid index -- 8
lib/rho/rhocontroller.rb:73:in `__rhoGetCallbackObject'
lib/rho/rhocontroller.rb:73:in `block in process_rho_object'
lib/rho/rhocontroller.rb:62:in `each'
lib/rho/rhocontroller.rb:62:in `process_rho_object'
lib/rho/rhocontroller.rb:93:in `serve'
lib/rho/rhoapplication.rb:217:in `serve'
lib/rho/rho.rb:836:in `serve'
2015-05-06 12:24:19.963 rhorunner[34751:8385679] I 05/06/2015 12:24:19:963 16b0b000           HttpServer| GC Start.

Anybody encounter this before, and have a clue what it means? The index numeric value varies. It would be helpful to understand exactly what this error means.

I'm having a problem with a common API style extension (from XML specification). I've a bit of a catch-22. lambda callbacks don't seem to work on Android. (I've reported that as an Issue.) And - for this extension at least, URL callbacks don't work on iOS (when they are asynchronous).

Certainly, I can work around it in an ugly way - and for the time being I am. (Test for platform and use lambda callback for iOS, and URL callback for Android...)

I know that URL callbacks CAN be used in iOS, and, in fact, I use them in a different extension. I suppose it has something to do with the context from which the callbacks are initiated.

My extension that DOES work happens to be iOS-only. It asynchronously sends keyboard hide/show callbacks when the virtual keyboard is hidden or shown.

My extension that does NOT work is iOS/Android, but Android part irrelevant here. It asynchronously sends callbacks when Bonjour services are discovered.

Both do this on the main thread.

It works if I use a lambda callback instead of a URL. And, you can see, it does in fact process the URI, so I know that the callback was retained.

Interestingly, I do get the FIRST callback successfully. However, this one isn't asynchronous. It's sent at the start of a Bonjour search, and just acknowledges that the search will take place.

2015-05-06 12:24:19.953 rhorunner[34751:8385679] I 05/06/2015 12:24:19:953 16b0b000           HttpServer| GC Start.
2015-05-06 12:24:19.955 rhorunner[34751:8385633] I 05/06/2015 12:24:19:955 075c0300 BonjourBrowser.m: 236| willSearch
2015-05-06 12:24:19.956 rhorunner[34751:8385679] I 05/06/2015 12:24:19:956 16b0b000           HttpServer| GC End.
2015-05-06 12:24:19.956 rhorunner[34751:8385679] I 05/06/2015 12:24:19:956 16b0b000           HttpServer| Process URI: '/app/Settings/on_bonjour_browser_service_callback'
2015-05-06 12:24:19.956 rhorunner[34751:8385679] I 05/06/2015 12:24:19:956 16b0b000                  APP| RHO serve: /app/Settings/on_bonjour_browser_service_callback
2015-05-06 12:24:19.956 rhorunner[34751:8385679] I 05/06/2015 12:24:19:956 16b0b000 APP SettingsController| @params = {"rho_callback"=>"1", "ID"=>"default", "searching"=>true, "API"=>"BonjourBrowser", "event"=>"willSearch"}

From trace messages in my Objective-C code, I can see that the extension is getting notifications, logs to the Rhodes log, and from the error you can see the callback is issued. It seems to be some issue accessing the callback data.

I send the callbacks like this:

- (void)sendCallback:(NSDictionary*)dict {
  NSDictionary* boilerPlate = @{
    @"API":        @"BonjourBrowser",
    @"ID":         [self instanceID],
    @"searching":  [NSNumber numberWithBool:[mProperties[@"searching"] boolValue]]
  };
  NSMutableDictionary* result = [NSMutableDictionary dictionaryWithDictionary:boilerPlate];
  [result addEntriesFromDictionary:dict];
  [self.callback setResult:result];
}

callback is a retained property.

Please Register or Login to post a reply

1 Replies

J Jon Tara

This is fixed in current Rhodes master. (Presumably will become version 5.1).

Unsure exactly which previous versions are broken. At least 5.0.30 and 5.0.38.

If you create a common-API Rhodes extension for iOS (generate from XML) URL callbacks will fail if you implement object instances.

For the broken versions:

- If you implement your extension using static methods, the callbacks will work.
- if you use lambda callbacks, that will work, as well.

The problem is that the callback data was not being retained in the generated base implementation code. This can be clearly seen when comparing master source to 5.0.30 or 5.0.38 source.

The reason it worked for my previous extension is because that extension defines only static methods. It works with lambda callbacks because the closure preserves the calling context.

Seems OK in 5.1 so far. Now, I will see if my mirror-image Android problem (URL callbacks work, lambda callbacks fail...) is fixed in 5.1 as well... (edit: nope!)

My bad for insisting on creating a "poster child" extension with all the bells and whistles! Rhodes wasn't ready for all the bells and whistles. 5.1 extensions at least have a couple of extra bells. Holding my breath on the whistles.

CONTACT
Can’t find what you’re looking for?