[GH-ISSUE #149] detect_block() adds 6 seconds overhead to every like/follow. #579

Closed
opened 2026-03-13 22:00:41 +03:00 by kerem · 2 comments
Owner

Originally created by @S0yKaf on GitHub (Oct 21, 2020).
Original GitHub issue: https://github.com/alexal1/Insomniac/issues/149

Hello, Writing this issue to document this time overhead that the detect_block() function adds to every action.

you can see from the logs here:

[10/21 17:29:50] Back to followers list
[10/21 17:29:50] @constructedworlds: interact
[10/21 17:29:51] Sleep for 0.647648662727738 seconds
[10/21 17:29:52] Likes count: 3
[10/21 17:29:52] Scroll down to see more photos.
[10/21 17:29:53] Sleep for 0.8904680090377439 seconds
[10/21 17:29:54] Open and like photo #1 (1 row, 2 column)
[10/21 17:29:55] Sleep for 1.0753480766378647 seconds
[10/21 17:29:56] Double click!   <---- detect_block() happens after this
[10/21 17:30:02] Back to profile
[10/21 17:30:02] Sleep for 0.4797770866813411 seconds
[10/21 17:30:02] Sleep for 0.9605292394437299 seconds
[10/21 17:30:03] Open and like photo #2 (1 row, 3 column)
[10/21 17:30:04] Sleep for 0.7575264996265683 seconds
[10/21 17:30:05] Double click!  <---- detect_block() happens after this
[10/21 17:30:11] Back to profile
[10/21 17:30:11] Sleep for 0.40442785320908486 seconds
[10/21 17:30:11] Sleep for 0.9480976582214997 seconds
[10/21 17:30:12] Open and like photo #3 (2 row, 1 column)
[10/21 17:30:13] Sleep for 1.1523794801325018 seconds
[10/21 17:30:14] Double click!  <---- detect_block() happens after this
[10/21 17:30:20] Back to profile
[10/21 17:30:20] Sleep for 0.46650675113231616 seconds

That detect_block() adds a consistent 6 - 7 seconds delay every time it's called.

A way should be found to optimized this function, as over time, it contributes heavily towards the time Instagram is kept running. Since we know Instagram keeps track of how long the app is open, I think It would be a good idea to optimize this function to keep this number down.

Here's the function in question:

def detect_block(device):
    block_dialog = device.find(resourceId='com.instagram.android:id/dialog_root_view',
                               className='android.widget.FrameLayout')
    is_blocked = block_dialog.exists()
    if is_blocked:
        print(COLOR_FAIL + "Probably block dialog is shown." + COLOR_ENDC)
        raise ActionBlockedError("Seems that action is blocked. Consider reinstalling Instagram app and be more careful"
                                 " with limits!")

I will do research on my side to see how this could be optimized. I'm also currently experimenting having the check removed altogether to see if it affects Instagrams bot detection.

Side Note:
If you're wondering why my sleeps are floats, I added custom sleep values as I found the default ones slightly too slow. as in, I normally interact faster than the bot does. the floats are simply for added randomness in the sleeping time.

Originally created by @S0yKaf on GitHub (Oct 21, 2020). Original GitHub issue: https://github.com/alexal1/Insomniac/issues/149 Hello, Writing this issue to document this time overhead that the `detect_block()` function adds to every action. you can see from the logs here: ``` [10/21 17:29:50] Back to followers list [10/21 17:29:50] @constructedworlds: interact [10/21 17:29:51] Sleep for 0.647648662727738 seconds [10/21 17:29:52] Likes count: 3 [10/21 17:29:52] Scroll down to see more photos. [10/21 17:29:53] Sleep for 0.8904680090377439 seconds [10/21 17:29:54] Open and like photo #1 (1 row, 2 column) [10/21 17:29:55] Sleep for 1.0753480766378647 seconds [10/21 17:29:56] Double click! <---- detect_block() happens after this [10/21 17:30:02] Back to profile [10/21 17:30:02] Sleep for 0.4797770866813411 seconds [10/21 17:30:02] Sleep for 0.9605292394437299 seconds [10/21 17:30:03] Open and like photo #2 (1 row, 3 column) [10/21 17:30:04] Sleep for 0.7575264996265683 seconds [10/21 17:30:05] Double click! <---- detect_block() happens after this [10/21 17:30:11] Back to profile [10/21 17:30:11] Sleep for 0.40442785320908486 seconds [10/21 17:30:11] Sleep for 0.9480976582214997 seconds [10/21 17:30:12] Open and like photo #3 (2 row, 1 column) [10/21 17:30:13] Sleep for 1.1523794801325018 seconds [10/21 17:30:14] Double click! <---- detect_block() happens after this [10/21 17:30:20] Back to profile [10/21 17:30:20] Sleep for 0.46650675113231616 seconds ``` That `detect_block()` adds a consistent 6 - 7 seconds delay every time it's called. A way should be found to optimized this function, as over time, it contributes heavily towards the time Instagram is kept running. Since we know Instagram keeps track of how long the app is open, I think It would be a good idea to optimize this function to keep this number down. Here's the function in question: ```python def detect_block(device): block_dialog = device.find(resourceId='com.instagram.android:id/dialog_root_view', className='android.widget.FrameLayout') is_blocked = block_dialog.exists() if is_blocked: print(COLOR_FAIL + "Probably block dialog is shown." + COLOR_ENDC) raise ActionBlockedError("Seems that action is blocked. Consider reinstalling Instagram app and be more careful" " with limits!") ``` I will do research on my side to see how this could be optimized. I'm also currently experimenting having the check removed altogether to see if it affects Instagrams bot detection. **Side Note:** If you're wondering why my sleeps are floats, I added custom sleep values as I found the default ones slightly too slow. as in, I normally interact faster than the bot does. the floats are simply for added randomness in the sleeping time.
kerem closed this issue 2026-03-13 22:00:46 +03:00
Author
Owner

@10000hzl commented on GitHub (Oct 23, 2020):

I like the floats thing, I implemented it too and it's cool to have.
I don't ever get an extra 6-7 seconds overhead though, maybe closer to 1-2 seconds.

<!-- gh-comment-id:715632567 --> @10000hzl commented on GitHub (Oct 23, 2020): I like the floats thing, I implemented it too and it's cool to have. I don't ever get an extra 6-7 seconds overhead though, maybe closer to 1-2 seconds.
Author
Owner

@Fadude commented on GitHub (Jan 6, 2021):

There is a new parameter called dont-indicate-softban from version 3.5.0. If you wish to not use the softban-detection feature, just add this flag to your insomniac command.

<!-- gh-comment-id:755277433 --> @Fadude commented on GitHub (Jan 6, 2021): There is a new parameter called `dont-indicate-softban` from version 3.5.0. If you wish to not use the softban-detection feature, just add this flag to your insomniac command.
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#579
No description provided.