Message-ID:
<CABLWnS9b9zBXF261gCZmAkNP1d9K09PX+6YW_KV_QcwDghK7Og at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
In my opinion, you are missing the “Simple” in “Simple Directmedia
Library”…
If you need to do something so complex that forces you to
- set up callbacks;
- respond in quasi real time;
- handle a variable number of events
you might as well just subclass the main delegate instead of
completely revolutionising the SDL chain.
Beware that I hardly believe the proposed implementation is future
proof, in fact as you know the events that need a fast action might
change with every ios release (like it happened from 3.x to 4.x).
I’m sure that subclassing+ovverriding can be adopted for android as well.
The only way that I can think of that this might future-proof your
application is if you provide implementations for ALL events in this
manner. If you do THAT, then there is NO reason to use SDL, because
you’re already doing almost everything that it does.> Date: Thu, 29 Mar 2012 17:07:24 +0200
From: Vittorio Giovara <vitto.giova at yahoo.it>
To: SDL Development List
Subject: Re: [SDL] iOS System Callback
Date: Thu, 29 Mar 2012 14:23:45 -0400
From: Brian Barnes
To: sdl at lists.libsdl.org
Subject: Re: [SDL] iOS System Callback
Message-ID:
Content-Type: text/plain; charset=us-ascii
Jared wrote:
As far as my comment goes, it was about duplicating the callback into
the event queue. I have no problem with callbacks.
Yes, I understand that, what I’m trying to tell you is that it just won’t
work. You will NOT get some of these messages in the event queue; your
program will be halted at that point. What you will get is the worse
possible solution: player hits button, you get one event, code is halted,
then you get (in a row) the “enter background” and “exit background” AFTER
you have exited the background. This is bad and will only serve to make the
events useless.
There’s nothing stopping you dropping a “minizimed” or “maximized” event on
the queue. Again, you’re avoiding the giant elephant in the room, which is
that your code is halted! You can’t timely send these messages. This is
just how iOS works. No usage case is going to change how the OS works.
Ah, I understand now. I had thought that you didn’t understand my
post, but it was the other way around. Thus, I apologize for the delay
in telling you this:
I HAVE considered this before, in reference to the very project that I
mentioned (technically it was related to PWM messages, but the timing
issue was the same). When I say ‘non-time-critical’ I mean it. It
doesn’t matter if it runs after execution resumes, because you’re just
informing the code of something that happened, nothing more. My
conclusion was the same as now: the event makes sense, because the
user of the event gets to read the documentation and decide if they
care about it.
Remember, SDL is calling your handler from within it’s handler, it can
do whatever temporary archiving that it needs to (though I assume that
it currently favors “don’t need to”), so these events have no reason
to just vanish (in fact, you suggest otherwise yourself). Further, it
doesn’t matter if the messages are timely, because that’s what the
callback itself is for in the first place! As I said twice now,
time-critical vs. non-time-critical. Time-critical needs the callback,
non-time-critical just needs to know that it happened at all. When
non-time-critical code finds out doesn’t matter.
Now, is it perhaps a little silly to have two events for this? Sure,
but that’s an implementation detail.
Vittorio wrote:
In my opinion, you are missing the “Simple” in “Simple Directmedia
Library”…
If you need to do something so complex that forces you to
- set up callbacks;
- respond in quasi real time;
- handle a variable number of events
you might as well just subclass the main delegate instead of
completely revolutionising the SDL chain.
Beware that I hardly believe the proposed implementation is future
proof, in fact as you know the events that need a fast action might
change with every ios release (like it happened from 3.x to 4.x).
I’m sure that subclassing+ovverriding can be adopted for android as well.
I’m not discreting the patch or the patch’s author, I’m just worried
about the possible implications and feature duplication.
You can never create anything if you are worried about APIs changing. They
will, and there’s nothing you can do about it. Overriding is not a good
ideal in a library! The concept of libraries is that they are black boxes.
I should note that the big change in iOS (when background processing was
added) was the ADDITION of new events. An override would have the exact
same problem.
Agreed.
And “Simple” is find, but “works” is better. If this is the way it’s
required to do by the OS, there’s no way around it. You have to respond
to these in real time.
Also, if (just as an example) someone decided to port SDL as a
micro-kernel interface to graphics hardware, this callback system
could be used to make hardware-interrupts easier to deal with. Same
thing would go with any other callback system that used unusual
function styles (e.g. lots of MS Windows functions, so probably
WindowsRT); by handling those things itself & providing a callback
interface where relevant, SDL makes it much easier to deal with those
systems.
Date: Thu, 29 Mar 2012 15:46:35 -0300
From: Gabriel Jacobo
To: SDL Development List
Subject: Re: [SDL] iOS System Callback
Message-ID:
<CAKDfes=ZiBCdjWFSPkKb2bkhNYgTUugxF7_JFboKrjorbpf5yA at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
I think overriding the delegate, if possible, is the best solution as
you keep the changes limited to the platform that’s got the problem,
and you leave up to the developer what solution to implement. There’s
plenty of examples of black box libraries where you have to override
things to make it work, the iOS framework being the first that comes
to mind!
That sounds REALLY badly designed. Interfaces to other systems should
fully adapt what they’re interfacing to into their own idioms. SDL
interfaces to OS systems, and should thus fully adapt those parts of
iOS that it actually touches (in some cases this might not actually be
realistic, but this is not one of those cases).
We can also consider adding an example implementation of these
overrides to help new users get quickly up to speed, or modify the
current delegate to error out if you haven’t overriden the required
methods, etc.
The first just increases the boilerplate that developers have to
write, the second is obnoxious (especially if they just don’t care,
e.g. a clock application).