Twitter.Compose showing the wrong picture preview

bug
unity
bugreporting

#1

Title says it, i originally thought it was my code but i do believe its a bug in twitter itself. Here is how I implement a screenshot.

IEnumerator ScreenShotAndPost(TwitterSession session)
    {
        yield return new WaitForEndOfFrame();
        var width = Screen.width;
        var height = Screen.height;
        var texture = new Texture2D(width, height, TextureFormat.RGB24, false);
        texture.ReadPixels(new Rect(0, 0, width, height), 0, 0);
        texture.Apply();
        byte[] bytes = texture.EncodeToPNG();
        FileStream stream = new FileStream(Application.persistentDataPath + "/TempScreenShot.png", FileMode.OpenOrCreate, FileAccess.Write);
        BinaryWriter writer = new BinaryWriter(stream);
        for (int i = 0; i < bytes.Length; i++)
        {
            writer.Write(bytes[i]);
        }
        writer.Close();
        stream.Close();
        DestroyImmediate(texture);


        PlayerPrefs.SetString("LogInToken", Utilities.Encryption.AESEncryption.Encrypt(TwitterSession.Serialize(session), "somepasswordoops"));
        //      ScreenCapture.CaptureScreenshot("TempScreenShot.png");
        ComposeTweet(session);
    }

    private void ComposeTweet(TwitterSession session)
    {
        string imageUri = "file://" + Application.persistentDataPath + "/TempScreenShot.png";
        debugtext.text = imageUri;
        Twitter.Compose(session, imageUri, "Look at my Zombie!", new string[] { "#EddiePetZombie" },
            (string tweetId) => {  },
            (ApiError error) => {
                
                PlayerPrefs.SetString("LogInToken", ""); startLogin();

            },
            () => {  }
         );
    }

however the behaviour is persistent using any kind of screenshotting method (i.e, example code)

once the tweet is posted it does actually upload the right screenshot

you can replicate this simply by adding the starred code below and adding the img reference in the editor


    **public UnityEngine.UI.Image img;**

    public void LoginCompleteWithCompose(TwitterSession session) {
		ScreenCapture.CaptureScreenshot("Screenshot.png");
		UnityEngine.Debug.Log ("Screenshot location=" + Application.persistentDataPath + "/Screenshot.png");
		string imageUri = "file://" + Application.persistentDataPath + "/Screenshot.png";
		Twitter.Compose (session, imageUri, "Welcome to", new string[]{"#TwitterKitUnity"},
			(string tweetId) => { UnityEngine.Debug.Log ("Tweet Success, tweetId=" + tweetId); },
			(ApiError error) => { UnityEngine.Debug.Log ("Tweet Failed " + error.message); },
			() => { Debug.Log ("Compose cancelled"); }
		 );
        **img.color = Color.red;**
    }

you can observe that after taking the first screenshot(turning the button red after it has been taken), taking a second one will still show the first (white button) in the twitter post pop up. once uploaded, however, it will be right.

Test device:
Xperia XA1 ultra (g3223)
Android 7.0