libgdx robovm 在调用堆栈上具有非本机帧的分离线程上崩溃
libgdx robovm crashes on detatch thread with non native frames on the call stack
我已经断断续续地尝试修复这个崩溃几个星期了,但我还没有找到问题所在。当我 运行 在我的 Libgdx 游戏中使用以下函数 "GetAchievementsInformation()" 时,应用程序崩溃并显示 "cannot detach thread when there are non native frames on the call stack"
我是不是做错了什么?我的大多数其他 Facebook 请求 运行 都很好(我有第二个请求也有同样的错误)
public FBRequest GetAchievementsRequest()
{
return new FBRequest(FBSession.getActiveSession(),"/"+ APP_ID + "/achievements", null,"GET");
}
FBRequestHandler GetAchievementsRequestHandler()
{
return new FBRequestHandler()
{
@Override
public void invoke(FBRequestConnection connection, NSObject data, NSError error)
{
if (error != null)
{
Gdx.app.log("error", error.toString());
logout();
return;
}
JSONArray achievements_data;
try {
achievements_data = NSObjectToJSONObject(data).getJSONArray("data");
for(int i=0;i<achievements_data.length();i++)
{
JSONObject achievement_data = achievements_data.getJSONObject(i);
JSONObject pointdata = achievement_data.getJSONObject("data");
String points_data = pointdata.get("points").toString();
int score = Integer.parseInt(points_data);
String url = achievement_data.get("url").toString();
JSONArray list = achievement_data.getJSONArray("image");
String image_url = list.getJSONObject(0).get("url").toString();
achievementManager.AddInformationToAchievement(url, score,image_url);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Gdx.app.log("request", "get achieved achievements");
GetAchievedAchievementsRequest().start(GetAchievedAchievementRequestHandler());
}
};
}
public FBRequest GetAchievedAchievementsRequest()
{
return new FBRequest(FBSession.getActiveSession(),"/me/achievements", null, "GET");
}
FBRequestHandler GetAchievedAchievementRequestHandler()
{
return new FBRequestHandler()
{
@Override
public void invoke(FBRequestConnection connection, NSObject data,NSError error)
{
if (error != null)
{
Gdx.app.log("error", error.toString());
logout();
return;
}
JSONArray achievements_data;
try
{
achievements_data = NSObjectToJSONObject(data).getJSONArray("data");
for(int i=0;i<achievements_data.length();i++)
{
JSONObject achievement_data = achievements_data.getJSONObject(i).getJSONObject("data");
JSONObject achievement_sub_data = achievement_data.getJSONObject("achievement");
String url = achievement_sub_data.get("url").toString();
achievementManager.UnlockedAchievement(url);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
achievementManager.SetupAchievementsFinished(); //finished loading after this
}
};
}
public void GetAchievementInformation()
{
Gdx.app.log("request", "Getting achievement information");
GetAchievementsRequest().start(GetAchievementsRequestHandler());
}
JSONObject NSObjectToJSONObject(NSObject object)
{
JSONObject json = null;
String jsonString64 = NSJSONSerialization.createJSONData(object, NSJSONWritingOptions.PrettyPrinted).toBase64EncodedString(NSDataBase64EncodingOptions.None);
String jsonString = Base64Coder.decodeString(jsonString64);
Gdx.app.log("json", "to json:" + jsonString);
try {
json = new JSONObject(jsonString);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return json;
}
这是通过添加修复的内存泄漏:connection.dispose();
我不确定为什么这不是我提出的其他请求的问题。但在这里它导致了崩溃。
我已经断断续续地尝试修复这个崩溃几个星期了,但我还没有找到问题所在。当我 运行 在我的 Libgdx 游戏中使用以下函数 "GetAchievementsInformation()" 时,应用程序崩溃并显示 "cannot detach thread when there are non native frames on the call stack"
我是不是做错了什么?我的大多数其他 Facebook 请求 运行 都很好(我有第二个请求也有同样的错误)
public FBRequest GetAchievementsRequest()
{
return new FBRequest(FBSession.getActiveSession(),"/"+ APP_ID + "/achievements", null,"GET");
}
FBRequestHandler GetAchievementsRequestHandler()
{
return new FBRequestHandler()
{
@Override
public void invoke(FBRequestConnection connection, NSObject data, NSError error)
{
if (error != null)
{
Gdx.app.log("error", error.toString());
logout();
return;
}
JSONArray achievements_data;
try {
achievements_data = NSObjectToJSONObject(data).getJSONArray("data");
for(int i=0;i<achievements_data.length();i++)
{
JSONObject achievement_data = achievements_data.getJSONObject(i);
JSONObject pointdata = achievement_data.getJSONObject("data");
String points_data = pointdata.get("points").toString();
int score = Integer.parseInt(points_data);
String url = achievement_data.get("url").toString();
JSONArray list = achievement_data.getJSONArray("image");
String image_url = list.getJSONObject(0).get("url").toString();
achievementManager.AddInformationToAchievement(url, score,image_url);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Gdx.app.log("request", "get achieved achievements");
GetAchievedAchievementsRequest().start(GetAchievedAchievementRequestHandler());
}
};
}
public FBRequest GetAchievedAchievementsRequest()
{
return new FBRequest(FBSession.getActiveSession(),"/me/achievements", null, "GET");
}
FBRequestHandler GetAchievedAchievementRequestHandler()
{
return new FBRequestHandler()
{
@Override
public void invoke(FBRequestConnection connection, NSObject data,NSError error)
{
if (error != null)
{
Gdx.app.log("error", error.toString());
logout();
return;
}
JSONArray achievements_data;
try
{
achievements_data = NSObjectToJSONObject(data).getJSONArray("data");
for(int i=0;i<achievements_data.length();i++)
{
JSONObject achievement_data = achievements_data.getJSONObject(i).getJSONObject("data");
JSONObject achievement_sub_data = achievement_data.getJSONObject("achievement");
String url = achievement_sub_data.get("url").toString();
achievementManager.UnlockedAchievement(url);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
achievementManager.SetupAchievementsFinished(); //finished loading after this
}
};
}
public void GetAchievementInformation()
{
Gdx.app.log("request", "Getting achievement information");
GetAchievementsRequest().start(GetAchievementsRequestHandler());
}
JSONObject NSObjectToJSONObject(NSObject object)
{
JSONObject json = null;
String jsonString64 = NSJSONSerialization.createJSONData(object, NSJSONWritingOptions.PrettyPrinted).toBase64EncodedString(NSDataBase64EncodingOptions.None);
String jsonString = Base64Coder.decodeString(jsonString64);
Gdx.app.log("json", "to json:" + jsonString);
try {
json = new JSONObject(jsonString);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return json;
}
这是通过添加修复的内存泄漏:connection.dispose();
我不确定为什么这不是我提出的其他请求的问题。但在这里它导致了崩溃。