Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4029790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:23:22+00:00 2026-05-20T11:23:22+00:00

In order to improve performance i am creating subviews for my scroll view in

  • 0

In order to improve performance i am creating subviews for my scroll view in a background thread and then posting the event to main thread using performSelectorOnMainThread and adding the view into the scrollview in it and bring it to font. However i get a crash sometimes.

When i check this in my background thread.

if( nil == myView.view.superview)

How can i perform this check thread safe in the background thread. If i have to perform on main thread then i need to change the design a lot, hence can there be a way i post it to main thread and use the return value.
I am open to alternatives on the same.

TIA,

Praveen S

EDIT:

I have implemented UIScrollview with paging. However due to performance issues and to improve responsiveness of the UI i moved creating the subviews into a different thread using

[self performSelectorInBackground:@selector(loadPages:) withObject:nil];

In load pages, i do the following

if( nil == myView.view.superview) 
{
Create the view
 [[self performSelectorOnMainThread:@selector(refreshViews:) myView.view waitUntilDone:YES];
}

In refresh view i add the subview to scrollview and bring it to front.

[myScrollView addSubview:views];
[myScrollView bringSubviewToFront:views];

However the get added and page control works fine. Scrolling is ok ok kind smooth. But when i scroll it fast( swipe across the screen in a fast manner) the application crashes.

The debugger says the crash is at obj_msgSend after the if check in the loadpages.

EDIT: Stack trace — Well it crashed at the check @synchronized this time. I have edited the crash log to remove project specific names for security reasons but the trace is as below.

#0  0x33a06464 in objc_msgSend ()
#1  0x314d6984 in -[UIViewController _loadViewFromNibNamed:bundle:] ()
#2  0x314d5cb8 in -[UIViewController loadView] ()
#3  0x313d6226 in -[UIViewController view] ()
#6  0x00009920 in -[myViewController loadPages:] (self=0x12a2a0, _cmd=0x1eac1, abcd=0x0) at 
#7  0x302d9198 in -[NSThread main] ()
#8  0x302d2248 in __NSThread__main__ ()
#9  0x3110c88c in _pthread_start ()
#10 0x31101a90 in thread_start ()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:23:23+00:00Added an answer on May 20, 2026 at 11:23 am

    UIKit is not thread-safe unless specifically marked otherwise. Creating views (and loading nibs) in the background is not supported; anything that touches a UIView needs to happen on the main thread. This applies even before your view has been added to a superview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to improve performance reading from a file, I'm trying to read the
I am writing a multi-threaded application in Java in order to improve performance over
In order to improve my open source project, I need testers. I have created
What are some things I can do to improve query performance of an oracle
I'm in a situation where I have to improve the performance of about 75
In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary
In order to perform a case-sensitive search/replace on a table in a SQL Server
In order to know how many times a pattern exists in current buffer, I
In order to debug an asp.net web app I have to have IE Script
In order to create an arbitrary precision floating point / drop in replacement for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.