Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[image][Android] Fix You can't start or clear loads in RequestListener or Target callbacks #21192

Merged
merged 3 commits into from
Feb 14, 2023

Conversation

lukmccall
Copy link
Contributor

Why

Fixes #21073.

How

Added a short delay between calling the onResourceReady and the modification of the underlying view content. More information in the code.

Test Plan

  • bare-expo
    • debug ✅
    • release ✅

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Feb 13, 2023
Comment on lines +240 to +248
// The "onResourceReady" function will be triggered when the new resource is available by the Glide.
// According to the Glide documentation (https://bumptech.github.io/glide/doc/debugging.html#you-cant-start-or-clear-loads-in-requestlistener-or-target-callbacks),
// it's not advisable to clear the Glide target within the stack frame.
// To avoid this, a new runnable is posted to the front of the main queue, which can then clean or create targets.
// This ensures that the "onResourceReady" frame of the Glide code will be discarded, and the internal state can be altered once again.
// Normally, using "postAtFrontOfQueue" can lead to issues such as message queue starvation, ordering problems, and other unexpected consequences.
// However, in this case, it is safe to use as long as nothing else is added to the queue.
// The intention is simply to wait for the Glide code to finish before the content of the underlying views is changed during the same rendering tick.
mainHandler.postAtFrontOfQueue {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this was changed. The rest is here because of the different formatting which has to be applied.

@lukmccall lukmccall merged commit ac324c0 into main Feb 14, 2023
@lukmccall lukmccall deleted the @lukmccall/image/fix-release-crashes branch February 14, 2023 12:17
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Feb 14, 2023
@tsapeta tsapeta added the published Changes from the PR have been published to npm label Feb 14, 2023
tsapeta pushed a commit that referenced this pull request Feb 14, 2023
…er or Target callbacks` (#21192)

# Why

Fixes #21073.

# How

Added a short delay between calling the `onResourceReady` and the modification of the underlying view content. More information in the code. 

# Test Plan

- bare-expo 
  - debug ✅
  - release ✅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[expo-image] Android: Crash on release when set placeholder props with blurhash ( works fine in dev-client))
3 participants