Skip to content

Paging3 uses the MainThread RPC calling that block the ui thread #72

@bytetang

Description

@bytetang

I wrap the RecyclerView with a SwipeRefreshLayout, when first enter the list page, set the SwipeRefreshLayout to loading progress, then do the paging refresh call like this,

 @ExperimentalCoroutinesApi
    private fun searchHistoryData() {
        swipe_container.isRefreshing = true

        searchJob?.cancel()
        searchJob = lifecycleScope.launch {
            viewModel?.refreshGameHistory()?.collect {
                swipe_container.isRefreshing = false
                adapter.submitData(it)
            }
        }
    }

Found the loading components not showing expected. profile the process via Android Studio, the RPC call executed after the adapter.submitData() calling, and it's running upon the main thread.

Since the PRC logics are in PagingSource load() suspend function. I can't decide the load function execute in which thread. my PRC function is a GRPC function, If I convert it to an async function, it will not convenient to handle the result.

In addition, the same as loading views, the footer view LoadState also been blocked.

And how should I do about this issue? If can consider adding an IO thread way to support it?

dependencies:
implementation "androidx.paging:paging-runtime:3.0.0-alpha01"
thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions