12

注:これは私がすでに答えを見つけた質問です。面白い答えを見つけてから質問を投稿することが奨励されているようですので、投稿させていただきます。他の誰かが同じ問題を抱えている可能性が高く、これが役立つと思います。


グラフを生成する iOS アプリがあります。更新を公開した直後に、あるユーザーから次のパニックに陥ったメールが送られてきました。

「最新の更新により曲線が変更されました...これ以上の成長曲線は見られず、挿入されたデータは下降線として表されます...完全によく見る前に

助けて"

私は彼にスクリーンショットを送ってもらい、詳細を説明します。彼は iPhone 3G を持っており、これが女の子のチャートです。ほとんどの点は間違った座標に描かれています: (x,y) ではなく (x,x) に描かれているように見えます。

バグのあるディスプレイのスクリーンショット

これがどのように見えるかを比較してください (色の違いは無視してください -- ピンクは女の子用、ブルーは男の子用です):

正しい表示のスクリーンショット

多くの実験の後、以前のバージョンの再構築バージョン (彼にとっては問題なく動作しました) を彼に送りましたが、それでも動作しません。結局、アップデートでのコードの変更はそれとは何の関係もないように見えます。説明は何でしょうか?

4

1 に答える 1

11

iPhone original and iPhone 3G use the armv6 architecture, later models armv7. An answer to this Stack Overflow question, and an Apple developer forum thread point to a problem in the armv6 Thumb code produced by XCode 4.2's compiler which cause arithmetic operations on certain data structures, in particular CGPoint, to return completely wrong results. Such as the x value being written into the y value.

The solution is to add the -mno-thumb compiler option to the XCode project. This tells the compiler not to emit Thumb mode code, thereby bypassing the bug. Another solution is to switch back to an earlier XCode (pre-iOS5 SDK), which doesn't have this bug.

So the bug is in the compiler! How cool is that? :) In two decades of developing, I was yet to come across such a thing.

Here's a screenshot showing where to add this compiler option if it helps anyone:

enter image description here

于 2011-12-05T20:26:10.333 に答える