fbsamples / audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
https://developers.facebook.com/docs/audience-network
Other
318 stars 370 forks source link

AudienceNetworkActivity AsyncTask blocked #30

Closed zuijinbuzai closed 7 years ago

zuijinbuzai commented 7 years ago

com.facebook.android:audience-network-sdk:4.23.0 AudienceNetworkActivity var3.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new String[]{var1}); It will blocked the Other lib who used AsyncTask, pls fix it.

zuijinbuzai commented 7 years ago

sorry, I found the wrong place, It should be sdk use the AsyncTask SerialExecutor blocked for a long time. if I delete the sdk, It is ok in the place lib use AsyncTask not blocked.

fransanchez commented 7 years ago

Hey @zuijinbuzai, thanks for reporting this issue, could you provide more information about the Android API version where you are experiencing it please? That will help us narrow it down. Thank you!

zuijinbuzai commented 6 years ago

@fransanchez I'm in China,the AsyncTask will blocked by the network for a long time no response, if open vpn, it will be ok. version 4.4, 6.0 and some more, almost all deveices will blocked. so I fixed it by add this code

private void fuckAsyncTask() {
    //Fix UCrop BitmapLoadTask blocked by fb network
    try {
        Field nameField = AsyncTask.class.getDeclaredField("sDefaultExecutor");
        nameField.setAccessible(true);
        nameField.set(new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                return null;
            }
        }, Executors.newCachedThreadPool());
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}