werbhelius/PickPhotoSample

Remove Glide Pause and Resume Request?

rayliverified opened this issue · 6 comments

What is the purpose of pausing and then resuming Glide image loading in PickPhotoActivity?

    RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (Math.abs(dy) > PickConfig.SCROLL_THRESHOLD) {
                manager.pauseRequests();
            } else {
                manager.resumeRequests();
            }
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                manager.resumeRequests();
            }
        }
    };

Performance is much improved by removing this code and allowing Glide to perform all logic related to image loading.

Fixed in PR #27

@searchy2 When the slide loads the image, it's easy to create OOM,When it's moving fast Glide Pause and Resume the image will not be loaded

Can you please test my build? I have tested it and experienced no errors scrolling through 2000+ images very quickly.

There is no performance impact using Glide while pausing and resuming creates a noticeable lag while loading images.

@searchy2 How about the memory ? low profile mobile will OOM , remove Pause and Resume memory will ingcreasing and wont't call GC to release

Glide is supposed to be really good about memory management. I think if you let Glide handle all image loading, it will prevent any OOM errors. Unfortunately, I have no low specced device to test this out on.

Have you had a chance to test on a low end device?