gpt4 book ai didi

java - libgdx robovm 在调用堆栈上具有非 native 帧的分离线程上崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 14:12:26 25 4
gpt4 key购买 nike

我已经断断续续地尝试修复这个崩溃数周了,但我还没有发现问题。当我在 Libgdx 游戏中运行以下函数“GetAchievementsInformation()”时,应用程序崩溃并显示“当调用堆栈上存在非 native 帧时无法分离线程”

我在这里做错了什么吗?我的大多数其他 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();

我不确定为什么这与我提出的其他请求无关。但在这里它导致了崩溃。

关于java - libgdx robovm 在调用堆栈上具有非 native 帧的分离线程上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28150832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com