Srinivas19
Srinivas19

Reputation: 39

Choreographer: Skipped 127 frames! The application may be doing too much work on its main thread

I am trying to display an image for 7 seconds and hiding it. But when I run my application its showing skipped 127 frames the application may be doing too much work on its main thread. How can I remove this error ? This is my code // Copyright 2007-2014 metaio GmbH. All rights reserved. package com.donseenu.two;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.metaio.sdk.ARViewActivity;
import com.metaio.sdk.MetaioDebug;
 import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.IMetaioSDKCallback;
import com.metaio.tools.io.AssetsManager;


public class Template extends ARViewActivity 
{

@Override
protected int getGUILayout() 
{
    // Attaching layout to the activity



    return R.layout.tutorial_hello_world; 
}


public void onButtonClick(View v)
{
    finish();
}







@Override
protected void loadContents() 
{


     this.runOnUiThread(new Runnable() {
            @Override
            public void run() {


                    try{
                      Thread.sleep(7000);
                    }
                    catch(Exception e)
                    {
                    }



                    ImageView image = (ImageView)findViewById(R.id.remove);
                image.setVisibility(View.GONE);

            }
        });






    try
    {
        // Getting a file path for tracking configuration XML file
        String trackingConfigFile = AssetsManager.getAssetPath(getApplicationContext(), "TrackingData_MarkerlessFast.xml");

        // Assigning tracking configuration
        boolean result = metaioSDK.setTrackingConfiguration(trackingConfigFile); 
        MetaioDebug.log("Tracking data loaded: " + result); 

        // Getting a file path for a 3D geometry
        String metaioManModel = AssetsManager.getAssetPath(getApplicationContext(), "augmented_city.obj");          
        if (metaioManModel != null) 
        {
            // Loading 3D geometry
            IGeometry geometry = metaioSDK.createGeometry(metaioManModel);
            if (geometry != null) 
            {
                // Set geometry properties
                geometry.setScale(4f);
            }
            else
                MetaioDebug.log(Log.ERROR, "Error loading geometry: "+metaioManModel);
        }


    }
    catch (Exception e)
    {
        MetaioDebug.printStackTrace(Log.ERROR, e);
    }
}


@Override
protected void onGeometryTouched(IGeometry geometry)
{
    // Not used in this tutorial
}


@Override
protected IMetaioSDKCallback getMetaioSDKCallbackHandler()
{
    // No callbacks needed in this tutorial
    return null;
}   
}

Upvotes: 0

Views: 1507

Answers (1)

mattm
mattm

Reputation: 5949

Don't sleep on the UI thread. During this time, the UI cannot redraw frames, so the system is correctly telling you they are being skipped.

If you want to schedule something for a few seconds in the future, use something like Handler

Upvotes: 1

Related Questions