Live data from Hacker News

Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

trigger.io

11–20 of 67 posts

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#11

It would have been great to see these improvements contributed back to PhoneGap/Cordova, which has an extremely permissive license and whose code is open-source. As it is, trigger.io comes with a restrictive license, I have to create an account to use it, I can't see the code, and they mandate that I include their branding with any free use of their product. Yay.

Is trigger.io a fork of PhoneGap? If not, "contributed back" isn't exactly the right phrase.

In any case, I think that anyone is free to do whatever they want with their code- trigger.io are not obliged to liberally license their work. They even describe how they've achieved their performance increase in the blog post- it's more than many would do.

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#12
post #7
post #5

Would be curious to know why Trigger didn't use the URL interception method in Android. Is that significantly slower?

I'm not quite sure I understand what you mean (so if this is the wrong answer let us know). But if you mean why do we use a different method on Android compared to iOS: we can communicate directly from Javascript to Java as part of the WebView in Android, which is very fast. The URL interception method is actually the slowest part of iOS but there is no way around it.

You can call Objective-C from JavaScript on iOS: [ https://developer.apple.com/library/mac/#documentation/Apple... ]

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#13

It would have been great to see these improvements contributed back to PhoneGap/Cordova, which has an extremely permissive license and whose code is open-source. As it is, trigger.io comes with a restrictive license, I have to create an account to use it, I can't see the code, and they mandate that I include their branding with any free use of their product. Yay.

We're trying to optimize the development cycle for web devs. So it's not just about the bridge itself, but also keeping the code around it lean and fit in with our command line tools / cloud build service. All so the build / test cycle is seconds.

Also we're a small team so don't have time to do everything we would like, and also contribute to Cordova. Trigger.io's native bridge is not a a fork of PhoneGap or downstream of it.

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#14
post #11

It would have been great to see these improvements contributed back to PhoneGap/Cordova, which has an extremely permissive license and whose code is open-source. As it is, trigger.io comes with a restrictive license, I have to create an account to use it, I can't see the code, and they mandate that I include their branding with any free use of their product. Yay.

Is trigger.io a fork of PhoneGap? If not, "contributed back " isn't exactly the right phrase. In any case, I think that anyone is free to do whatever they want with their code- trigger.io are not obliged to liberally license their work. They even describe how they've achieved their performance increase in the blog post- it's more than many would do.

Yep, to be clear - trigger.io is not a fork of PhoneGap or downstream from it.

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#15
post #7
post #5

Would be curious to know why Trigger didn't use the URL interception method in Android. Is that significantly slower?

I'm not quite sure I understand what you mean (so if this is the wrong answer let us know). But if you mean why do we use a different method on Android compared to iOS: we can communicate directly from Javascript to Java as part of the WebView in Android, which is very fast. The URL interception method is actually the slowest part of iOS but there is no way around it.

Thanks for the answer. Sorry I wasn't clear... I was referring to this part of the article, in which you describe how the HTML / JavaScript communicates with Objective C on the iPhone:

>> We then make a request to a fake URI (forge://…) which we intercept in native code

Have you tried doing the same for Android? Do you have any numbers that compare the performance of this method with the JS -> Java bridge?

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#16
(disclaimer: I work for Adobe on a competing service (PhoneGap Build) and have worked with PhoneGap for years)

This is a silly benchmark - there is absolutely no reason you would put 1000 calls at once, sequential or parallel, across this sort of bridge in a real app. You probably shouldn't be calling any JavaScript API in a client-side app 1000 times at once.

The bridge in PhoneGap Android probably is slower than the one in Forge but

1) that's a tradeoff the PhoneGap devs were willing to make for wider compatibility, support for older devices, and isolation from the bizarre Android WebKit bugs that crop up in every release.

2) synthetic benchmarks aside, there's no indication this would affect the usability of the app.

Take the camera example in the article. A PhoneGap call (judging from the graphs) takes about 14ms, a Forge call about 3ms. That's for the entire round trip (JavaScript -> Native -> JavaScript), so divide each in half for each side of the trip.

With PhoneGap: * first half of the trip (7ms) * Android presents Camera activity, user picks a photo, Android returns control to original app (say, 500ms, very conservatively) * second half of the trip (7ms) = 514ms

With Forge: * first half of the trip (1.5ms) * Android presents Camera activity, user picks a photo, Android returns control to original app (500ms) * second half of the trip (1.5ms) = 503ms

This is much closer to a real-world use case - and the calls to native APIs entirely dominate the time spent on the bridge.

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#18
post #9

Anyone have experiences of moving from PhoneGap to Trigger.io? Sounds like the tooling is a bit simpler to use (you can avoid XCode): http://www.quora.com/How-is-Trigger-io-better-than-PhoneGap-... But otherwise I can't see many inducements to using Trigger.io's commercial service over open-source PhoneGap.

When thinking about the pricing model, you should compare us to a combination of PhoneGap's cloud build service (which is also fremium and restrictive) and their support packages:

http://phonegap.com/support#support-packages

The main difference with us is that you do not pay to raise a support tickets: you get direct access to our developers on any plan. And we charge per-app with no restrictions on the number of developers.

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#19
post #16

(disclaimer: I work for Adobe on a competing service (PhoneGap Build) and have worked with PhoneGap for years) This is a silly benchmark - there is absolutely no reason you would put 1000 calls at once, sequential or parallel, across this sort of bridge in a real app. You probably shouldn't be calling any JavaScript API in a client-side app 1000 times at once. The bridge in PhoneGap Android probably is slower than th…

Totally agree with you on this one.

On a side note, are there plans to develop a better set of debugging tools for PhoneGap? It's one of the major pains of the platform. If one is already in development can you point me in the proper direction? Thanks!

Re: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge

#20
re: "This approach is heavier and hackier, but a decision they made in order to sideline a bug in the Android 2.3 simulation. It’s not a bug that affects actual Android 2.3 devices, so we take this to be a bit of overkill."

From what I could tell, the bug was shipped starting with some version of Android 2.x (I'm thinking 2.2) where JSC was used as the internal JS engine for WebKit instead of V8. When the Android devs added V8 support, they actually broke JSC support. It's a device manufacturer choice (or was) as to which JS engine to use. Curiously, Android shipped the 2.3 simulator image (guess that was the version) with JSC support, thus, "it was broken".

The API in question is `WebView.addJavascriptInterface()`. That method returned successfully, but whenever you accessed the interface from JS, you'd trap.

Could be this was only on the simulator, but - I'm thinking folks saw this on devices as well. Maybe those devices are no longer relevant?

Presumably Cordova will revert back to using `WebView.addJavascriptInterface()` when it's safe to do. The problem is, it's not clear when it's safe to do so. It's also not clear how you can test your JS environment to see if "it's safe", programmatically. Or maybe you can (eg, throw an Error, check for existence of error.stack), but ... it's wasn't a comfortable situation to be in.

Do you have some references that the 'bug' doesn't ship on devices, or that it no longer ships on simulator images?

What versions of Android SDK/simulator/devices does Trigger.io support? Presumably you don't support running Android 2.3 on the simulator, as your code would trap?

Post reply on HN