0

SCROLL DOWN TO SEE THE ERROR MESSAGE

On occasion my app expects input from the user. When he does enter something, I use Toasts to display that the input was accepted.

And so far... this worked great! But eventually I noticed, when I started spamming the input button the app would freeze.

After some trial and error, I noticed, the problem was neither the button spamming nor the creation of Toasts.

So you can follow my conclusion, I am gonna list here the most important points. (On a side note: I am working in Kotlin and haven't tried other languages)

Spamming a button with the following onClickListener freezes the app

myButton.setOnClickListener {
            Toast.makeText(this, "myText", Toast.LENGTH_SHORT).show()
        }

At first I thought there might be a problem with my button, but in the end there was nothing wrong with it. (I am not gonna post code from the button, since you can use an auto-generated one)

I then came to the conclusion that the problem may come from the generation of Toasts. After all, according to the error message, there seems to be a buffer overflow.

So I tried creating only one toast and display that one.

class... {
        val toast = Toast.makeText(this, "myText", Toast.LENGTH_SHORT)
        override fun onCreate(savedInstanceState: Bundle?) {
                ...
                myButton.setOnClickListener{
                       toast.show()
                }
        }
}

I still get the same error:

2019-03-15 18:41:08.128 5098-5122/project.path E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -2147483646
2019-03-15 18:41:08.551 779-779/? E/Fence: merge: sync_merge("StatusBar#0:0", 831, 865) returned an error: Too many open files (-24)
2019-03-15 18:41:08.586 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:08.586 779-1025/? E/BufferQueueProducer: [Toast#115] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:08.587 779-779/? E/Fence: merge: sync_merge("Toast#83:2", 831, 1008) returned an error: Too many open files (-24)
2019-03-15 18:41:08.620 779-779/? E/Fence: merge: sync_merge("Toast#83:2", 787, 943) returned an error: Too many open files (-24)
2019-03-15 18:41:08.638 779-869/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:08.638 779-869/? E/BufferQueueProducer: [Toast#116] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:08.649 779-869/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.649 779-869/? E/BufferQueueProducer: [Toast#115] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.651 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.651 779-1025/? E/BufferQueueProducer: [Toast#115] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.652 779-869/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.652 779-869/? E/BufferQueueProducer: [Toast#115] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.654 779-779/? E/Fence: merge: sync_merge("Toast#83:2", 787, 974) returned an error: Too many open files (-24)
2019-03-15 18:41:08.663 779-869/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.663 779-869/? E/BufferQueueProducer: [Toast#116] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.665 779-869/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.665 779-869/? E/BufferQueueProducer: [Toast#116] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.666 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.666 779-1025/? E/BufferQueueProducer: [Toast#116] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.687 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 974, 888) returned an error: Too many open files (-24)
2019-03-15 18:41:08.720 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 807, 814) returned an error: Too many open files (-24)
2019-03-15 18:41:08.754 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 807, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:08.771 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:08.771 779-1025/? E/BufferQueueProducer: [Toast#117] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:08.787 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 807, 847) returned an error: Too many open files (-24)
2019-03-15 18:41:08.821 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 807, 875) returned an error: Too many open files (-24)
2019-03-15 18:41:08.824 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:08.824 779-2417/? E/BufferQueueProducer: [Toast#118] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:08.832 779-779/? E/Fence: merge: sync_merge("Toast#114:2", 880, 991) returned an error: Too many open files (-24)
2019-03-15 18:41:08.835 779-869/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.835 779-869/? E/BufferQueueProducer: [Toast#117] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.836 779-869/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.836 779-869/? E/BufferQueueProducer: [Toast#117] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.837 779-869/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.837 779-869/? E/BufferQueueProducer: [Toast#117] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.849 779-869/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.849 779-869/? E/BufferQueueProducer: [Toast#118] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.851 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 857) returned an error: Too many open files (-24)
2019-03-15 18:41:08.851 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 857) returned an error: Too many open files (-24)
2019-03-15 18:41:08.851 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.851 779-2417/? E/BufferQueueProducer: [Toast#118] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.851 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:08.851 779-2417/? E/BufferQueueProducer: [Toast#118] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:08.871 779-779/? E/Fence: merge: sync_merge("Toast#85:2", 855, 991) returned an error: Too many open files (-24)
2019-03-15 18:41:08.904 779-779/? E/Fence: merge: sync_merge("Toast#87:2", 991, 909) returned an error: Too many open files (-24)
2019-03-15 18:41:08.937 779-779/? E/Fence: merge: sync_merge("Toast#87:2", -1, 814) returned an error: Too many open files (-24)
2019-03-15 18:41:08.938 779-779/? E/Fence: merge: sync_merge("Toast#88:2", 991, 814) returned an error: Too many open files (-24)
2019-03-15 18:41:08.976 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:08.976 779-867/? E/BufferQueueProducer: [Toast#119] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:08.977 3669-3684/? E/FusionService: is80211dEnabled true
2019-03-15 18:41:09.001 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 932) returned an error: Too many open files (-24)
2019-03-15 18:41:09.001 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 932) returned an error: Too many open files (-24)
2019-03-15 18:41:09.002 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 932) returned an error: Too many open files (-24)
2019-03-15 18:41:09.008 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.008 779-1025/? E/BufferQueueProducer: [Toast#120] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.020 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.020 779-1025/? E/BufferQueueProducer: [Toast#119] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.021 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.021 779-1025/? E/BufferQueueProducer: [Toast#119] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.022 779-2417/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.023 779-2417/? E/BufferQueueProducer: [Toast#119] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.028 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.028 779-2417/? E/BufferQueueProducer: [Toast#120] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.036 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.037 779-2417/? E/BufferQueueProducer: [Toast#120] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.038 779-867/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.038 779-867/? E/BufferQueueProducer: [Toast#120] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.038 779-779/? E/Fence: merge: sync_merge("Toast#87:2", 814, 949) returned an error: Too many open files (-24)
2019-03-15 18:41:09.052 779-779/? E/Fence: merge: sync_merge("Toast#107:2", 958, 982) returned an error: Too many open files (-24)
2019-03-15 18:41:09.069 779-779/? E/Fence: merge: sync_merge("Toast#108:2", 982, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:09.083 2571-5992/? E/NetworkScheduler: Invalid component specified.
2019-03-15 18:41:09.085 779-779/? E/Fence: merge: sync_merge("Toast#109:2", 982, 1006) returned an error: Too many open files (-24)
2019-03-15 18:41:09.122 779-779/? E/Fence: merge: sync_merge("Toast#87:2", 958, 973) returned an error: Too many open files (-24)
2019-03-15 18:41:09.139 2571-5991/? E/NetworkScheduler: Invalid component specified.
2019-03-15 18:41:09.158 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.158 779-867/? E/BufferQueueProducer: [Toast#121] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.184 779-779/? E/HwcComposer: executeCommands failed because of Status(EX_TRANSACTION_FAILED): 'FAILED_TRANSACTION: '
2019-03-15 18:41:09.184 779-779/? E/HWComposer: presentAndGetReleaseFences: failed for display 0: NoResources (6)
2019-03-15 18:41:09.185 779-779/? E/Fence: merge: sync_merge("Toast#101:2", 847, 880) returned an error: Too many open files (-24)
2019-03-15 18:41:09.190 779-867/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.191 779-867/? E/BufferQueueProducer: [Toast#122] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.196 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.196 779-867/? E/BufferQueueProducer: [Toast#121] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.197 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.197 779-867/? E/BufferQueueProducer: [Toast#121] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.197 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.197 779-1025/? E/BufferQueueProducer: [Toast#121] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.204 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.204 779-1025/? E/BufferQueueProducer: [Toast#122] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.205 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.205 779-1025/? E/BufferQueueProducer: [Toast#122] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.206 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.206 779-1025/? E/BufferQueueProducer: [Toast#122] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.222 779-779/? E/Fence: merge: sync_merge("Toast#88:2", 814, 845) returned an error: Too many open files (-24)
2019-03-15 18:41:09.223 779-779/? E/Fence: merge: sync_merge("Toast#102:2", 880, 814) returned an error: Too many open files (-24)
2019-03-15 18:41:09.304 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.304 779-1025/? E/BufferQueueProducer: [Toast#123] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.322 779-779/? E/Fence: merge: sync_merge("Toast#89:2", 814, 847) returned an error: Too many open files (-24)
2019-03-15 18:41:09.358 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.358 779-1025/? E/BufferQueueProducer: [Toast#124] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.369 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.369 779-867/? E/BufferQueueProducer: [Toast#123] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.370 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.370 779-867/? E/BufferQueueProducer: [Toast#123] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.372 779-867/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.372 779-867/? E/BufferQueueProducer: [Toast#123] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.385 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.385 779-2417/? E/BufferQueueProducer: [Toast#124] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.386 779-1025/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.387 779-1025/? E/BufferQueueProducer: [Toast#124] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.387 779-2417/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.387 779-2417/? E/BufferQueueProducer: [Toast#124] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.389 779-779/? E/Fence: merge: sync_merge("Toast#89:2", 814, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:09.508 779-1025/? E/GraphicBufferAllocator: Failed to allocate (224 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.508 779-1025/? E/BufferQueueProducer: [Toast#125] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.539 779-779/? E/Fence: merge: sync_merge("Toast#91:2", 963, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:09.543 779-867/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 900: 5
2019-03-15 18:41:09.543 779-867/? E/BufferQueueProducer: [Toast#126] allocateBuffers: failed to allocate buffer (0 x 0, format 0, usage 0)
2019-03-15 18:41:09.570 779-779/? E/HwcComposer: executeCommands failed because of Status(EX_TRANSACTION_FAILED): 'FAILED_TRANSACTION: '
2019-03-15 18:41:09.570 779-779/? E/HWComposer: presentAndGetReleaseFences: failed for display 0: NoResources (6)
2019-03-15 18:41:09.570 779-779/? E/Fence: merge: sync_merge("Toast#91:2", -1, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:09.570 779-779/? E/Fence: merge: sync_merge("Toast#92:2", 963, 831) returned an error: Too many open files (-24)
2019-03-15 18:41:09.583 779-2542/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.583 779-2542/? E/BufferQueueProducer: [Toast#126] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.584 779-2542/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.584 779-2542/? E/BufferQueueProducer: [Toast#126] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.585 779-867/? E/GraphicBufferAllocator: Failed to allocate (623 x 98) layerCount 1 format 1 usage 10000900: 5
2019-03-15 18:41:09.585 779-867/? E/BufferQueueProducer: [Toast#126] dequeueBuffer: createGraphicBuffer failed
2019-03-15 18:41:09.601 779-779/? E/HwcComposer: executeCommands failed because of Status(EX_TRANSACTION_FAILED): 'FAILED_TRANSACTION: '
2019-03-15 18:41:09.601 779-779/? E/HWComposer: presentAndGetReleaseFences: failed for display 0: NoResources (6)
2019-03-15 18:41:09.602 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 1006) returned an error: Too many open files (-24)
2019-03-15 18:41:09.602 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 1006) returned an error: Too many open files (-24)
2019-03-15 18:41:09.614 779-779/? E/GLConsumer: [project.path/activity.exampleClass#0] doGLFenceWait: error dup'ing fence fd: 24
2019-03-15 18:41:09.614 779-779/? E/Surface: dequeueBuffer: error duping fence: 24
2019-03-15 18:41:09.619 779-779/? E/HwcComposer: executeCommands failed because of Status(EX_TRANSACTION_FAILED): 'FAILED_TRANSACTION: '
2019-03-15 18:41:09.619 779-779/? E/HWComposer: presentAndGetReleaseFences: failed for display 0: NoResources (6)
2019-03-15 18:41:09.619 779-779/? E/Fence: merge: sync_merge("FramebufferSurface:2", 1006, 875) returned an error: Too many open files (-24)
2019-03-15 18:41:09.619 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 1008) returned an error: Too many open files (-24)
2019-03-15 18:41:09.620 779-779/? E/Fence: merge: sync_merge("LayerRelease", -1, 1008) returned an error: Too many open files (-24)

Now to the question: Did somebody else encounter this error and found a fix? My workaround so far is to disable the button spamming.

I also tried displaying Toasts in their own UI-Thread, but that didn't work. (The tip came from here: Toast is crashing Application, even inside thread)

Maybe this fix works for one of you, which means, I must have done a mistake.

Thanks for your help in advance!

  • what else you are expecting on button pressing? after onClickListener toast is showing that's what you are doing right there.. BTW are you loading some list or what? – USMAN osman Mar 17 '20 at 12:35
  • @USMANosman I am not expecting more right here. For our problem here, I only want to show a Toast on a button click. Nothing else. – Chrysotomus Mar 17 '20 at 12:49
  • https://stackoverflow.com/a/16930071/12397978 read this – USMAN osman Mar 17 '20 at 14:02
  • Thanks for the fast answer! This may be the solution to the problem. Since I do already use my workaround, I won't try it though, and thus, would love to hear if somebody else tries this fix and succeeds with it! – Chrysotomus Mar 17 '20 at 14:15

0 Answers0