New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TwitterKit 3 causes black screen for long time on app launching #89

Open
JEKos opened this Issue Jul 4, 2017 · 24 comments

Comments

@JEKos

JEKos commented Jul 4, 2017

Hi, after changing from fabric's twitterkit to twitterkit 3, there is big delay when I'm launching my app. After the splash screen there is a black screen for ~8sec, log says this:

W/Twitter: Could not call isLimitAdTrackingEnabled on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
D/Twitter: Could not get parcel from Google Play Service to capture AdvertisingId
D/Twitter: Could not get parcel from Google Play Service to capture Advertising limitAdTracking
D/Twitter: AdvertisingInfo not present

I'm not using any ads on my app.

I tested it, removing twitterkit's initialization, and the black screen doesn't appear at all, so is definitely from that.

@efrohnhoefer

This comment has been minimized.

Contributor

efrohnhoefer commented Jul 5, 2017

Likely similar to A lot of ANR after Twitter SDK update to 3.0.0. Currently the workaround is to run initialization in the background. We are looking to address the issue in the SDK.

@laruedavid

This comment has been minimized.

laruedavid commented Jul 7, 2017

Hi, i have the same bug during my first tweet display in my app.

During the ANR we got two logs from your sdk :
W/Twitter: Could not call getAdvertisingIdInfo on com.google.android.gms.ads.identifier.AdvertisingIdClient
W/Twitter: Could not call getId on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info

I think it's due to AdvertisingInfoReflectionStrategy.getInfo() method throw an exception because it's forbidden to call com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo in main thread ("java.lang.IllegalStateException: Calling this from your main thread can lead to deadlock") .

So AdvertisingInfoReflectionStrategy.getInfo() return null and AdvertisingInfoReflectionStrategy.isLimitAdTrackingEnabled() got a NullPointerException

Thanks

@JEKos

This comment has been minimized.

JEKos commented Jul 30, 2017

This problem still exists in 3.1.0

@stephenmcbride

This comment has been minimized.

stephenmcbride commented Aug 11, 2017

Any estimate on when this will be fixed?

@cstillwell89

This comment has been minimized.

cstillwell89 commented Aug 11, 2017

I get this same issue immediately after calling:

final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(context).setTimeline(userTimeline).build();

My logcat prints the following while the above command is running.

W: Could not call getId on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
W: Could not call isLimitAdTrackingEnabled on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
D: Could not get parcel from Google Play Service to capture AdvertisingId
D: Could not get parcel from Google Play Service to capture Advertising limitAdTracking
D: AdvertisingInfo not present
W: Long monitor contention with owner twitter-worker1 (24314) at java.lang.Object dalvik.system.DexFile.openDexFileNative(java.lang.String, java.lang.String, int, java.lang.ClassLoader, dalvik.system.DexPathList$Element[])(DexFile.java:-2) waiters=0 in com.twitter.sdk.android.core.internal.AdvertisingInfo com.twitter.sdk.android.core.internal.IdManager.getAdvertisingInfo() for 20.318s

I'm using com.twitter.sdk.android:twitter:3.1.0 for my project.

@JEKos

This comment has been minimized.

JEKos commented Aug 11, 2017

I found a fix

add new Thread(() -> TweetUi.getInstance()).start(); after Twitter.initialize(this);
credits to PiotrWpl here

@cstillwell89

This comment has been minimized.

cstillwell89 commented Aug 23, 2017

@JEKos That isn't much of a fix if you are trying to load a timeline on the main activity as you will still have to wait the 20+ seconds for the initialization to finish before the timeline gets built.

As an aside, the issue is still present in 3.1.1

@brayanL

This comment has been minimized.

brayanL commented Aug 30, 2017

Hello, the problem is still persistent, some solution other than the above proposal

@stephenmcbride

This comment has been minimized.

stephenmcbride commented Sep 11, 2017

It has been over 2 months since this was first reported, can we get an ETA on when this will be fixed please @efrohnhoefer?

@kenyee

This comment has been minimized.

kenyee commented Sep 24, 2017

