[GH-ISSUE #6] Infinite loop on IGTV #464

Closed
opened 2026-03-13 21:30:27 +03:00 by kerem · 8 comments
Owner

Originally created by @alexal1 on GitHub (Jun 8, 2020).
Original GitHub issue: https://github.com/alexal1/Insomniac/issues/6

Cannot catch and replay this bug, maybe you guys have thoughts.

Sometimes IGTV fullscreen is accidentally being opened and then the script goes into infinite loop. It tries to find "search" button but can't. I have two questions:

  1. How is IGTV being opened?
  2. Why it doesn't return back on the main screen on some devices? open_instagram() function is called, it runs adb shell am start -n com.instagram.android/com.instagram.mainactivity.MainActivity command. Could you please check if this command returns you to the main screen while playing IGTV?

@gvmturl @GabrieleAnsaldo @xerZV

Originally created by @alexal1 on GitHub (Jun 8, 2020). Original GitHub issue: https://github.com/alexal1/Insomniac/issues/6 Cannot catch and replay this bug, maybe you guys have thoughts. Sometimes IGTV fullscreen is accidentally being opened and then the script goes into infinite loop. It tries to find "search" button but can't. I have two questions: 1. How is IGTV being opened? 2. Why it doesn't return back on the main screen on some devices? `open_instagram()` function is called, it runs `adb shell am start -n com.instagram.android/com.instagram.mainactivity.MainActivity` command. Could you please check if this command returns you to the main screen while playing IGTV? @gvmturl @GabrieleAnsaldo @xerZV
kerem 2026-03-13 21:30:27 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@xerZV commented on GitHub (Jun 8, 2020):

@alexal1
I will try it tomorrow.
Yesterday I managed to run it successfully on my Windows PC with python 3. Had to refactor some print methods, etc etc.

Also I got "Actions blocked" but maybe because I was using --repeat 10.

I noticed that when you use only one blogger every time it starts from the beginning. Maybe we should think of something like "randomize scroll" so that can pick different followers instead of going over them from the beginning.

<!-- gh-comment-id:640763775 --> @xerZV commented on GitHub (Jun 8, 2020): @alexal1 I will try it tomorrow. Yesterday I managed to run it successfully on my Windows PC with python 3. Had to refactor some print methods, etc etc. Also I got "Actions blocked" but maybe because I was using --repeat 10. I noticed that when you use only one blogger every time it starts from the beginning. Maybe we should think of something like "randomize scroll" so that can pick different followers instead of going over them from the beginning.
Author
Owner

@GabrieleAnsaldo commented on GitHub (Jun 8, 2020):

Hi guys!
So here are some questions first:
@alexal1 At what moment does IGTV open? Could you elaborate on that?
Instead of using that command, you might want to use this adb shell input keyevent KEYCODE_BACK which basically it emulates the return button to go back and close the IGTV page.

Also @xerZV and @alexal1 I think we should implement like_by_hashtag because going on each person page requires quite a lot of time. Liking by hashtag is something that is faster, which means that Instagram will stay open for less time.

How I have it implemented now is:

  1. Go to the search page
  2. Enter the desires hashtag "#my_hashtag"
  3. Click on the entered hashtag (you will get to the hashtag page)
  4. When on the hashtag page click on Recent
  5. Now you can start liking and scrolling down (This is the tricky part, we can try to find a way to do this)
<!-- gh-comment-id:640792911 --> @GabrieleAnsaldo commented on GitHub (Jun 8, 2020): Hi guys! So here are some questions first: @alexal1 At what moment does IGTV open? Could you elaborate on that? Instead of using that command, you might want to use this ```adb shell input keyevent KEYCODE_BACK``` which basically it emulates the return button to go back and close the IGTV page. Also @xerZV and @alexal1 I think we should implement like_by_hashtag because going on each person page requires quite a lot of time. Liking by hashtag is something that is faster, which means that Instagram will stay open for less time. How I have it implemented now is: 1. Go to the search page 2. Enter the desires hashtag "#my_hashtag" 3. Click on the entered hashtag (you will get to the hashtag page) 4. When on the hashtag page click on Recent 5. Now you can start liking and scrolling down (This is the tricky part, we can try to find a way to do this)
Author
Owner

@alexal1 commented on GitHub (Jun 8, 2020):

Well, thanks for your ideas, we'll implement them all, but the bug is still here and we need to handle it :)

@GabrieleAnsaldo

At what moment does IGTV open? Could you elaborate on that?

It happens when a post that contains IGTV is opened to like it. Sometimes (I don't know why) instead of liking it opens IGTV fullscreen.

you might want to use this adb shell input keyevent KEYCODE_BACK

When something goes wrong, the script catches JsonRPCError from uiautomator. We don't exactly know on which screen we are, because potentially wrong action can happen everywhere. Thus we don't exactly know where we'll be after a backpress. That's why I want a universal solution to start from the beginning in this case.

<!-- gh-comment-id:640844213 --> @alexal1 commented on GitHub (Jun 8, 2020): Well, thanks for your ideas, we'll implement them all, but the bug is still here and we need to handle it :) @GabrieleAnsaldo > At what moment does IGTV open? Could you elaborate on that? It happens when a post that contains IGTV is opened to like it. Sometimes (I don't know why) instead of liking it opens IGTV fullscreen. > you might want to use this adb shell input keyevent KEYCODE_BACK When something goes wrong, the script catches `JsonRPCError` from uiautomator. We don't exactly know on which screen we are, because potentially wrong action can happen everywhere. Thus we don't exactly know where we'll be after a backpress. That's why I want a universal solution to start from the beginning in this case.
Author
Owner

@alexal1 commented on GitHub (Jun 8, 2020):

@xerZV

I noticed that when you use only one blogger every time it starts from the beginning. Maybe we should think of something like "randomize scroll" so that can pick different followers instead of going over them from the beginning.

I was thinking about it too. Random scroll is an unreliable solution. For a blogger with 10k and 100k followers mean number of scrolls should be different.

I can suggest following algorithm:
Let's call the case when all users on the screen already are interacted a "full interaction screen".
If we meet a full interaction screen, we make a scroll. If we meet it again, we make 4 scrolls. Then 9, 16, 25, etc until a not full interaction screen is met. With this solution we will miss part of users but speed will increase.

<!-- gh-comment-id:640888610 --> @alexal1 commented on GitHub (Jun 8, 2020): @xerZV > I noticed that when you use only one blogger every time it starts from the beginning. Maybe we should think of something like "randomize scroll" so that can pick different followers instead of going over them from the beginning. I was thinking about it too. Random scroll is an unreliable solution. For a blogger with 10k and 100k followers mean number of scrolls should be different. I can suggest following algorithm: Let's call the case when _all_ users on the screen already are interacted a "full interaction screen". If we meet a full interaction screen, we make a scroll. If we meet it again, we make 4 scrolls. Then 9, 16, 25, etc until a not full interaction screen is met. With this solution we will miss part of users but speed will increase.
Author
Owner

@alexal1 commented on GitHub (Jun 9, 2020):

Okay guys I committed 1a93d827fa where

  1. Added closing instagram when smth goes wrong, which will probably fix the bug (thanks @GabrieleAnsaldo)
  2. Added quadratical steps to fasten scrolling (thanks @xerZV)
<!-- gh-comment-id:641085559 --> @alexal1 commented on GitHub (Jun 9, 2020): Okay guys I committed 1a93d827faac7bec3cd7385e9d1b5a0dcf0c3ce0 where 1. Added closing instagram when smth goes wrong, which will probably fix the bug (thanks @GabrieleAnsaldo) 2. Added quadratical steps to fasten scrolling (thanks @xerZV)
Author
Owner

@xerZV commented on GitHub (Jun 9, 2020):

Unfortunately Im still getting Actions blocked. Maybe I should try to use another phone or? ANy ideas?

<!-- gh-comment-id:641117301 --> @xerZV commented on GitHub (Jun 9, 2020): Unfortunately Im still getting `Actions blocked`. Maybe I should try to use another phone or? ANy ideas?
Author
Owner

@GabrieleAnsaldo commented on GitHub (Jun 9, 2020):

Hi @xerZV , I have a very dirty way of solving this problem. Firstly, make sure that you don’t like too many posts per session. As an example I like about 300 posts per session and I have 6 to 7 sessions a day.

Secondly, if you want to remove the block what you can do is to delete the user data cache and log in again to Instagram. To do so you can simply use the adb command: adb shell pm clear com.instagram.android. However you have to make sure to log in again to your Instagram account and accept the warnings such as “instagrams would like to access your location etc.”

<!-- gh-comment-id:641126725 --> @GabrieleAnsaldo commented on GitHub (Jun 9, 2020): Hi @xerZV , I have a very dirty way of solving this problem. Firstly, make sure that you don’t like too many posts per session. As an example I like about 300 posts per session and I have 6 to 7 sessions a day. Secondly, if you want to remove the block what you can do is to delete the user data cache and log in again to Instagram. To do so you can simply use the adb command: adb shell pm clear com.instagram.android. However you have to make sure to log in again to your Instagram account and accept the warnings such as “instagrams would like to access your location etc.”
Author
Owner

@alexal1 commented on GitHub (Jun 11, 2020):

@xerZV I refused of quadratic steps to speed up scrolling followers: it's unexpected behavior for some users. Instead I worked on optimization: a1da48e5cb. Now it checks each user in the list always, but doesn't wait for 3-4 seconds at the end of the list. git pull to get current version please.

<!-- gh-comment-id:642539590 --> @alexal1 commented on GitHub (Jun 11, 2020): @xerZV I refused of quadratic steps to speed up scrolling followers: it's unexpected behavior for some users. Instead I worked on optimization: a1da48e5cbadfdb654d31bf252a7005a464daeba. Now it checks each user in the list always, but doesn't wait for 3-4 seconds at the end of the list. `git pull` to get current version please.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Insomniac#464
No description provided.