我在iOS 8.4上运行使用IBM MobileFirst 7创建的应用程序。起初它工作正常:我可以写入jsonstore并进行其他本机函数调用。
然后应用程序开始同步并写入JSONStore(大量数据),并在一段时间后停止(控制台中没有错误)。它通常在尝试调用WL.Client.invokeProcedure函数时发生。
我还注意到一个奇怪的行为:如果我双击主页按钮,它会在循环中调用下一个WL.Client.invokeProcedure,然后我从适配器接收结果,然后再次停止(每次我双击主页)按钮发生这种情况)。其他本机调用也会发生这种情况(例如,我试图通过使用cordova调用JS控制台中的其他本机函数,只有在我点击主页按钮后才会调用它。)
有谁知道造成这种行为的原因是什么?〜
编辑:
关于本机调用:由于我使用cordova,我可以使用插件来访问某些本机功能,例如:
//this is what I meant by "native function calls"
cordova.exec(successCallback, errorCallback, 'SFRPowerSave', 'enable', []);
我不确定WL.Client.invokeProcedure和WL.JSONStore函数,但我认为它们也使用本机代码。
这就是我正在做的事情:
//I get the first 50 dirty documents
function push(){
var numberOfDocumentsToPush = 50;
var dirtyDocuments = currentSyncStore.dirtyDocuments.splice(0, numberOfDocumentsToPush);
//then I call the adapter add method and return a promise
return when(WL.Client.invokeProcedure({
adapter : adapter.name,
procedure : adapter.push.procedure,
parameters : [ JSON.stringify(dirtyDocuments),
JSON.stringify({add: addParams}) ],
compressResponse : false
}, {
timeout: adapter.timeout,
invocationContext: {context: this, document: dirtyDocuments}
});
}
//after the promise is returned, I get the next 50 dirty documents and call the push function again, I usually have a lot of dirtyDocuments (lets say 10000).
//After a while it just stops, the WL.Client.invokeProcedure doesn't reject or resolve the promise and no timeout occurs.
//I can interact with the interface of the application but if I try to call some native function, it will not work (but it gets called immediatly after entering the multitask mode - double tap home button in ipad/iphone)
//In the adapter I call the stored procedure from the DB2 database one time for each document:
function pushLogs(logs, params, addFunction){
var parsedParams = JSON.parse(params);
var addParsedParams = parsedParams.add;
var addConfig = getConfig("logs", addFunction, JSON.stringify(addParsedParams));
var parsedLogs = JSON.parse(logs);
var globalResult = {
isSuccessful: true,
responses: []
};
for (var i = 0; i < parsedLogs.length; i++) {
var options = {
values : JSON.stringify(parsedLogs[i].document),
spConfig: addConfig
};
var result = invokeSQLStoredProcedure(options);
globalResult.isSuccessful = globalResult.isSuccessful && result.isSuccessful;
globalResult.responses.push(result);
}
return globalResult;
}
答案 0 :(得分:0)
PMR被打开以处理这个问题。它已成为Cordova缺陷,现在正通过APAR PI47657进行处理:应用程序在尝试异步调用JSONStore以同步数据时挂起。
该修复程序将出现在IBM Fix Central的未来iFix版本中(以及通过PMR打开)。