Getting hit by this too..upgraded a bunch of libraries and chased the weird program pauses to this too :-(

@c0dehunter

This comment has been minimized.

c0dehunter commented Oct 23, 2017

C'mon now guys, we need a fix.

@polson

This comment has been minimized.

polson commented Nov 1, 2017

Just chiming in that I would also like to see this fixed

@andon

This comment has been minimized.

andon commented Nov 13, 2017

We are experiencing the same issue. Would like to get this fixed as well.

andon added a commit to netceteragroup/react-native-twitterkit that referenced this issue Nov 13, 2017

Initialize TweetUi
Due to a freezes reported, we initialize the TweetUi as per the following open issues:
- twitter/twitter-kit-android#89
- https://twittercommunity.com/t/a-lot-of-anr-after-twitter-sdk-update-to-3-0-0/89701
@efrohnhoefer

This comment has been minimized.

Contributor

efrohnhoefer commented Nov 13, 2017

We just released version 3.2.0 that we think addresses the issue. If there is still a problem it would be helpful if someone could provided a sample app that reproduces the issue.

@laruedavid

This comment has been minimized.

laruedavid commented Nov 14, 2017

It's seems to work better for me, it's no longer necessary to do :
new Thread(() -> TweetUi.getInstance()).start();

@JEKos

This comment has been minimized.

JEKos commented Nov 14, 2017

Problem still exists in 3.2.0, new Thread(() -> TweetUi.getInstance()).start(); solves the problem again for me

@cashjason

This comment has been minimized.

cashjason commented Dec 17, 2017

Any updates on a fix for this? The thread did not work for me

@cstillwell89

This comment has been minimized.

cstillwell89 commented Dec 18, 2017

Version 3.1.1 fixed the issue for me. I had to update my code to the following

TwitterConfig config = new TwitterConfig.Builder(this)
            .logger(new DefaultLogger(Log.DEBUG))
            .twitterAuthConfig(new TwitterAuthConfig(getTwitterKey(), getTwitterSecret()))
            .debug(true)
            .build();
 Twitter.initialize(config);

And I get the timeline using the following

UserTimeline userTimeline = new UserTimeline.Builder().screenName("...").build();
    userTimeline.next(null, new Callback<TimelineResult<Tweet>>() {
        @Override
        public void success(Result<TimelineResult<Tweet>> result) { ... }
        @Override
        public void failure(TwitterException exception) { ... }
    });
@ay8s

This comment has been minimized.

ay8s commented Jan 28, 2018

Much better with v3.1.1 for me.

@AppGrade-D

This comment has been minimized.

AppGrade-D commented Feb 14, 2018

I think it still exists in version 3.2.0

@pamartineza

This comment has been minimized.

pamartineza commented Feb 16, 2018

My working solution that doesn't block UI thread (tested on SDK v3.2.0)

//Twitter sdk initialization
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
TwitterConfig config = new TwitterConfig.Builder(getContext())
                .twitterAuthConfig(authConfig)
                .build();
Twitter.initialize(config);
//Define your userTimeLine
 val userTimeLine = UserTimeline.Builder()
                .screenName(yourHandle)
                .maxItemsPerRequest(10)
                .includeReplies(false)
                .includeRetweets(true)
                .build()

//Request tweets async
userTimeLine.next(null, object: Callback<TimelineResult<Tweet>?>() {
            override fun success(result: Result<TimelineResult<Tweet>?>?) {

               //Once tweets have been retrieved then create your adapter
                val adapter = TweetTimelineListAdapter.Builder(context)
                    .setTimeline(userTimeLine)
                    .build();

                //Set adapter for your listview
                listLv.adapter = adapter
            }

            override fun failure(exception: TwitterException?) {
               //handle failure
            }
        })
@JEKos

This comment has been minimized.

JEKos commented Feb 17, 2018

@pamartineza Yep, I tested it and it working! Thanks!

@pwahid

This comment has been minimized.

pwahid commented Feb 24, 2018

On Twitter SDK v3.2.0.
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\mypc\ .gradle\caches\transforms-1\files-1.1\tweet-ui-3.2.0.aar\fff28dafeed80062205ad8b22682a05f\jars\classes.jar

Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/twitter/sdk/android/tweetui/FilterTimelineDelegate$TimelineFilterCallback.class

Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\mypc\ .gradle\caches\transforms-1\files-1.1\tweet-ui-3.2.0.aar\fff28dafeed80062205ad8b22682a05f\jars\classes.jar

my application details-
minSdkVersion 21
targetSdkVersion 26

@rslama

This comment has been minimized.

rslama commented Mar 13, 2018

Even v. 3.1.1 somehow works better (in term of freezing UI) than v. 3.2.0 there are still phones which handle that very bad way.
Is any plan/schedule for fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment