Re: ScreenSaverView gets instantiated several times
On Oct 5, 2009, at 3:39 AM, Gabriel Zachmann wrote: When the user clicks 'Test' in System Preferences, it "just" creates a new instance of your subclass of ScreenSaverView! Do you really find that fact to be "shocking"? Yes, I do. [snip] If only Apple would have said so in big letters at the beginning of the docs of ScreenSaverView! The documentation on creating screen savers is pretty sparse, no argument here. There are also sample screen savers available from the developer site, as well as other sources that can help you understand more about the environment you're entering. The absence of documented details may lead you to making some assumptions about how your screen saver objects are created and the environment in which they operate, but it is important to test those assumptions before you get too far down the road. I can see being "surprised" when an assumption proves to be inaccurate. I would reserve "shocked" for situations where the documentation is inaccurate or the actual implementation seems to be in contradiction with patterns found in other frameworks. What did you suppose would happen (not that suppositions and assumptions are worth much)? I supposed that the screen saver manager would just call - initWithFrame: again. As Uli pointed out previously, calling -initWithFrame: (or any init method) multiple times on one object is not a pattern you find in other classes/frameworks. You might have assumed a call to -setFrame:, if you assumed the same view was being used and resized, but that would be easy to test to verify your assumption. Extra credit: the user has multiple displays attached, "Main screen only" option is off, and the user clicks the Test button or activates your screen saver (hot corner, inactivity). What do you expect will happen then? I assumed it would load(!) & run the screen saver bundle multiple times. And it's not that this assumption is complete nonsense, is it? Depending upon your knowledge of bundles, it wouldn't be an outrageous assumption to make. As Uli pointed out, there are reasons this isn't the case. This assumption would again be something important to test early in development. What actually does happen? With multiple displays I have no idea, since I've got only one display. But now I "assume" that it loads the bundle once and creates multiple instances ... Yes, one ScreenSaverView per display. Admittedly, this is a tougher assumption to test if you don't have access to a machine with multiple displays. it's really just a way to say "Yes, you must be prepared for multiple instances of your screen saver view to exist simultaneously". Again, if only Apple would have said that in the docs! Here's another one (newly introduced) that isn't in the docs (as far as I know): to run on Snow Leopard on a machine whose processor is capable of running in 64-bit mode (all currently shipping Macs), you will need a 64-bit version of your screen saver with GC supported. To run on Leopard and earlier, as well as on Snow Leopard on machines whose processor is not capable of running in 64-bit mode (Core Solo, Core Duo), you will need a 32-bit version of your screen saver with GC off. Good luck! - Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ScreenSaverView gets instantiated several times
Yes, I do. In particular, because it has a major impact on the way one has to design the code. For instance, if changing the configuration causes some longish computations. I tried pretty hard to hide this from the user, so that after applying the changes of the configuration of my screen saver, the user does not have to wait for tens of seconds until the screen saver resumes operation. Now, the design I chose to achieve this is useless, because when the user clicks 'Test', System Preferences just goes ahead and creates a new instance! Now, it seems that I have no other choice than keep up the modal panel until the computations ensuing the config chance are finished ;-( Well it's not necessarily useless, you just need to put it elsewhere. What were you doing (or trying to do) before when the user changed configuration? Were you displaying the 'last version' whilst calculating things in the background and then switching to the new version .. which would be a bit confusing. Or are you saying the first time the screen saver is used you do a bunch of complicated calculations which are slow but the results of which you cache in the instance of your screen saver class and when you change the config a bit you can recalculate the new values quite rapidly? If it's the latter, you could store the 'basic' calculations in static variables in your class, calculate them once and then have every instance of the screen saver use them. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ScreenSaverView gets instantiated several times
On 05.10.2009, at 10:39, Gabriel Zachmann wrote: I supposed that the screen saver manager would just call - initWithFrame: again. -init... methods are only called once on an instance, when it is alloced and inited. Calling it several times on the same instance that has already been initialized goes against every bit of documentation on AppKit, and more importantly, Objective C out there. I think you should get yourself a good book about Objective C, it sounds like the one you learned from so far omitted some very important aspects of Objective C. Extra credit: the user has multiple displays attached, "Main screen only" option is off, and the user clicks the Test button or activates your screen saver (hot corner, inactivity). What do you expect will happen then? I assumed it would load(!) & run the screen saver bundle multiple times. And it's not that this assumption is complete nonsense, is it? You cannot load a bundle several times on the Mac. That's because you can't unload a bundle. After all, you could be defining string constants or custom subclasses in your bundle, and someone in the program that loaded your bundle could be retaining one of those objects. Unloading it would make your application crash, because suddenly the code the class points to or the TEXT section from which the constant string came would be gone. Cheers, -- Uli Kusterer "The witnesses of TeachText are everywhere..." ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ScreenSaverView gets instantiated several times
When the user clicks 'Test' in System Preferences, it "just" creates a new instance of your subclass of ScreenSaverView! Do you really find that fact to be "shocking"? Yes, I do. In particular, because it has a major impact on the way one has to design the code. For instance, if changing the configuration causes some longish computations. I tried pretty hard to hide this from the user, so that after applying the changes of the configuration of my screen saver, the user does not have to wait for tens of seconds until the screen saver resumes operation. Now, the design I chose to achieve this is useless, because when the user clicks 'Test', System Preferences just goes ahead and creates a new instance! Now, it seems that I have no other choice than keep up the modal panel until the computations ensuing the config chance are finished ;-( If only Apple would have said so in big letters at the beginning of the docs of ScreenSaverView! What did you suppose would happen (not that suppositions and assumptions are worth much)? I supposed that the screen saver manager would just call - initWithFrame: again. Extra credit: the user has multiple displays attached, "Main screen only" option is off, and the user clicks the Test button or activates your screen saver (hot corner, inactivity). What do you expect will happen then? I assumed it would load(!) & run the screen saver bundle multiple times. And it's not that this assumption is complete nonsense, is it? What actually does happen? With multiple displays I have no idea, since I've got only one display. But now I "assume" that it loads the bundle once and creates multiple instances ... it's really just a way to say "Yes, you must be prepared for multiple instances of your screen saver view to exist simultaneously". Again, if only Apple would have said that in the docs! Best regards, Gabriel. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ScreenSaverView gets instantiated several times
On Oct 4, 2009, at 7:14 PM, Gabriel Zachmann wrote: I've been hunting a bug in my screen saver for several hours, until I've found out the following shocking fact (I think). When the user clicks 'Test' in System Preferences, it "just" creates a new instance of your subclass of ScreenSaverView! Do you really find that fact to be "shocking"? What did you suppose would happen (not that suppositions and assumptions are worth much)? Extra credit: the user has multiple displays attached, "Main screen only" option is off, and the user clicks the Test button or activates your screen saver (hot corner, inactivity). What do you expect will happen then? What actually does happen? Lest this reply sound too critical, it's really just a way to say "Yes, you must be prepared for multiple instances of your screen saver view to exist simultaneously". ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com