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

Fix an issue where the media download would not start until the end of the scroll #1721

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion MatrixSDK/Utils/Media/MXMediaLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ - (void)downloadMediaFromURL:(NSString *)url
request.HTTPBody = [NSJSONSerialization dataWithJSONObject:data options:0 error:nil];
}

downloadConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
// if we use the default settings the connection object will be scheduled in the NSDefaultRunLoopMode. That means that the connection is only executing the request when the app’s run loop is in NSDefaultRunLoopMode.
// Now, when a user touches the screen (e.g. to scroll a UIScrollView) the run loop’s mode will be switched to NSEventTrackingRunLoopMode. And now, that the run loop is not in NSDefaultRunMode anymore, the connection will not execute. The ugly effect of that is, that the download is blocked whenever the user touches the screen
// Setting the mode to NSRunLoopCommonModes allow the request to work in all modes (even NSEventTrackingRunLoopMode)
downloadConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
[downloadConnection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
[downloadConnection start];
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-1721.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue where MXMediaLoader would not start downloading until the end of the scroll.