[ALOY-1604] iOS 10.0: Bluebird Promise not firing 'then' if Alloy is used.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2018-03-05T21:48:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Runtime |
Labels | alloy, bluebird, promises |
Reporter | Hugo Ramos Freire Neto |
Assignee | Feon Sua Xin Miao |
Created | 2018-02-08T17:07:55.000+0000 |
Updated | 2018-03-06T12:32:11.000+0000 |
Description
When I use Alloy for something, bluebird promise not firing 'then' on iphone 5s with OS 10.0.
If I use OS 11.0, it works normally.
If I use SDK 6.x, it works normally on all OS versions.
To Reproduce:
1. Create a new Project
2. Download bluebird.min.js at https://github.com/petkaantonov/bluebird/releases
3. Rename to bluebid.js and past on lib folder.
4. Write on app/alloy.js:
Alloy.Globals.test = 'test';
3. Write on index.js:
var Promise = require('bluebird');
var test = new Promise(function (resolve){
resolve();
});
test.then(function (){
console.log('not working!!');
});
console.log(Alloy.Globals.test);
5. Run os Iphone 5s simulator with OS 10.0.
The ('not working!!') log doesn't work.
If I remove the (Alloy.Globals.test) log, then promise is fired and the The ('not working!!') log works.
Attachments
File | Date | Size |
---|---|---|
classic.zip | 2018-02-22T19:31:17.000+0000 | 23824 |
Titanium SDK 7.1.0 and later will support built-in promises, so you won't need any external library for it anymore. Therefore I would propose to not address this but use the built in solution in the next release. Since we won't have a release before 7.1.0, this will be the earliest fix date anyway. Are you okay with that? P.S.: You can try out the ES6 / promises support today using the master branch (
appc ti sdk install -b master
). Thanks!Hello [~hrfn], Can you get back to us testing with the master release? Thanks.
Hello, I'm having this issue as well. I have a large app and we have other libraries that depend on bluebird. We use bluebird specific methods such as Promise.mapSeries that are not present the native implementation. The native implementation also have very bad stack traces, and bluebird provides has a complete stack when exceptions occur. Unfortunatelly we cant switch to native promises because of those reasons
JavaScriptCore on iOS 11 supports Promises built-in (even without transpilation / Babel), which you are basically overriding. Since SDK 7, we enable JavaScriptCore by default and you can disable with
<use-js-core-framework>false</use-js-core-framework>
in the<ios/>
section of the tiapp.xml. Please also confirm this only happens with Alloy and not classic apps.This issue is happening in my apps too. It's critical because I use Bluebird everywhere in my app and it's happening when my app is used on iOS 10 devices. I use Alloy too.
Attached a classic app that has the same issue. In
app.js
at line 2, 21 and 32, the same module is called but produces different out come. [~amukherjee], let me know if you and anyone is able to verify this.[~hrfn], if you replace
console.log(Alloy.Globals.test);
with sayconsole.log('####');
the promise listener registered with.then()
won't get called either. So I'm not exactly sure what's the purpose of the reproduce step #4. This might be related to the promise library, it seems like a scheduling issue, and I'm able to reproduce with a classic app. You can workaround is by usingsetTimeout
:I've tested right now, if I use console.log('####'); instead console.log(Alloy.Globals.test); it work's for me. And on classic app works for me too.
Any thoughts on why this is happening on iphone OS 10 only? Does it have anything different?
According to [~eharris], removing this commit fixes the issue https://github.com/petkaantonov/bluebird/commit/b8e580c52504457f618018c5e434abb72548a3b8. Looks like an issue with the promise library itself.
To expand upon Feons comment here's how I arrived at that conclusion - I searched the Bluebird issue tracker on the GitHub for any known issues on iOS, I found [this](https://github.com/petkaantonov/bluebird/issues/1022) which appeared to be a similar issue, albeit closed as fixed - We know this worked in SDK 6, one major change around JavaScript usage from SDK 6 to 7 was that the on device JavaScriptCore framework became the default. - Seeing as how the fix for the above issue is using the JS Engines promise implementation, it seemed possible to me that this bug was due to the JavaScriptCore Promise implementation on certain iOS versions pre 11.0 (from my tests, I could see the issue down to iOS 8) - I ran with
<use-jscore-framework>false</use-jscore-framework>
in my tiapp, which forces the app to use TiJSCore (i.e pre-7 behavior), the issue was not seen - I removed the changes in [the fix](https://github.com/petkaantonov/bluebird/commit/b8e580c52504457f618018c5e434abb72548a3b8), this fixed the issue So the issue here appears to be due to Bluebird delegating to the native Promise implementation when possible. This isn't seen when using TiJScore (pre 7 behaviour,2. Fork bluebird, remove the changes in the aforementioned commit, build the libraries yourself and use those. 3. Set
<use-jscore-framework>false</use-jscore-framework>
, to use TiJSCore. But I do not recommend this way as you'll just be deferring this problem for a little while as TiJSCore is I believe is due for removal in SDK 8